cursor-best-practices
AGENTS.md7 starsChanged 10 months agoMITView on GitHub
This document provides comprehensive guidance for Cursor's AI to understand this codebase at the deepest level. Use this when working on, modifying, or extending the cursor-best-practices skill. cursor-best-practices is a Cursor Agent Skill that provides comprehensive best practices for using Cursor. It's designed to: - Help users set up and configure Cursor effectively - Provide 250+ rule files covering all aspects of Cursor usage - Offer ready-to-use templates for commands, agents, and skills - Guide users in making their codebases…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository5 other files it gives its agents.
- .cursor/rules/architecture-and-design.mdCursor rule
- .cursor/rules/codebase-structure.mdCursor rule
- .cursor/rules/content-patterns.mdCursor rule
- .cursor/rules/skill-maintenance.mdCursor rule
- cursor-best-practicesSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
28 rules. About 1 is common, 21 are distinctive, and 6 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈21
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 49
When to use the skill
- Distinctive: line 163
All rules have been enhanced with keyword-rich descriptions
- Distinctive: line 276
Every rule file follows this structure:
- Distinctive: line 286
Do: [Pattern] section with explanation and examples
- Distinctive: line 287
Don't: [Anti-pattern] section with explanation and examples
- Very specific: line 323
Choose location: Place in appropriate rules/ subdirectory based on topic
- Distinctive: line 325
Write content: Follow Do/Don't pattern with examples
- Very specific: line 327
Update index: Add entry to rules/_sections.md
- Distinctive: line 328
Update indexes: Add to relevant index files if needed
- Distinctive: line 336
Update when adding major new sections
- Distinctive: line 342
Keep them clear and well-documented
- Distinctive: line 350
Keep comprehensive but organized
- Distinctive: line 351
Don't duplicate rule content
- Distinctive: line 355
Update indexes when adding new rules
- Very specific: line 365
By query: Check indexes/query-index.md
- Very specific: line 373
Deep dives: Check references/
- Distinctive: line 379
Follow patterns in existing files
- Very specific: line 380
Update _sections.md when adding rules
- Very specific: line 383
Follow skill maintenance guidelines in .cursor/rules/skill-maintenance.md
- Distinctive: line 417
All aspects of Cursor usage are covered
- Distinctive: line 434
Use-case index: Find rules by task
- Distinctive: line 464
All required fields present
- Common: line 486
No secrets in repository
- Distinctive: line 488
All content is public (MIT license)
- Distinctive: line 489
No executable code (markdown only)
- Distinctive: line 495
Update rules: when features change
- Distinctive: line 496
Add new rules: when patterns emerge
- Distinctive: line 497
Update indexes: when adding rules
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cursor Best Practices - Deep Codebase Guide
This document provides comprehensive guidance for Cursor's AI to understand this codebase at the deepest level. Use this when working on, modifying, or extending the cursor-best-practices skill.
Repository Purpose
cursor-best-practices is a Cursor Agent Skill that provides comprehensive best practices for using Cursor. It's designed to:
- Help users set up and configure Cursor effectively
- Provide 250+ rule files covering all aspects of Cursor usage
- Offer ready-to-use templates for commands, agents, and skills
- Guide users in making their codebases Cursor-compatible
- Serve as a reference implementation of the Agent Skills specification
Repository Structure (Deep Dive)
Root Level
cursor-best-practices/
├── README.md # Main documentation - installation, usage, examples
├── CHANGELOG.md # Version history following Keep a Changelog format
├── CONTRIBUTING.md # Contribution guidelines and workflow
├── LICENSE # MIT license
├── metadata.json # Skill metadata for discovery (version, abstract, references)
├── CODEBASE.md # High-level codebase overview
├── .gitignore # Git ignore patterns (OS files, editor files, temp files)
└── .cursor/ # Project-specific Cursor configuration
├── AGENTS.md # This file - deep codebase guide
├── rules/ # Project-specific rules for this codebase
│ ├── codebase-structure.md
│ └── skill-maintenance.md
└── .cursorignore # Files to exclude from Cursor featuresSkill Directory: cursor-best-practices/
The actual skill content lives in the nested cursor-best-practices/ folder. This structure allows the repository to be installed via npx skills add which expects the skill folder to match the repository name.
Core Skill File
SKILL.md - Main skill file with:
- Frontmatter: name, description, license, compatibility, metadata
name: Must match folder name (cursor-best-practices)description: Keyword-rich, includes when-to-use scenarioslicense: MITcompatibility: References all three standards (Agent Skills, skills.sh, Cursor)metadata: author, version, standards links
- Body: Comprehensive guide covering:
- When to use the skill
- Rules overview and types
- Commands available
- Skills and subagents
- Ignore files
- Agent and security
- Agent modes
- Workflows and large codebases
- Semantic search, @mentions, Tab
- Bugbot, MCP, shortcuts
- Setup workflow
- Troubleshooting
- Length: Kept under ~500 lines, links to detailed content in rules/ and references/
Rules Directory (rules/)
Structure: 250+ rule files organized hierarchically by category
Organization Pattern:
- Top-level rules:
rules-*.md,context-*.md,modes-*.md,workflows-*.md,ignore-*.md - Category subdirectories:
agent/,context/,features/,integrations/,configuration/,cookbook/,troubleshooting/,get-started/
Key Files:
_template.md- Template for creating new rules (frontmatter structure, Do/Don't pattern)_sections.md- Index of all rules organized by category (navigation aid)
Rule File Structure:
---
description: "Keyword-rich description with multiple phrasings, synonyms, common queries"
tags: [tag1, tag2, tag3, related-tags, query-variations]
globs: ["**/*.ts"] # Optional, for file-specific rules
alwaysApply: false # Optional, default false
---
# Rule Title
Brief introduction explaining the practice.
## Do: [Pattern Name]
Explanation of the correct approach with examples.
## Don't: [Anti-pattern Name]
Explanation of what to avoid with examples.
## Related Queries
Users might ask:
- "How to..."
- "When to..."
- "What is..."
## See Also
- [Related rule](path/to/rule.md)
- [Cursor docs](https://cursor.com/docs/...)Categories Breakdown:
agent/(34 files)modes/- Agent, Ask, Plan, Debug modes (when to use, how to use)patterns/- Scoping, reviewing, mentions patternsuse-cases/- Bug fixing, feature development, refactoringoverview.md- Agent overview
context/(45 files)rules/- Rule anatomy, best practices, file structure, how rules work, project rulescommands/- Creating commands, examples, locations, structuremcp/- MCP authentication, configuration, protocols, troubleshootingskills/- Skill discovery, examples, structure, usagesubagents/- Built-ins, configuration, types, usage patternssemantic-search/- Combine with grep, limitations, when to usementions/- Scoping down, use code for snippets, use file and folder
features/(32 files)tab/- Suggestions, partial accepts, auto-import, jump, settings, toggling, FAQinline-edit/- Patterns, single-file edits, Ctrl+K workflow, troubleshootingbugbot/- Patterns, examples, testing, syntaxcli/- Overview, installation, commands, agent modes, automation, scripting, CI/CDcloud/- Overview, setup, configuration, use cases, resources, timeoutstranscripts/- Overview, creation, privacy, access control, sensitive data, workflows
integrations/(30 files)github/- Setup, authentication, PR workflows, issues, cloud agents, cursor mentionslack/- Setup, authentication, automation, cloud agents, cursor mention, notificationsgitlab/- Overview, setup, authentication, PR workflows, issues, automationlinear/- Overview, setup, authentication, automation, workflowsgit/- Overview, setup, authentication, branches, commits, merge, rebase, strategies, patternsdeeplinks/- Overview, format, usage, examples
configuration/(29 files)extensions/- Overview, installation, discovery, configuration, conflictsignore/- .cursorignore, .cursorindexingignore, syntax, securitylanguages/- Overview, configuration, features, settingsmigrations/- Overview, process, troubleshootingshell/- Overview, configuration, patterns, usageshortcuts/- Core shortcuts, custom shortcuts, shortcuts by mode, shortcuts by platformthemes/- Overview, dark mode, light mode, customization, selection
cookbook/(13 files)examples/- API integration, component creation, database query, refactoring legacypatterns/- Context management, error handling, iterative developmentworkflows/- Bug fixing, code review, feature development, refactoring, team workflows, testing
troubleshooting/(7 files)- Common issues, rules not applying, agent errors, authentication issues, performance issues, request ID, troubleshooting guide
get-started/(5 files)- Overview, quickstart, concepts, models, pricing, make-codebase-cursor-compatible
Rule Enhancement Pattern:
- All rules have been enhanced with keyword-rich descriptions
- Each includes "Related Queries" section for discoverability
- Tags include query variations (how-to-use-X, what-is-X, when-to-use-X)
- Descriptions include multiple phrasings and synonyms
Commands Directory (commands/)
Purpose: Ready-to-use command templates that users copy to .cursor/commands/
Format: Plain Markdown files, no frontmatter needed. Filename = command name.
Files (14 total):
code-review.md- Review code for correctness, security, quality, testspr.md- Summarize changes, propose PR title/descriptionrun-tests-and-fix.md- Run tests, fix failures, re-run until greensecurity-audit.md- Security-focused reviewsetup-new-feature.md- Propose plan for new featurefix-issue.md- Fix bug or feature from issueupdate-deps.md- Update dependencies, run testsdocs.md- Generate or update documentationmake-cursor-compatible.md- Make codebase Cursor-compatiblelint-and-fix.md- Run linter, auto-fix issues, report remainingformat.md- Format code according to project standardscheck-coverage.md- Check test coverage, identify gaps, suggest improvementsanalyze-deps.md- Analyze dependency tree, identify unused/duplicate depsgenerate-types.md- Generate TypeScript/types from schemas, APIs, or JSON
Structure: Each command includes:
- Clear instructions for the AI
- Usage examples
- Output format specification
- Checklist or step-by-step structure
Agents Directory (agents/)
Purpose: Subagent templates that users copy to .cursor/agents/
Files (15 total):
Read-only subagents (review/analysis):
verifier.md- Template for verification subagent (runs tests and lint, reports only)reviewer.md- Code review subagent (correctness, security, quality, tests; read-only)security-auditor.md- Security-focused review subagent (injection, auth, secrets, deps; read-only)linter.md- Linting subagent (linting and code style review; read-only)architect.md- Architectural review subagent (architectural patterns and design review; read-only)
Editable subagents (can modify code):
documenter.md- Documentation subagent (generate/update docs; can edit)tester.md- Test writing subagent (write and update tests; can edit)refactorer.md- Refactoring subagent (improve code quality while maintaining functionality; can edit)debugger.md- Debugging subagent (investigate and identify bugs; can edit)performance-analyzer.md- Performance review subagent (analyze bottlenecks and optimization opportunities; can edit)accessibility-checker.md- Accessibility review subagent (WCAG compliance and a11y best practices; can edit)migrator.md- Migration subagent (handle framework upgrades, API changes; can edit)dependency-manager.md- Dependency management subagent (review and manage dependencies; can edit)formatter.md- Code formatting subagent (format code according to standards; can edit)type-generator.md- Type generation subagent (generate types from schemas/APIs; can edit)
Format: Markdown with YAML frontmatter (name, description)
Skills Directory (skills/)
Purpose: Skill-related content and recommendations
Files:
recommended.md- Curated list of recommended skills from skills.sh, organized by category_template-skill.md- Template for creating new skills
References Directory (references/)
Purpose: Deep-dive guides with comprehensive explanations (longer narrative content)
Files (5 total):
rules-and-commands.md- Comprehensive guide to rules and commandsagent-and-security.md- Agent tools, workflows, security best practicesworkflows-and-codebases.md- TDD, git-style commands, large codebasesmodes-context-tools.md- Agent modes, semantic search, @mentions, Tab, Bugbotquick-reference.md- Quick reference guide with shortcuts, commands, subagents, and workflows
Purpose: These are linked from SKILL.md to avoid duplicating long content. They provide comprehensive coverage of complex topics.
Indexes Directory (indexes/)
Purpose: Navigation indexes for quick discovery of relevant content
Files (8 total):
query-index.md- Maps common user queries to relevant rulessetup-workflows-index.md- Framework and project setup guidesfeature-index.md- Feature-based index organizing rules by Cursor featureintegration-index.md- Integration index covering GitHub, GitLab, Slack, etc.configuration-index.md- Configuration index for extensions, ignore files, languages, etc.troubleshooting-index.md- Troubleshooting index mapping problems to solutionspattern-index.md- Pattern index for common coding patternsuse-case-index.md- Use case index organizing by task (bug fixing, feature development, etc.)
File Naming Conventions
Rules
- Top-level:
kebab-case.md(e.g.,rules-keep-under-500-lines.md,context-setup-cursor-folder.md) - In subdirectories:
kebab-case.md(e.g.,agent-mode.md,creating-rules.md) - Index files:
*-index.md(e.g.,query-index.md) - Templates:
_template*.md(e.g.,_template.md,_template-skill.md)
Commands
- Format:
kebab-case.mdmatching command name (e.g.,code-review.md→/code-review)
Directories
- Format:
kebab-case(e.g.,agent/,get-started/,context/)
Content Patterns
Rule File Pattern
Every rule file follows this structure:
- Frontmatter (YAML):
description: Keyword-rich, multiple phrasings, includes common queriestags: Base tags + query variations + synonymsglobs: Optional, for file-specific rulesalwaysApply: Optional, default false
- Body:
- Brief introduction
- Do: [Pattern] section with explanation and examples
- Don't: [Anti-pattern] section with explanation and examples
- Related Queries section (common user questions)
- See Also section (links to related rules and docs)
- Length: Under ~500 lines (split by concern if needed)
Command File Pattern
Commands are plain Markdown with:
- Clear title
- Instructions for the AI
- Usage examples
- Output format specification
- Step-by-step structure or checklist
Reference File Pattern
References are longer narrative guides that:
- Provide comprehensive coverage
- Link to rules (don't duplicate)
- Include examples and patterns
- Cover complex topics in detail
Key Principles
- One practice per file - Each rule covers one specific practice
- Keyword-rich descriptions - Frontmatter descriptions help with relevance matching
- Clear organization - Files organized by category and use case
- Link, don't duplicate - Reference guides link to rules, not duplicate content
- User-focused - Content helps users understand and use Cursor effectively
- Standards-compliant - Follows Agent Skills specification, compatible with skills.sh and Cursor
When Working on This Codebase
Adding a New Rule
- Choose location: Place in appropriate
rules/subdirectory based on topic - Use template: Copy
rules/_template.mdas starting point - Write content: Follow Do/Don't pattern with examples
- Add frontmatter: Include keyword-rich description and tags
- Update index: Add entry to
rules/_sections.md - Update indexes: Add to relevant index files if needed
- Add Related Queries: Include common user questions
- Add See Also: Link to related rules and docs
Modifying SKILL.md
- Keep under ~500 lines
- Link to rules/, commands/, agents/, skills/, references/
- Update when adding major new sections
- Maintain frontmatter accuracy
Updating Commands
- Commands are templates users copy
- Keep them clear and well-documented
- Include usage examples
- Maintain consistent structure
Working with References
- References are longer narrative guides
- Link from SKILL.md
- Keep comprehensive but organized
- Don't duplicate rule content
Maintaining Indexes
- Update indexes when adding new rules
- Maintain alphabetical or logical ordering
- Include brief descriptions
- Link to rule files
Common Tasks
Finding Content
- By category: Browse
rules/subdirectories - By query: Check
indexes/query-index.md - By feature: See
indexes/feature-index.md - By use case: See
indexes/use-case-index.md - All rules: See
rules/_sections.md
Understanding Structure
- Overview: Read
SKILL.md - Deep dives: Check
references/ - Templates: See
rules/_template.md - This codebase: See this file (
.cursor/AGENTS.md)
Contributing
- Follow patterns in existing files
- Update
_sections.mdwhen adding rules - Update relevant indexes
- See
CONTRIBUTING.mdfor details - Follow skill maintenance guidelines in
.cursor/rules/skill-maintenance.md
Standards Compliance
This skill follows three standards:
- Agent Skills Specification (https://agentskills.io/specification)
- Proper SKILL.md frontmatter
- Correct directory structure
- Standards-compliant format
- skills.sh (https://skills.sh/docs)
- GitHub repository structure
- Installable via
npx skills add - Proper metadata
- Cursor Skills (https://cursor.com/docs/context/skills)
- Compatible with
.cursor/skills/structure - Works with Cursor's skill discovery
- Supports Cursor-specific features
- Compatible with
Architecture Decisions
Why Nested Structure?
The cursor-best-practices/cursor-best-practices/ nested structure allows:
- Repository name matches skill name
- Direct installation via
npx skills add HKTITAN/cursor-best-practices - Skill folder name matches repository name (required by skills.sh)
Why 250+ Rules?
Comprehensive coverage ensures:
- Users can find guidance for any Cursor-related question
- All aspects of Cursor usage are covered
- Rules are discoverable through multiple indexes
- Keyword-rich descriptions enable relevance matching
Why Separate References?
References separate from rules because:
- Rules should be concise (<500 lines)
- References provide deep-dive content
- Avoids duplication
- Keeps SKILL.md focused
Why Multiple Indexes?
Different indexes serve different purposes:
- Query index: Find rules by user question
- Feature index: Find rules by Cursor feature
- Use-case index: Find rules by task
- Setup index: Find setup guides
- Pattern index: Find coding patterns
- Integration index: Find integration guides
- Configuration index: Find configuration guides
- Troubleshooting index: Find solutions to problems
Dependencies and Relationships
File Dependencies
SKILL.mdlinks to: rules/, commands/, agents/, skills/, references/rules/_sections.mdindexes all rules- Index files reference rule files
- Reference files link to rule files
- Commands are standalone (users copy them)
Content Relationships
- Rules are atomic (one practice per file)
- References aggregate related rules
- Indexes organize rules by different dimensions
- Commands are independent templates
- SKILL.md provides overview and navigation
Testing and Validation
Skill Structure Validation
- SKILL.md frontmatter matches specification
- All required fields present
- Folder structure correct
- Files follow naming conventions
Content Quality
- Rules follow template structure
- Descriptions are keyword-rich
- Examples are clear and practical
- Links are valid
- No broken references
Performance Considerations
- Rules load on demand (not all at once)
- Indexes enable quick discovery
- References linked, not duplicated
- SKILL.md kept concise (<500 lines)
- File-specific rules use globs for efficiency
Security Considerations
- No secrets in repository
- .cursorignore excludes sensitive files
- All content is public (MIT license)
- No executable code (markdown only)
- References external docs (not embedded)
Maintenance Workflow
- Track Cursor docs for changes
- Update rules when features change
- Add new rules when patterns emerge
- Update indexes when adding rules
- Update CHANGELOG.md for notable changes
- Update metadata.json version
- Test installation via
npx skills add
Future Enhancements
Potential additions:
- More command templates
- Additional subagent templates
- More reference guides
- Additional indexes
- Scripts for automation
- Examples and demos
See Also
- CODEBASE.md - High-level overview
- CONTRIBUTING.md - Contribution guidelines
- SKILL.md - Main skill file
- rules/_sections.md - Rules index
- .cursor/rules/skill-maintenance.md - Maintenance guidelines
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

