CLAUDE.md generator
Answer a few questions about your project and get a focused CLAUDE.md — commands, conventions, and rules Claude Code actually follows — ready to commit.
Which file?
./CLAUDE.md — shared with your team through Git. Commit it at the repo root. Claude Code loads it at the start of every session in this project.
Format
One short paragraph: what this is, who uses it, and the one thing that makes it unusual.
Only what Claude can't see at a glance — versions and choices that matter.
The exact commands Claude can't guess. A single-test command saves the most time.
Rules that differ from the language defaults. Concrete enough to verify.
The runner, where tests live, and what "done" requires.
Paste `tree -L 2` output or a list of paths. Noise (node_modules, build output, lockfiles) is dropped — keep only key dirs.
Branching, commits, PRs, and what to run before calling a task done.
Positive rules. Mark at most one or two as important.
Things Claude should never do in this repo.
Non-obvious behavior that bit someone before: env quirks, ports, flaky bits.
<!-- Loaded into Claude Code's context every session — keep it under ~200 lines. Made with host0.ai/tools/claude-md-generator. HTML comments like this one are stripped before Claude sees the file. --> # acme-dashboard A Next.js App Router project in TypeScript. Server components by default; the UI is Tailwind. ## Tech stack - Next.js (App Router) + React, TypeScript strict - Tailwind CSS for styling - Vitest + Testing Library for tests ## Commands - `npm run dev` — Dev server (localhost:3000) - `npm run build` — Production build - `npm run lint` — Lint - `npx tsc --noEmit` — Typecheck - `npx vitest run` — All tests - `npx vitest run src/lib/foo.test.ts` — Single test file ## Code style - Server components by default; add "use client" only for state, effects, or browser APIs - Import from `@/…` (maps to `src/`), never long relative paths - Data fetching happens in server components or route handlers, not in client effects - No `any` — use `unknown` and narrow it ## Testing - Tests sit next to the code as `*.test.ts(x)` - Run the single file you changed before the whole suite ## Repo map ```text src/ ├── app/ # routes, layouts, route handlers ├── components/ # shared ui └── lib/ # server + shared logic public/ tests/ # e2e ``` ## Workflow - IMPORTANT: Run lint, typecheck, and tests before saying a task is done - Don't commit or push unless asked ## Do - Ask when a requirement is ambiguous instead of guessing - Make the smallest change that solves the task ## Don't - Don't add a dependency without asking - Don't disable lint rules or skip tests to make a check pass ## Gotchas - Env vars exposed to the browser must start with `NEXT_PUBLIC_` - `npm run build` catches errors the dev server doesn't — run it before calling a change done
Save it to ./CLAUDE.md. On macOS, after copying:
pbpaste > CLAUDE.mdOverwrites an existing file. Then run /context in Claude Code and look for it under memory files.
Length: concise — the docs target under 200 lines per file; shorter files get followed more reliably.
No issues found — specific, concise, and structured.
How to use this CLAUDE.md generator
- Pick the file. Project (
./CLAUDE.md), local (./CLAUDE.local.md), or user (~/.claude/CLAUDE.md) — the header, hints, and save path follow your choice. - Pick a stack preset. Next.js, React + Vite, Django, FastAPI, Rails, Go, Rust, a Node API, or a pnpm monorepo pre-fill real commands (dev, build, lint, typecheck, and a single-test command) plus conventions. Edit anything.
- Shape the sections. Toggle, rename, and reorder them; add, remove, and reorder rules; mark the one rule Claude keeps skipping as important; paste
treeoutput and the repo map drops node_modules, build output, and lockfiles. - Watch the meter. The output updates live with a length meter against the ~200-line target and lint hints for vague rules, over-used emphasis, duplicates, contradictions, and secrets.
- Ship it. Copy it, download it as CLAUDE.md, or save it as AGENTS.md for other coding agents. Already have one? Switch to "Improve an existing one", paste it, and get the same lint report with line numbers — then load it into the builder to rework it.
What is a CLAUDE.md file?
Every Claude Code session starts with a fresh context window. A CLAUDE.md file is how you carry knowledge across sessions: a Markdown file of instructions that Claude reads at the start of every conversation — the commands, conventions, and rules you'd otherwise re-explain each time. The official docs put it simply: treat CLAUDE.md as the place you write down what you'd otherwise re-explain.
Add to it when Claude makes the same mistake a second time, when a code review catches something Claude should have known about the codebase, or when you type the same correction you typed last session. Keep it to facts Claude needs in every session; a multi-step procedure belongs in a skill, and a rule that only applies to part of the codebase belongs in a path-scoped rule under .claude/rules/.
One thing a CLAUDE.md is not: enforcement. Its content arrives as context (a user message after the system prompt), so Claude follows it well but not with a guarantee. Anything that must happen every time — formatting after each edit, blocking writes to a folder — belongs in a hook or in permission settings.
Claude Code memory: where CLAUDE.md files live
CLAUDE.md files can live in four places. Claude Code loads them from broadest to most specific, so a project instruction appears in context after a user instruction:
| Scope | Location | For |
|---|---|---|
| Managed policy | /Library/Application Support/ClaudeCode/CLAUDE.md (macOS), /etc/claude-code/CLAUDE.md (Linux, WSL), C:\Program Files\ClaudeCode\CLAUDE.md (Windows) | Organization-wide rules deployed by IT; can't be excluded |
| User | ~/.claude/CLAUDE.md | Your preferences, every project |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | Team-shared through git |
| Local | ./CLAUDE.local.md | Your notes for this project; gitignored |
CLAUDE.local.md: personal notes for one project
CLAUDE.local.md sits next to the project CLAUDE.md and holds what's yours alone — your sandbox URLs, preferred test data, local quirks. It loads alongside the project file (after it, at the same level), so add it to .gitignore. Because a gitignored file only exists in the worktree where you created it, people who juggle several git worktrees can import a file from their home directory instead.
How CLAUDE.md files load
- Claude Code loads
CLAUDE.mdandCLAUDE.local.mdfrom the directory you launch it in and every directory above it. Launch infoo/bar/and bothfoo/CLAUDE.mdandfoo/bar/CLAUDE.mdload. - Files are concatenated, not overridden: root first, your working directory last, and within a directory
CLAUDE.local.mdcomes afterCLAUDE.md. If two files contradict each other, Claude may pick either — keep them consistent. - CLAUDE.md files in subdirectories load on demand, when Claude reads files in that subdirectory — ideal for per-package rules in a monorepo. The
claudeMdExcludessetting skips files from other teams. - Block-level HTML comments (
<!-- like this -->) are stripped before the file reaches Claude, so notes for human maintainers cost no context. - The project-root CLAUDE.md survives
/compact: Claude re-reads it from disk afterwards. Run/contextto see which memory files loaded, and/memoryto open and edit them.
What to put in a CLAUDE.md file
The docs' rule of thumb: include what Claude can't infer from the code, and leave out what it can.
Include
- Bash commands Claude can't guess — dev, build, lint, a single test
- Code style rules that differ from the defaults
- Testing instructions and the preferred test runner
- Repo etiquette: branch naming, commit and PR conventions
- Architectural decisions specific to this project
- Environment quirks, like required env vars
- Gotchas and non-obvious behavior
Leave out
- Anything Claude can figure out by reading the code
- Standard language conventions it already knows
- Detailed API docs — link to them instead
- Information that changes frequently
- Long explanations and tutorials
- File-by-file descriptions of the codebase
- Self-evident advice like "write clean code"
A complete CLAUDE.md example
About 45 lines for a real Next.js app — every line is something Claude would otherwise get wrong. Load a preset above to start from something similar.
# acme-dashboard Internal dashboard for the support team: Next.js App Router + Postgres (Drizzle). Server components by default. ## Commands - `pnpm dev` — dev server on localhost:3000 - `pnpm test` — all tests (Vitest) - `pnpm vitest run src/lib/billing.test.ts` — one file; prefer this while iterating - `pnpm lint && pnpm typecheck` — must pass before a task is done - `pnpm db:migrate` — apply Drizzle migrations ## Code style - TypeScript strict; no `any` — use `unknown` and narrow - Server components by default; "use client" only for state or browser APIs - Import from `@/…`, never `../../..` - Money is integer cents everywhere; format only in the UI ## Testing - Tests sit next to the code as `*.test.ts` - Every bug fix gets a regression test ## Repo map ```text src/ ├── app/ # routes ├── components/ # shared ui ├── db/ # drizzle schema + migrations └── lib/ # server logic ``` ## Workflow - IMPORTANT: never commit directly to `main`; branch as `feat/…` / `fix/…` - Don't commit or push unless asked ## Gotchas - `.env.local` isn't committed — copy `.env.example` - The billing webhook test needs `STRIPE_WEBHOOK_SECRET` set; it's skipped otherwise ## References - Architecture decisions: @docs/architecture.md
CLAUDE.md best practices
- Keep it under 200 lines. It loads into context every session, and bloated files make Claude ignore the rules that matter. For each line, ask: would removing this cause Claude to make mistakes?
- Be specific enough to verify. "Use 2-space indentation" beats "format code properly"; "run
npm testbefore committing" beats "test your changes"; "API handlers live insrc/api/handlers/" beats "keep files organized". - Use headings and bullets. Claude scans structure the way a reader does; grouped bullets are easier to follow than dense paragraphs.
- Emphasize sparingly. If Claude keeps skipping one instruction, add IMPORTANT to that line alone. Emphasize many lines and none of them stands out.
- Remove contradictions. Review the root file, nested files, and
.claude/rules/together; conflicting rules get resolved arbitrarily. - Treat it like code. Commit it so the team can contribute, review it when Claude misbehaves, and prune it regularly. If Claude asks questions the file already answers, the phrasing is ambiguous.
- Start with /init. It analyzes your codebase and writes a starter file (or suggests improvements to an existing one). Refine it with what Claude couldn't discover on its own.
CLAUDE.md imports: the @path syntax
A CLAUDE.md can pull in other files with @path/to/file — for example see @README.md for the overview or a bullet like - git workflow: @docs/git-instructions.md. The rules, per the docs:
- Relative paths resolve from the file that contains the import, not the working directory; absolute and
~/paths work too. - Imported files can import others, up to four hops deep.
- Imports inside code spans and fenced code blocks are ignored, so wrapping a path in backticks keeps it literal.
- The first time a project imports a file outside the repo, Claude Code asks you to approve it.
- Imports help organization but don't save context — imported files load at launch with the file that references them. To load instructions only when relevant, use path-scoped rules or skills.
- A neat use:
@~/.claude/my-project-instructions.mdin a project file shares personal notes across git worktrees, where a gitignored CLAUDE.local.md would only exist in one.
Claude Code auto memory vs CLAUDE.md
Claude Code has a second, complementary kind of persistent memory. Auto memory is written by Claude itself as it works — your preferences, corrections you give it, project context it can't derive from the code — and stored per repository in ~/.claude/projects/<project>/memory/. A MEMORY.md index there loads each session (its first 200 lines or 25KB), and topic files are read on demand.
- CLAUDE.md: you write it, it holds instructions and rules, and it can be shared with your team through git.
- Auto memory: Claude writes it, it holds learnings and patterns, and it stays on your machine (shared across worktrees of the same repo).
- Asking Claude to "remember" something saves it to auto memory; to put it in CLAUDE.md, say "add this to CLAUDE.md" or edit the file via
/memory. - Auto memory is on by default. Toggle it in
/memory, per project withautoMemoryEnabled, or withCLAUDE_CODE_DISABLE_AUTO_MEMORY=1.
CLAUDE.md vs AGENTS.md
AGENTS.md is the shared instruction file many coding agents read. Current Claude Code (v2.1.277 and later) reads it too — but by default only when your project has no CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in the working directory or above. When both exist, Claude reads the CLAUDE.md files only, unless you set project instructions in /config to read both.
The portable setup the docs recommend: keep the shared rules in AGENTS.md and add a tiny CLAUDE.md that imports it, with Claude-specific notes below the import. This generator can save either file — pick AGENTS.md as the format, and it shows the two-line bridge file to copy.
# CLAUDE.md @AGENTS.md ## Claude Code - Use plan mode for changes under src/billing/
A symlink (ln -s AGENTS.md CLAUDE.md) also works if you don't need Claude-specific content, but git checks symlinks out as plain text files on Windows unless symlinks are enabled — prefer the import if anyone on the team uses Windows. Claude doesn't read AGENTS.local.md, AGENTS.override.md, or anything under .agents/.
CLAUDE.md examples, including the Karpathy CLAUDE.md
Plenty of developers publish their CLAUDE.md files on GitHub, and reading a few is a good way to calibrate. The most famous is the "Karpathy CLAUDE.md" — a short community file by developer Forrest Chang, distilled from Andrej Karpathy's public observations on how LLM coding agents fail. Karpathy didn't write it himself, and it's behavioral guidance (simplicity first, surgical changes, goal-driven execution) rather than facts about a project.
That distinction matters when you copy one. General behavior rules fit your user-level ~/.claude/CLAUDE.md, where they apply everywhere; the project file should stay about this repo — its commands, its conventions, its gotchas. A borrowed rule set never replaces the single-test command only your project has.
Common CLAUDE.md mistakes
- The novel. Hundreds of lines of architecture essays. The rule that matters gets lost, and the docs'
/doctorcheck will propose cutting what Claude can derive from the code. - The platitudes. "Write good code", "follow best practices", "be careful". Claude already tries; say what good means here.
- The directory dump. A full
treelisting. Claude can explore the tree itself — name only the dirs that aren't obvious. - Everything is IMPORTANT. When every rule shouts, none stands out.
- Conflicting rules. "Use npm" in one place,
pnpm installin another. Claude picks one arbitrarily. - Secrets in the file. CLAUDE.md is plain text and usually committed. Reference env var names, never values.
- Relying on it for guarantees. Instructions shape behavior; hooks and permissions enforce it.
Frequently asked questions
What is a CLAUDE.md file?
A CLAUDE.md file is a plain Markdown file that Claude Code reads at the start of every session. It gives Claude persistent context it can't infer from the code alone: build and test commands, code style rules, project layout, workflow conventions, and gotchas. You write it; Claude reads it. It's context, not enforced configuration — to block an action no matter what, use a hook or permission settings instead.
Where do I put the CLAUDE.md file?
For a project, put it at the repo root as ./CLAUDE.md (or ./.claude/CLAUDE.md) and commit it so your team shares it. Personal preferences for every project go in ~/.claude/CLAUDE.md. Personal notes for one project go in ./CLAUDE.local.md, which you add to .gitignore. Organizations can also deploy a managed policy CLAUDE.md that applies to every user on a machine.
What should a CLAUDE.md file contain?
What Claude would otherwise get wrong: bash commands it can't guess (especially a single-test command), code style rules that differ from the defaults, testing instructions, repository etiquette like branch naming, project-specific architectural decisions, environment quirks such as required env vars, and non-obvious gotchas. Leave out anything Claude can learn by reading the code, standard language conventions, long tutorials, file-by-file descriptions, and self-evident advice like "write clean code".
How long should a CLAUDE.md be?
The official docs target under 200 lines per CLAUDE.md. Every line loads into context at the start of every session, and longer files reduce adherence. For each line, ask whether removing it would cause Claude to make a mistake — if not, cut it. Move instructions that only matter for some files into .claude/rules/ with paths frontmatter so they load only when needed.
What are CLAUDE.md best practices?
Be specific enough to verify ("use 2-space indentation", not "format code properly"), keep it concise, group rules under Markdown headings with bullet points, avoid contradictions between files, and use emphasis like IMPORTANT on the one rule Claude keeps skipping — not on many lines. Commit it to git, start from /init, and prune it like code when Claude's behavior drifts.
Is CLAUDE.local.md still supported?
Yes. The current Claude Code memory docs list ./CLAUDE.local.md as the place for personal, project-specific preferences such as your sandbox URLs or preferred test data. It loads alongside CLAUDE.md and is appended after it at the same directory level. Add it to .gitignore so it isn't committed. Note that a gitignored file only exists in the worktree where you created it.
How does Claude Code memory work?
Claude Code has two memory systems, both loaded at the start of every conversation: CLAUDE.md files, which you write, and auto memory, which Claude writes itself from your corrections and preferences. CLAUDE.md files are loaded from your working directory and every directory above it at launch, concatenated rather than overriding each other; CLAUDE.md files in subdirectories load on demand when Claude reads files there.
What is Claude Code auto memory?
Auto memory is persistent memory that Claude writes for itself: notes about you, feedback you've given, ongoing project context, and references. It lives in ~/.claude/projects/<project>/memory/ with a MEMORY.md index, and the first 200 lines or 25KB of that index load every session. It's on by default; toggle it in /memory or with the autoMemoryEnabled setting. It's machine-local and not shared through git — team rules still belong in CLAUDE.md.
Does Claude Code read AGENTS.md?
Yes, in current versions (v2.1.277 and later). By default Claude reads AGENTS.md only when there's no CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in your working directory or above it; when both exist it reads your CLAUDE.md files only. You can change that with the project instructions setting in /config, or keep one shared file by putting @AGENTS.md at the top of a small CLAUDE.md.
How do I import other files into CLAUDE.md?
Write @path/to/file anywhere in the file, e.g. @README.md or @docs/architecture.md. Relative paths resolve from the file containing the import, absolute and ~/ paths work too, and imported files can import others up to four hops deep. Paths inside backticks or code blocks are not imported. Imports organize the file but don't save context: imported files still load at launch.
Can I have CLAUDE.md files in subdirectories?
Yes. CLAUDE.md files in directories above where you launch Claude Code load at startup; CLAUDE.md files in subdirectories load when Claude reads files in those subdirectories. That makes a nested CLAUDE.md the natural place for package-specific rules in a monorepo. If other teams' files get in the way, the claudeMdExcludes setting skips them.
Should I use /init or a CLAUDE.md generator?
Both work well together. /init has Claude analyze your codebase and write a starter CLAUDE.md with the commands and conventions it discovers (or suggest improvements if one exists). A generator like this one is faster for the things Claude can't discover on its own — your team's workflow rules, do's and don'ts, and gotchas — and lints the result for length and vague rules. Run /init, then paste its output into "Improve an existing one" to tighten it.
What is the Karpathy CLAUDE.md?
It's a widely shared community CLAUDE.md written by developer Forrest Chang, distilled from Andrej Karpathy's public observations about how LLM coding agents go wrong. Despite the name, Karpathy didn't write it. It's a short set of behavioral guidelines rather than project facts, so it complements a project CLAUDE.md instead of replacing one — if you use it, it fits best in your user-level ~/.claude/CLAUDE.md.
Is this CLAUDE.md generator free, and is my file uploaded?
It's free with no signup, and nothing is uploaded: the builder, the linter, and the preview all run in your browser. Your draft is saved in this browser's local storage so a refresh doesn't lose it.
Related free tools
See all free tools →Built something? Put it online in seconds
host0 is the cloud for small software: bring any coding agent, build the tool only you need — like this one — and say "deploy to host0". Live at a shareable URL, no servers to run.