agentleFS
HKTITANHKTITAN/cursor-best-practices/.cursor/AGENTS.md

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…

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
  1. Distinctive:

    When to use the skill

    line 49
  2. Distinctive:

    All rules have been enhanced with keyword-rich descriptions

    line 163
  3. Distinctive:

    Every rule file follows this structure:

    line 276
  4. Distinctive:

    Do: [Pattern] section with explanation and examples

    line 286
  5. Distinctive:

    Don't: [Anti-pattern] section with explanation and examples

    line 287
  6. Very specific:

    Choose location: Place in appropriate rules/ subdirectory based on topic

    line 323
  7. Distinctive:

    Write content: Follow Do/Don't pattern with examples

    line 325
  8. Very specific:

    Update index: Add entry to rules/_sections.md

    line 327
  9. Distinctive:

    Update indexes: Add to relevant index files if needed

    line 328
  10. Distinctive:

    Update when adding major new sections

    line 336
  11. Distinctive:

    Keep them clear and well-documented

    line 342
  12. Distinctive:

    Keep comprehensive but organized

    line 350
  13. Distinctive:

    Don't duplicate rule content

    line 351
  14. Distinctive:

    Update indexes when adding new rules

    line 355
  15. Very specific:

    By query: Check indexes/query-index.md

    line 365
  16. Very specific:

    Deep dives: Check references/

    line 373
  17. Distinctive:

    Follow patterns in existing files

    line 379
  18. Very specific:

    Update _sections.md when adding rules

    line 380
  19. Very specific:

    Follow skill maintenance guidelines in .cursor/rules/skill-maintenance.md

    line 383
  20. Distinctive:

    All aspects of Cursor usage are covered

    line 417
  21. Distinctive:

    Use-case index: Find rules by task

    line 434
  22. Distinctive:

    All required fields present

    line 464
  23. Common:

    No secrets in repository

    line 486
  24. Distinctive:

    All content is public (MIT license)

    line 488
  25. Distinctive:

    No executable code (markdown only)

    line 489
  26. Distinctive:

    Update rules: when features change

    line 495
  27. Distinctive:

    Add new rules: when patterns emerge

    line 496
  28. Distinctive:

    Update indexes: when adding rules

    line 497

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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 features

