workflowContext Engineering2 min read
CLAUDE.md That Actually Works
Stop re-explaining your project to every new agent session.
A CLAUDE.md file is permanent context your agent reads at the start of every session. Done right, it eliminates repetitive setup, prevents the most common mistakes, and keeps every agent consistent with your team's standards.
The Problem
Every new Claude Code session starts cold. Without persistent context, you spend the first few minutes re-explaining your stack, your test runner, your branch conventions, and your anti-patterns. Then you correct the same avoidable mistakes again and again — in every session.
What to Include
CLAUDE.md isn't a tutorial. It's a cheat sheet for an engineer who already knows how to code. Include only what the agent can't infer from reading the code itself:
- Run commands: how to start the dev server, run tests, type-check
- Stack conventions: ES modules vs CommonJS, import aliases, preferred patterns
- Branch and PR rules: naming conventions, when to open a PR vs direct commit
- Known gotchas: required env vars, ports, quirks in your monorepo setup
- Anti-patterns: "never use X, use Y instead" — this is the highest-ROI line you can write
What to Cut
If Claude already follows a convention without being told, cut it. Bloated files cause the agent to skim — and the important rules get lost in the noise.
- Don't explain standard conventions the model already knows
- Don't paste in API docs — link to them
- Don't write "follow best practices" or "write clean code" — these are noise
- If removing a line wouldn't cause a mistake, remove it
Start with /init
Claude Code's /init command generates a starter CLAUDE.md by analyzing your project structure. Use it as a base, then trim aggressively. The goal is the shortest file that still prevents real mistakes.
Example
# Stack- React Router v7, TypeScript, Tailwind CSS- Node >= 24.0.0# Commands- `npm run dev` — start dev server on :3000- `npm run typecheck` — type check only, no build- `npm run test` — Vitest unit tests# Conventions- ES module imports only (no require)- Use ~/ alias for app/, never relative paths- Form submissions go to Notion via app/models/Lead.server.ts# Anti-patterns- Never use React.FC — plain function components with typed props- Never commit .env — use .env.example instead- Never use any — fix the type or use unknownOne Thing to Know Before It Grows
Project-root CLAUDE.md is one of the few things re-injected from disk after a session compacts, which is exactly why load-bearing rules belong here rather than in chat or behind path-scoped frontmatter. It is also a fixed cost paid on every turn of every session, so target under 200 lines and move anything longer into a skill or a scoped rule. The Context Budget covers the tradeoff and how to measure your own.
More in Context Engineering
- 4 min readAGENTS.md — One File, Every AgentThe open standard that makes your project context portable across Claude Code, Cursor, Codex, Copilot, and 20+ other agents. Write it once, every agent reads it.Read
- 5 min readWriting Your Own SkillsThis hub is full of skills other people wrote. The compounding win is writing your own. A skill is how you encode your team's process once and have every agent follow it the same way.Read
- 1 min readExplore → Plan → ImplementSeparate research from implementation so you stop solving the wrong problem.Read
