Claude Code project setup
3 CLAUDE.md examples and a starter template
Choose a CLAUDE.md example for a TypeScript web app, a Python package or a monorepo. Save it as CLAUDE.md at the root of your repository. Replace the sample paths and test instructions with the ones your team uses. Keep the rules a teammate needs on their first change.
Last updated · Published
By CWYN · Published
1. Copy the starter template
# [Project name]
## Project summary
[What does this repo produce, and who uses it?]
## Commands
Run from [working directory].
- Build with `[build command]`.
- Run tests with `[test command]`.
- Lint with `[lint command]`.
## Conventions
- Follow [reference file] when adding [kind of change].
## Hard rules
- Ask [owner] before [action that needs approval].
## Gotchas
- [Common mistake]. Use [correct command or path] because [reason].
## Where things live
- `[path]` holds [source files].
- `[path]` holds [tests or fixtures].
For the part about how you work, use the CLAUDE.md generator and paste your working preferences below the project rules.
2. Three filled-in CLAUDE.md examples
CWYN wrote these examples for three fictional repositories. Each block is the full text of a root CLAUDE.md.
Checked against docs, not run. Anthropic’s guide to CLAUDE.md files and imports (as of ).
Node/TypeScript web app
# Market hours
This Node app shows which neighborhood markets are open now.
## Layout
- Edit weekly schedules in `src/markets.json`.
- Keep the opening-hours calculation in `src/hours.ts`.
## Time rules
- Interpret hours in each market's local time zone.
- A closing time earlier than opening falls on the following day.
## Tests
- Run `npm test` from the repository root.
- In `test/hours.test.ts`, cover a Friday market open from 22:00 to 02:00.
- It should be open at 01:59 on Saturday and closed at 02:00.
Use Layout to locate the schedule and the function that reads it. Under Time rules, spell out which day a closing time belongs to. Under Tests, give the command and the two times that catch a closing-time error.
Python package
# Rainfall reader
This Python package reads station CSV files for rainfall reports.
## Public API
- Keep `read_station_csv` importable from `rainfall/__init__.py`.
- Put parsing logic in `rainfall/reader.py`.
## Missing readings
- Return `None` for a blank rainfall field.
- Return `0.0` for a measured zero. Values are in millimeters.
## Regression tests
- Store small station files in `tests/fixtures/`.
- In `tests/test_reader.py`, read a CSV with one blank and one zero.
- Assert that the two readings survive the public API as distinct values.
The Public API section names the import that downstream reports rely on. Use Missing readings to record a distinction the CSV header cannot explain. The Regression tests check that callers can still tell a missing observation from a dry day.
Monorepo with two apps and a shared package
# Trail reports
Field crews record trail conditions offline. Editors review them on the web.
## Workspace map
- `apps/field/` writes reports and `apps/web/` reads them.
- Both apps use the parser in `packages/report/`.
## Shared format
@docs/report-format.md
- Add new fields to the shared parser before using them in either app.
## Compatibility check
- Keep a report saved by the previous field app in `packages/report/fixtures/`.
- After a format change, verify the web app can still open that report.
Workspace map shows who writes and reads a report. Shared format imports the field definitions from a path relative to this CLAUDE.md. Point it to an existing file in your repo. Compatibility check protects crews whose saved reports still use the older format.
3. Where the file goes
| Who uses it | File and use |
|---|---|
| The project team | Commit ./CLAUDE.md or ./.claude/CLAUDE.md to share the project’s commands and conventions. |
| You, in this project | Use ./CLAUDE.local.md for personal project notes. Add it to .gitignore. For parallel sessions, see how to copy an ignored file into a worktree. |
| You, across projects | Use ~/.claude/CLAUDE.md for instructions you want in every project. |
| The organization | Use the managed policy location for your operating system. Anthropic lists the OS-specific paths in the reference below. |
At the start of every session, Claude reads instruction files in the working directory and its ancestors. Files in subdirectories load on demand. Claude joins the discovered files together, so it sees both versions of a rule if a parent and child file disagree.
Anthropic’s CLAUDE.md locations and loading rules (as of ).
4. What not to put in it
- A multi-step procedure. Put the release checklist in a project skill. A shared skill lives at
.claude/skills/<name>/SKILL.md. Anthropic’s guide to skills (as of ). - A rule for just one directory. Put a convention that only applies to the docs tree in a path-scoped rule under
.claude/rules/. - A restriction that must always hold. CLAUDE.md gives Claude context. To block a tool action regardless of what Claude decides, use a
PreToolUsehook. Check that your hook fires.
Anthropic’s guidance on rules, skills and enforcement (as of ).
5. What repeated instructions cost on the API
CWYN’s Code review preset budgets 500 system tokens per turn. Suppose your project instructions use that many tokens and you send them on each of the 2 turns. Price that block at the regular API input rate for Claude Sonnet 4.6.
500 tokens × 2 turns = 1,000 input tokens.
1,000 × $3 ÷ 1,000,000 = $0.003. Anthropic API pricing (as of ).
What changes the number?
- Instruction length. Replace the preset allowance with the tokens in your own instructions. A line can hold one word or a paragraph.
- Turns. Count how many requests actually include the block.
- Billing category. Use your model’s rate for regular input, cache reads or cache writes according to your usage record.
For a whole session, include the other input and the reply in the AI cost calculator.
6. CLAUDE.md FAQ
How long should CLAUDE.md be?
Aim for fewer than 200 lines per file. Longer files take up more context and make instructions harder to follow. An @path/to/import can organize the text, but the imported content still uses context. Imports can go up to four hops deep.
Can Claude Code generate a starting file?
Run /init in the project. It generates a starting CLAUDE.md. If the file already exists, it suggests improvements and leaves the original in place.
Can I use my repository’s AGENTS.md?
Yes. To include an existing AGENTS.md in the same directory, put @AGENTS.md on its own line in your CLAUDE.md. See the AGENTS.md examples for a root file and a package override. If your team maintains both files, AI Instruction Builder Pro generates them from the same questionnaire.
When should I add a rule?
Add a rule when Claude makes the same mistake twice, when you find yourself repeating a correction, or when a reviewer catches something Claude should have known.
Anthropic’s CLAUDE.md reference (as of ).