Tutorials / Claude Code: AI-Assisted Coding from First Prompt to Daily Workflow / CLAUDE.md: teaching the tool about your project

CLAUDE.md: teaching the tool about your project

11 min read text
Course contents (20 lessons)
  1. Meet Claude Code
  2. What Claude Code is and how it differs from a chat window
  3. Installing Claude Code and signing in
  4. Your first session: explore, ask, change
  5. Asking well and staying in control
  6. Asking for changes: context, goal, constraints and acceptance criteria
  7. Reading and approving edits
  8. Permission modes: how much freedom to give
  9. Project memory and slash commands
  10. CLAUDE.md: teaching the tool about your project
  11. Slash commands and custom commands
  12. Everyday coding workflows
  13. The plan-first workflow
  14. Understanding unfamiliar code
  15. Debugging with Claude Code
  16. Refactoring safely
  17. Writing tests with Claude Code
  18. Git, small changes, cost and security
  19. Git workflows: branches, commits and pull request descriptions
  20. Keeping changes small and reviewable
  21. Context and cost awareness
  22. Security habits: secrets, commands and untrusted input
  23. Extending the tool, teamwork and a final project
  24. Hooks and MCP servers explained
  25. Team practices for AI-assisted coding
  26. 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.md in 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

IncludeLeave out
Commands to build, test, lint and runA long description of the whole architecture
Where things live, in a few linesThings that are obvious from the file names
Code style rules that a linter does not enforceRules that the linter already enforces
Things that are easy to get wrong in this projectGeneric advice such as "write clean code"
Workflow rules: branch names, commit styleSecrets, 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