CLAUDE.md: teaching the tool about your project
Course contents (20 lessons)
- Meet Claude Code
- What Claude Code is and how it differs from a chat window
- Installing Claude Code and signing in
- Your first session: explore, ask, change
- Asking well and staying in control
- Asking for changes: context, goal, constraints and acceptance criteria
- Reading and approving edits
- Permission modes: how much freedom to give
- Project memory and slash commands
- CLAUDE.md: teaching the tool about your project
- Slash commands and custom commands
- Everyday coding workflows
- The plan-first workflow
- Understanding unfamiliar code
- Debugging with Claude Code
- Refactoring safely
- Writing tests with Claude Code
- Git, small changes, cost and security
- Git workflows: branches, commits and pull request descriptions
- Keeping changes small and reviewable
- Context and cost awareness
- Security habits: secrets, commands and untrusted input
- Extending the tool, teamwork and a final project
- Hooks and MCP servers explained
- Team practices for AI-assisted coding
- Final project: building a small app step by step
The problem it solves
Every new session starts without memory of your earlier sessions. You would otherwise repeat the same things each time: how to run the tests, which folder holds what, "we use tabs", "never edit the generated files". CLAUDE.md is a plain text file where you write these down once. The tool reads it when it starts a session in the project, so the knowledge is there from the first message.
Where it lives
- A
CLAUDE.mdin the root of your project, which you commit so the whole team shares it. - A personal one in your user configuration folder, for your own preferences across all projects.
- Files in subfolders can hold notes for that part of the code. Check the official documentation for how they are picked up in your version.
Creating one with /init
The /init command asks the tool to look at the project and write a first CLAUDE.md for you. It is a good start, because it finds the build and test commands and the layout. But treat the result as a draft. Read it line by line, remove what is wrong or obvious, and add what only you know.
What belongs in it
| Include | Leave out |
|---|---|
| Commands to build, test, lint and run | A long description of the whole architecture |
| Where things live, in a few lines | Things that are obvious from the file names |
| Code style rules that a linter does not enforce | Rules that the linter already enforces |
| Things that are easy to get wrong in this project | Generic advice such as "write clean code" |
| Workflow rules: branch names, commit style | Secrets, passwords, tokens. Never. |
An example CLAUDE.md
# Project notes for Claude
## What this is
Internal invoicing web app. ASP.NET Core API in /src/Api, React front end in /src/Web.
## Commands
- Build API: dotnet build src/Api
- API tests: dotnet test tests/Api.Tests
- Web tests: npm test --prefix src/Web
- Lint web: npm run lint --prefix src/Web
## Conventions
- API endpoints return ProblemDetails for errors, never plain strings.
- All money values are decimal, in the smallest currency unit in the database.
- Use the existing Button and Modal components, do not add new UI libraries.
## Be careful
- Never edit files under /src/Api/Migrations by hand. Ask me to create migrations.
- The file src/Web/api-client.ts is generated. Change the OpenAPI spec instead.
## Workflow
- Small commits. Imperative commit messages, for example "Add invoice total rounding".
- Run API and web tests before saying a task is done.
Why it works
It is short and specific. Every line changes the behaviour of the tool in a way that matters. "Never edit migrations by hand" prevents a classic accident. The commands mean that the tool can check its own work without guessing.
Keep it short
This is the most important rule. Every line in CLAUDE.md uses part of the tool's working memory in every session. A bloated file crowds out useful context and buries the important rules. If a rule is not worth a line of someone's attention in every session, leave it out. I aim for one screen, perhaps two.
Grow it from real mistakes
The best entries come from things that went wrong. When the tool makes the same mistake twice, for example it keeps using the wrong test command, add one line. Over a few weeks the file becomes a record of how your project really works. When a rule is no longer true, delete it. A wrong note is worse than no note.
Ask the tool to propose updates
We just spent twenty minutes because you did not know the web tests need the API running first. Suggest one or two lines for CLAUDE.md that would have prevented this. Show them to me before editing the file.
I still review the lines, because the tool tends to write too much. Edit them down to the essentials.
Be careful about secrets
The file is committed to your repository. Never write keys, tokens, connection strings with passwords or customer data in it. Write where to find configuration, not the values: "Local settings are in appsettings.Development.json, which is not committed."
It is guidance, not law
The tool usually follows CLAUDE.md, but not perfectly, particularly in long sessions. If a rule matters a lot, such as "never run commands against production", back it up with permissions or hooks, which we cover later, rather than hoping the text is enough.
The common mistake
The common mistake is accepting the first generated file and never touching it again, or the opposite: writing a five-page manual. Neither helps. Short, reviewed and updated is the target.
Try it yourself
Run /init in a project. Read the result and cut it to under 40 lines. Add two lines that only you know. Then start a new session and ask "How do I run the tests here?" to check that the tool picks it up. Commit the file.
This course is free to read. Create a free account to enrol, save your progress and pick up where you left off.
Sign up free I already have an account