CLAUDE.md and Project Configuration

The single highest-leverage setup step for Claude Code is a good CLAUDE.md — the file where you write down, once, the context and conventions you'd otherwise repeat every session.

Claude Code is a capable collaborator that doesn’t share your context (post 1). CLAUDE.md is how you give it that context durably. Instead of re-explaining your build commands, conventions, and gotchas in every conversation, you write them down once and Claude Code loads them automatically. Getting this file right is the difference between an agent that constantly guesses your conventions and one that follows them from the first message. This post is about CLAUDE.md and the configuration around it.

What CLAUDE.md is

CLAUDE.md is a Markdown file that Claude Code reads automatically at the start of a session and treats as standing instructions for working in that project. Think of it as the onboarding doc you’d hand a new engineer — except it’s read every time, so it’s always applied. It typically lives at your repo root and is checked into version control so the whole team benefits.

There’s a small hierarchy worth knowing:

They layer, so project rules cover the repo while personal preferences follow you everywhere.

What to put in it

The best CLAUDE.md is specific and useful, not a wall of generic advice. High-value contents:

The gotcha: a CLAUDE.md stuffed with generic best-practices (“write clean code,” “add tests”) wastes context and teaches the model nothing it doesn’t know — every line competes for attention. Keep it specific to this project: the commands, the conventions, the gotchas that are actually true here.

Keep it tight and current

CLAUDE.md is loaded into context every session, so it has a real cost — bloat dilutes everything else. Treat it like code you maintain:

Configuration beyond CLAUDE.md

CLAUDE.md handles context and conventions; separate configuration handles behavior and permissions:

The principle: make the good setup shareable and version-controlled. A well-configured repo means every teammate’s Claude Code starts with the same context, conventions, and guardrails.

The gotcha: putting secrets or machine-specific paths in a committed config or CLAUDE.md leaks them to the whole team and to anyone who clones the repo — keep those in local (uncommitted) settings or environment, and commit only what’s genuinely shared.

A realistic CLAUDE.md, annotated

Here’s the shape of a useful project CLAUDE.md — specific, not generic:

# Project: payments-api (Go)

## Build & test
- `make test` — full suite; `go test ./path -run TestName` for one test
- `make lint` — golangci-lint; CI fails on any lint error
- Run locally: `make run` (needs Postgres via `docker compose up db`)

## Layout
- `cmd/` entrypoints · `internal/` private pkgs · `internal/ledger/` the core

## Conventions
- Money is integer minor units + currency code — NEVER floats
- Errors: wrap with `fmt.Errorf("...: %w", err)`; no naked returns
- New endpoints: add a table-driven test and an authz check

## Do not
- Don't edit `internal/pb/` (generated protobuf)
- Don't add dependencies without asking
- Never commit to main; branch first

Every line earns its place: the commands let the agent verify its own work, the money rule prevents a whole class of bug, and the “do not” list heads off the mistakes a newcomer (human or agent) actually makes. Notice what’s absent — no “write clean code,” no “follow best practices.” Those cost context and teach nothing.

The gotcha: the money-units and generated-code rules above are exactly the kind of thing the model can’t infer from the code alone in one glance — it might see a float64 elsewhere and follow it, or “helpfully” regenerate a file you hand-edited. The highest-value CLAUDE.md lines are the project-specific invariants and traps, not the universal advice.

The payoff

The upfront investment in CLAUDE.md and config compounds. Every session starts with the agent already knowing how to build and test, which conventions to follow, and what not to touch — so you spend your specification effort (post 2) on the task, not on re-explaining the project. On a team, it means consistent agent behavior across everyone who works in the repo. It’s the closest thing Claude Code has to a “set it up once” lever, and it’s worth doing early.

Key takeaways

Further reading