CLAUDE.md: format, examples, and best practices

A CLAUDE.md file sits in your repository root and is read by Claude Code at the start of every session. It's the difference between an agent that guesses your commands and conventions, and one that knows them. This guide covers what to put in it, what to leave out, and the mistakes that make agents worse.

What CLAUDE.md is for

Claude Code loads CLAUDE.md automatically as standing instructions. It's the right place for exactly three kinds of content:

A complete example

# CLAUDE.md

## Project

**acme-api** — internal billing API.
Stack: Python, FastAPI, uv, pytest, Ruff.

## Commands

- Install dependencies: `uv sync`
- Run dev server: `uv run uvicorn app.main:app --reload`
- Run all tests: `uv run pytest`
- Run a single test: `uv run pytest tests/test_billing.py::test_proration`
- Lint: `uv run ruff check .`
- Format: `uv run ruff format .`

## Conventions

- Request/response shapes are Pydantic models; set `response_model` on routes.
- DB access through the repository layer in `app/repos/` — routes never
  touch the session directly.
- Async routes must not call blocking IO; use async clients or
  `run_in_threadpool`.

## Gotchas

- A sync call inside an `async def` route blocks the event loop —
  this is our most common performance regression.
- Alembic autogenerate misses column renames; always read the
  generated migration before applying.

Best practices

CLAUDE.md vs AGENTS.md

AGENTS.md is the open, tool-agnostic equivalent — the same substance, read by many coding agents. Claude Code reads AGENTS.md as well when CLAUDE.md is absent; teams commonly commit both (or make one a symlink of the other) so every agent in the toolchain gets the same instructions. Our generator emits both from one detection pass.

Skip the blank page. Paste your package.json or pyproject.toml and get both files tailored to your stack — free, in your browser. Generate mine →