Home / Guides / CLAUDE.md template for Claude Code
CLAUDE.md examples and a template for Claude Code
Short answer: Commit a short CLAUDE.md at your repo root (or .claude/CLAUDE.md) with your stack, the exact dev, test and lint commands, the 5 to 10 hard rules that must never break, and a plan-first workflow. Keep it under 200 lines. Personal preferences go in ~/.claude/CLAUDE.md, private notes in a gitignored CLAUDE.local.md, and @path imports keep the main file short. Run /init for a first draft. Already have AGENTS.md? Make CLAUDE.md an @AGENTS.md line plus Claude-only notes. Five examples and the free template are below.
Claude Code reads CLAUDE.md from your repo root at the start of every session. A good one is short, specific and boring. A bad one is a 600-line wish list the agent skims and ignores.
What belongs in CLAUDE.md
- Project facts: stack, package manager, where things live.
- Exact commands: how to dev, test, lint and typecheck. Agents guess these wrong constantly.
- Hard rules: the 5 to 10 things that must never happen (disable RLS, commit secrets, edit generated files).
- Workflow: plan first, small diffs, run the tests before saying "done".
CLAUDE.md examples
Claude Code loads several memory files, and each has a different job. These examples follow Anthropic's memory docs (checked October 21, 2026), which suggest keeping each CLAUDE.md under 200 lines and writing concrete, checkable instructions. Run /init to generate a starting file and /context to see which files loaded.
Example 1: project CLAUDE.md (commit it)
Lives at ./CLAUDE.md or ./.claude/CLAUDE.md and is shared with your team.
# Acme web app ## Commands - Install: pnpm install - Dev: pnpm dev - Test: pnpm test (run before committing) - Lint: pnpm lint ## Code style - TypeScript strict. No `any`. - Use 2-space indentation. - Server code in src/server/, never import it from src/components/. ## Rules - Never edit .env files or commit secrets. - Ask before adding a dependency. - Plan first for changes touching more than 3 files.
Example 2: user CLAUDE.md for all your projects
~/.claude/CLAUDE.md holds personal preferences that apply everywhere.
# My preferences - Explain the plan in 3 bullets before editing. - Prefer small commits with conventional commit messages. - Do not run git push. I push myself.
Example 3: CLAUDE.local.md for just you
./CLAUDE.local.md is for project notes you don't share. Add it to .gitignore.
- My local API runs on http://localhost:8787 - Test account: use the seed user from scripts/seed.ts
Example 4: imports keep the file short
Pull other files in with @path. Paths are relative to the file containing the import, and imports can nest up to four hops.
See @README.md for the project overview and @package.json for scripts. # Git workflow @docs/git-instructions.md
Example 5: path-scoped rules in .claude/rules/
Markdown files in .claude/rules/ with paths: frontmatter load only when Claude works on matching files.
---
paths:
- "src/api/**/*.ts"
---
# API rules
- Validate every request body with zod.
- Return errors as { error: string } with a proper status code.CLAUDE.md is context, not enforcement: Claude can still skip a line. For a rule that must hold every time, such as never editing .env, use a hook. See Claude Code hooks examples.
Share rules with Cursor and Codex
Keep the shared rules in AGENTS.md and make CLAUDE.md import it with a single @AGENTS.md line, then add only Claude-specific notes below. One source of truth, every tool.
Free template: copy it
@AGENTS.md # Claude Code notes - Stack: <<FILL: e.g. Next.js 15 App Router, Supabase, Stripe, pnpm>> - Commands: pnpm dev | pnpm test | pnpm lint | pnpm typecheck - Before editing: write a short plan and wait for "go" on anything touching auth, payments or migrations. - Keep diffs small. Never edit generated files (lib/database.types.ts) by hand. - Never print, log or commit secrets. Never disable RLS or tests to make something pass. - "Done" means: tests and typecheck pass, and you list what you changed.
For a ready-made safety section, grab the free agent-guardrails.md from our GitHub repo and paste it into AGENTS.md.
Want the whole drawer?
The Claude Code Kit ($24) goes past CLAUDE.md: 6 least-privilege subagents, 10 slash commands, a settings.json with permissions and hook wiring, and 4 tested hooks. The Vibe Starter Rules Pack ($19) adds a full AGENTS.md + CLAUDE.md pair, 8 scoped rules and launch checklists for Next.js + Supabase + Stripe.
Just want the one file? One-File Agent Rules ($9) is one universal AGENTS.md for any stack: import it from CLAUDE.md with @AGENTS.md. Or download the free Starter AGENTS.md (no email needed).
14-day refund, no questions.