Skill 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 scenarios
    • license: MIT
    • compatibility: 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:

  1. agent/ (34 files)
    • modes/ - Agent, Ask, Plan, Debug modes (when to use, how to use)
    • patterns/ - Scoping, reviewing, mentions patterns
    • use-cases/ - Bug fixing, feature development, refactoring
    • overview.md - Agent overview
  2. context/ (45 files)
    • rules/ - Rule anatomy, best practices, file structure, how rules work, project rules
    • commands/ - Creating commands, examples, locations, structure
    • mcp/ - MCP authentication, configuration, protocols, troubleshooting
    • skills/ - Skill discovery, examples, structure, usage
    • subagents/ - Built-ins, configuration, types, usage patterns
    • semantic-search/ - Combine with grep, limitations, when to use
    • mentions/ - Scoping down, use code for snippets, use file and folder
  3. features/ (32 files)
    • tab/ - Suggestions, partial accepts, auto-import, jump, settings, toggling, FAQ
    • inline-edit/ - Patterns, single-file edits, Ctrl+K workflow, troubleshooting
    • bugbot/ - Patterns, examples, testing, syntax
    • cli/ - Overview, installation, commands, agent modes, automation, scripting, CI/CD
    • cloud/ - Overview, setup, configuration, use cases, resources, timeouts
    • transcripts/ - Overview, creation, privacy, access control, sensitive data, workflows
  4. integrations/ (30 files)
    • github/ - Setup, authentication, PR workflows, issues, cloud agents, cursor mention
    • slack/ - Setup, authentication, automation, cloud agents, cursor mention, notifications
    • gitlab/ - Overview, setup, authentication, PR workflows, issues, automation
    • linear/ - Overview, setup, authentication, automation, workflows
    • git/ - Overview, setup, authentication, branches, commits, merge, rebase, strategies, patterns
    • deeplinks/ - Overview, format, usage, examples
  5. configuration/ (29 files)
    • extensions/ - Overview, installation, discovery, configuration, conflicts
    • ignore/ - .cursorignore, .cursorindexingignore, syntax, security
    • languages/ - Overview, configuration, features, settings
    • migrations/ - Overview, process, troubleshooting
    • shell/ - Overview, configuration, patterns, usage
    • shortcuts/ - Core shortcuts, custom shortcuts, shortcuts by mode, shortcuts by platform
    • themes/ - Overview, dark mode, light mode, customization, selection
  6. cookbook/ (13 files)
    • examples/ - API integration, component creation, database query, refactoring legacy
    • patterns/ - Context management, error handling, iterative development
    • workflows/ - Bug fixing, code review, feature development, refactoring, team workflows, testing
  7. troubleshooting/ (7 files)
    • Common issues, rules not applying, agent errors, authentication issues, performance issues, request ID, troubleshooting guide
  8. 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):

  1. code-review.md - Review code for correctness, security, quality, tests
  2. pr.md - Summarize changes, propose PR title/description
  3. run-tests-and-fix.md - Run tests, fix failures, re-run until green
  4. security-audit.md - Security-focused review
  5. setup-new-feature.md - Propose plan for new feature
  6. fix-issue.md - Fix bug or feature from issue
  7. update-deps.md - Update dependencies, run tests
  8. docs.md - Generate or update documentation
  9. make-cursor-compatible.md - Make codebase Cursor-compatible
  10. lint-and-fix.md - Run linter, auto-fix issues, report remaining
  11. format.md - Format code according to project standards
  12. check-coverage.md - Check test coverage, identify gaps, suggest improvements
  13. analyze-deps.md - Analyze dependency tree, identify unused/duplicate deps
  14. generate-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):

  1. rules-and-commands.md - Comprehensive guide to rules and commands
  2. agent-and-security.md - Agent tools, workflows, security best practices
  3. workflows-and-codebases.md - TDD, git-style commands, large codebases
  4. modes-context-tools.md - Agent modes, semantic search, @mentions, Tab, Bugbot
  5. quick-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):

  1. query-index.md - Maps common user queries to relevant rules
  2. setup-workflows-index.md - Framework and project setup guides
  3. feature-index.md - Feature-based index organizing rules by Cursor feature
  4. integration-index.md - Integration index covering GitHub, GitLab, Slack, etc.
  5. configuration-index.md - Configuration index for extensions, ignore files, languages, etc.
  6. troubleshooting-index.md - Troubleshooting index mapping problems to solutions
  7. pattern-index.md - Pattern index for common coding patterns
  8. use-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.md matching 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:

  1. Frontmatter (YAML):
    • description: Keyword-rich, multiple phrasings, includes common queries
    • tags: Base tags + query variations + synonyms
    • globs: Optional, for file-specific rules
    • alwaysApply: Optional, default false
  2. 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)
  3. 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

  1. One practice per file - Each rule covers one specific practice
  2. Keyword-rich descriptions - Frontmatter descriptions help with relevance matching
  3. Clear organization - Files organized by category and use case
  4. Link, don't duplicate - Reference guides link to rules, not duplicate content
  5. User-focused - Content helps users understand and use Cursor effectively
  6. Standards-compliant - Follows Agent Skills specification, compatible with skills.sh and Cursor

When Working on This Codebase

Adding a New Rule

  1. Choose location: Place in appropriate rules/ subdirectory based on topic
  2. Use template: Copy rules/_template.md as starting point
  3. Write content: Follow Do/Don't pattern with examples
  4. Add frontmatter: Include keyword-rich description and tags
  5. Update index: Add entry to rules/_sections.md
  6. Update indexes: Add to relevant index files if needed
  7. Add Related Queries: Include common user questions
  8. 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.md when adding rules
  • Update relevant indexes
  • See CONTRIBUTING.md for details
  • Follow skill maintenance guidelines in .cursor/rules/skill-maintenance.md

Standards Compliance

This skill follows three standards:

  1. Agent Skills Specification (https://agentskills.io/specification)
    • Proper SKILL.md frontmatter
    • Correct directory structure
    • Standards-compliant format
  2. skills.sh (https://skills.sh/docs)
    • GitHub repository structure
    • Installable via npx skills add
    • Proper metadata
  3. Cursor Skills (https://cursor.com/docs/context/skills)
    • Compatible with .cursor/skills/ structure
    • Works with Cursor's skill discovery
    • Supports Cursor-specific features

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.md links to: rules/, commands/, agents/, skills/, references/
  • rules/_sections.md indexes 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

  1. Track Cursor docs for changes
  2. Update rules when features change
  3. Add new rules when patterns emerge
  4. Update indexes when adding rules
  5. Update CHANGELOG.md for notable changes
  6. Update metadata.json version
  7. 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.