The onboarding briefing file every AI agent reads before writing a single line of code — your project's rules of the house, stack, and guardrails in one concise document.
Read time8 min
LevelBeginner
SectionBuilding Blocks
01 — what it is
Your AI's Day-One Briefing Document
Imagine hiring a senior freelance developer. You would not say "build an ordering feature" and walk away — you would give them an onboarding brief. CLAUDE.md is exactly that brief, written for an AI agent.
CLAUDE.md (also used as AI.md or instructions.md depending on the tool) is a markdown file that lives in the root of your repository. Every time Claude Code starts a session, it reads this file first. No prompting needed — the agent arrives already oriented to your stack, folder layout, and team conventions.
Without it, Claude guesses. It might invent paths that do not exist, reach for an outdated library, or write a module in a folder that breaks your architecture. With it, those mistakes never happen because the rules are baked in from session zero.
The /init command in Claude Code auto-generates a starter CLAUDE.md based on your existing project structure. Run it on any existing project, then edit the output to fit your team's conventions.
02 — why it matters
Four Problems It Solves
CLAUDE.md is not documentation for documentation's sake — it directly reduces cost, improves consistency, and speeds up onboarding for both humans and AI agents.
✓
Token Efficiency
Instead of copy-pasting guidelines into every prompt, the AI reads one file once per session. Context window used for actual work, not re-explaining your stack.
✓
Architectural Consistency
The AI writes code that looks like your team's code — correct framework, naming conventions, and folder structure every time.
✓
Eliminates Hallucinations
A guardrail that anchors the AI to your actual tech stack. It cannot invent a path or reach for a deprecated library if the file says otherwise.
✓
Seamless Handovers
New developer or new AI tool? One file. Understands project governance in under two minutes. No tribal knowledge required.
03 — the five sections
Anatomy of a Well-Formed CLAUDE.md
A production-grade CLAUDE.md contains exactly five sections, in this order. Each section serves a specific purpose — skip one and the AI fills the gap with assumptions.
1. Project Description, State & Meta Context — One paragraph: what the project is, its current development stage, and the context the AI needs to orient itself. For TiffinConnect this was "a NestJS marketplace backend for tiffin subscriptions, pre-launch, MongoDB on port 27018."
2. Tech Stack Table — A two-column table mapping each layer (runtime, framework, database, testing, linting, deployment) to the exact technology. The AI uses this to avoid inventing dependencies.
3. Architectural Blueprints & Path Aliases — The folder structure diagram and alias map. Backend shows module layout; frontend shows component and feature layout. Forbid relative path crawling (../../common); mandate clean aliases (@common/*).
4. Strict Response Contracts — How the AI must behave: output format, verbosity level, what to do when a requirement is ambiguous.
5. Mandatory Rules (The Guardrails) — The non-negotiable list. Short, numbered, no exceptions: never touch modules outside the current task, run lint before marking anything done, update docs whenever a schema changes.
Guardrails are the highest-priority rules in the file. The AI reads them every session and treats them as constraints, not suggestions.
04 — tiffinconnect example
The TiffinConnect CLAUDE.md in Practice
Here is the minimal gist template used as a starting point for the TiffinConnect NestJS backend. Fill in the bracketed placeholders before the first session.
markdown
# TiffinConnect Backend
## Project
NestJS marketplace API for tiffin subscriptions. Pre-launch.
MongoDB on port 27018 via Docker Compose.
## Stack
| Layer | Technology |
|------------|-------------------------------|
| Framework | NestJS |
| Language | TypeScript (strict) |
| Database | MongoDB (port 27018) |
| Testing | Jest |
| Linting | ESLint + Prettier |
## Commands
- Dev: npm run start:dev
- Test: npm run test
- Lint: npm run lint
## Structure
src/
users/
users.module.ts
users.controller.ts
users.service.ts
users.service.spec.ts ← test lives next to code
orders/
common/
## Path Aliases
@common/* → src/common/
@users/* → src/users/
## Rules
1. Never touch files outside the current task scope.
2. Run npm run lint before marking any task complete.
3. Update docs/db-schema.md whenever a collection changes.
4. Read the relevant skill file before starting work.
5. Forbid relative paths — use @aliases only.
✓
Keep it brief and scannable
Use markdown tables and lists. AI reads structures beautifully — dense prose is slower to parse and more likely to be skipped.
✗
Don't explain the business idea
The AI does not need a marketing pitch. "Subscription marketplace API" is enough. Save the vision deck for investors.
✓
Update it dynamically
New global error handler? Updated library version? New folder convention? Update CLAUDE.md immediately — stale rules are worse than no rules.
✗
Don't duplicate your codebase
Never paste massive code snippets into the file. Show structural patterns — folder layout, naming convention — not full implementations.
05 — references
Further Reading
Resource
URL
Claude Code Documentation (Anthropic) — Best Practices for CLAUDE.md