Skip to content

Project Context Files

AI tools read markdown files in your project root to understand context, conventions, and gotchas. If those files are good, the tool stops fighting you so much.

ToolContext FileNotes
Claude CodeCLAUDE.mdOfficial convention
Cursor.cursorrulesOr .cursor/rules/*.mdc
ZedAGENTS.mdAlso reads CLAUDE.md
Continue.devAGENTS.mdAlso reads CLAUDE.md
Copilot.github/copilot-instructions.mdGitHub convention
Any toolAGENTS.mdWidely recognized fallback

“Overly verbose files can lead to Claude ignoring instructions if deemed irrelevant. Aim for under 300 lines.” — Anthropic

Target lengths:

  • Ideal: Under 100 lines
  • Maximum: Under 300 lines
  • If longer: Split into multiple files

For each line, ask: “Would removing this cause the AI to make mistakes?” If not, cut it.

CategoryExamples
Gotchas”Use date-fns, not moment” / “Auth tokens in cookies, not localStorage”
Commandsnpm run dev, npm test, build commands
Non-obvious architecture”Database schema in /prisma/, not /db/
Project-specific conventions”Named exports only” / “No class components”
CategoryWhy Skip
Language basicsAI knows TypeScript, Python, etc.
Framework docsAI knows React, Express, FastAPI
Obvious patternsIf it’s in the code, AI will see it
Vocabulary definitionsDon’t explain what “component” means
Architectural patternsDon’t explain MVC, Clean Architecture

Do not embed everything. Tell the AI where to look.

## Architecture
See `/docs/architecture.md` for detailed system design.
## API Conventions
See `/docs/api-conventions.md` for request/response patterns.
## Database
Schema in `/prisma/schema.prisma`. Migrations in `/prisma/migrations/`.

That keeps the context file short while still giving the AI a path to the details.

For larger projects, use a hierarchy of context files:

project/
├── CLAUDE.md # Project-wide: commands, gotchas, conventions
├── src/
│ ├── api/
│ │ └── CLAUDE.md # API-specific: auth patterns, error handling
│ └── components/
│ └── CLAUDE.md # Component-specific: styling, state patterns
└── docs/
├── architecture.md # Detailed docs (linked, not embedded)
└── api-conventions.md

Personal + project files:

  • ~/.claude/CLAUDE.md: your personal preferences
  • ./CLAUDE.md: project-specific context
# Project Context
## What This Is
[One sentence describing the project]
## Commands
- `[command]` - [what it does]
## Gotchas
- [Thing the AI gets wrong and how to fix it]
## Code Style
- [Non-obvious preference]

That is enough. Start small and add only what prevents repeated mistakes.

Anti-PatternWhy It Fails
Embedding full documentationAI ignores long files; use links instead
Explaining language basicsAI already knows; wastes context
Duplicating README contentAI can read README; don’t repeat
Listing every file/folderAI can explore; describe only non-obvious structure
Verbose style guidesKeep to 3-5 key rules; AI infers the rest
# Project Rules
## Commands
- `npm run dev` - Start dev server
- `npm test` - Run tests
- `npm run lint` - Lint and typecheck
## Gotchas
- Auth tokens in cookies, not localStorage
- Use `date-fns`, not moment
- Database schema in `/prisma/schema.prisma`
## Code Style
- Named exports only
- Prefer arrow functions for components

22 lines. The rest is usually already visible in the code.

# Project Context
## Commands
- `uv run uvicorn app.main:app --reload` - Dev server
- `uv run pytest` - Run tests
- `uv run alembic upgrade head` - Migrations
## Gotchas
- Model artifacts in `/models/` - don't commit (use DVC)
- Legacy `/v1/score` uses old schema - don't modify
## Code Style
- Type hints on all functions
- Async for I/O, sync for CPU-bound

16 lines. Focused on what the AI would get wrong without guidance.

Your context file should evolve:

  1. Start minimal: 10-20 lines
  2. Add when AI makes mistakes: “It keeps suggesting moment instead of date-fns” -> add gotcha
  3. Remove when redundant: if the tool consistently gets something right, stop spending lines on it
  4. Version control: track changes and revert them if they make the file worse

Ready-to-use templates for common stacks: