Skip to content

Context Awareness

Claude Code is smarter when it understands your project. The CLAUDE.md file tells Claude what it needs to know.

A CLAUDE.md file is a markdown file that Claude reads when it starts. Think of it as a briefing document for your AI pair programmer.

your-project/
├── CLAUDE.md ← Claude reads this first
├── src/
├── tests/
└── ...

Without CLAUDE.md, Claude has to guess:

  • What commands to run
  • What coding style to follow
  • What patterns you use
  • What to avoid touching

With CLAUDE.md, Claude knows your project from the start.

Create a CLAUDE.md in your project root:

# Project: My Awesome App
## Overview
A Flask web application for managing user subscriptions.
## Tech Stack
- Python 3.11
- Flask 2.x
- SQLAlchemy + PostgreSQL
- Pytest for testing
- Redis for caching
## Key Commands
- `make dev` - Start development server
- `make test` - Run tests
- `make lint` - Run linters
## Project Structure
- `app/` - Main application code
- `app/models/` - SQLAlchemy models
- `app/routes/` - API endpoints
- `tests/` - Test suite
## Coding Conventions
- Use type hints everywhere
- Docstrings in Google style
- Max line length: 100 characters

That’s it! Claude now understands:

  • What your project does
  • How to run things
  • Where code lives
  • What style to follow

Focus on information Claude can’t easily discover:

SectionWhyExample
OverviewWhat the project does”Backend API for user subscriptions”
Tech StackTools and frameworks”Python 3.11, Flask, PostgreSQL”
Key CommandsHow to run thingsmake test - Run tests”
Project StructureWhere code livesapp/models/ - Database models”
SectionWhyExample
Coding ConventionsStyle preferences”Use type hints everywhere”
Critical RulesThings to never do”Never modify core/auth.py without review”
Known IssuesCurrent problems”Rate limiting fails under load (#234)“
# MyProject
Python Flask API for task management.
Tech: Python 3.11, Flask, PostgreSQL, Redis
Commands:
- `make dev` - Start server
- `make test` - Run tests
Structure:
- `api/` - API routes
- `models/` - Database models
- `services/` - Business logic
# MyProject
Python Flask API for task management.
Tech: Python 3.11, Flask 2.x, PostgreSQL 15, Redis
Commands:
- `make dev` - Start dev server (port 5000)
- `make test` - Run pytest
- `make lint` - Run ruff + mypy
Structure:
- `api/routes/` - API endpoints
- `api/models/` - SQLAlchemy models
- `api/services/` - Business logic (keep routes thin)
- `tests/` - Tests mirror api/ structure
Conventions:
- Type hints required
- Google-style docstrings
- Routes are thin, logic in services/
Rules:
- Always use transactions for multi-step DB ops
- All API errors: {"error": "msg", "code": "ERROR_CODE"}

When Claude starts:

  1. ✓ Reads CLAUDE.md from project root
  2. ✓ Incorporates it into context
  3. ✓ Uses it to inform all responses

Claude will:

  • Follow your coding conventions
  • Use your preferred commands
  • Understand your architecture
  • Respect your rules and constraints
# Good: Actionable and specific
## Commands
- `npm run dev` - Start dev server on :3000
- `npm test` - Run Jest tests
## Rules
- Never commit .env files
- All prices stored as integers (cents)
# Bad: Too vague or obvious
## Commands
- Run the appropriate development commands
## Rules
- Write good code
- Don't make mistakes

CLAUDE.md is always in Claude’s context. Every word counts:

Too long: 5-page document with project history, team bios, every config option Just right: 1-2 pages with essential project context Too short: “Python project. Figure it out.”

After creating CLAUDE.md, verify it helps:

Terminal window
# Test 1: Does Claude use your commands?
claude
> run the tests
# Should use the command from CLAUDE.md
# Test 2: Does Claude follow your conventions?
> add a new function
# Should follow naming/style from CLAUDE.md
# Test 3: Does Claude understand structure?
> where is the user authentication code?
# Should correctly identify files based on CLAUDE.md structure

Update when:

  • ✓ Architecture changes
  • ✓ New conventions adopted
  • ✓ Commands change
  • ✓ Critical rules added

Don’t update for:

  • ✗ Minor implementation details
  • ✗ Temporary experimental code
  • ✗ Every small change

Now that you understand the basics, explore advanced CLAUDE.md patterns: