Where CLAUDE.md lives
| File | Purpose |
|---|---|
./CLAUDE.md at the repo root | project rules shared by the team, committed to git |
| CLAUDE.md in a subfolder | rules for a specific module, picked up when the agent works there |
~/.claude/CLAUDE.md | your personal rules for every project |
The /memory command opens memory files for editing.
What to write
- Commands: how to install dependencies, run tests, the linter, the build.
- Structure: where the backend, frontend, migrations and tests are.
- Style: rules your linter doesn’t enforce: naming, error handling, testing approach.
- Don’ts: don’t touch generated files, don’t change the public API unless asked.
- Process: branch and commit naming, what to check before finishing a task.
Example
# Project: online shop on Laravel + Vue ## Commands - Tests: php artisan test - Frontend: npm run dev, build npm run build - Linter: ./vendor/bin/pint ## Structure - app/Services — business logic, thin controllers - resources/js — Vue components ## Rules - Store money in cents (int), never float - New endpoints only with a Feature test - Don't edit files in database/migrations, create new migrations ## Before finishing a task - Run tests and pint, fix errors
Common mistakes
- Too long. CLAUDE.md takes context space in every session. Keep it short and specific.
- Generic phrases. "Write clean code" changes nothing. "Functions under 40 lines, early return" does.
- Stale commands. If the test command changed but CLAUDE.md didn’t, the agent wastes steps on errors.
- Secrets in the file. CLAUDE.md is committed to git. No passwords or keys.
CLAUDE.md and skills
CLAUDE.md is always loaded. Instructions for rare tasks (release, database migration, report) are better as a skill that loads only when needed. More in lesson 7 and in the article "CLAUDE.md in Claude Code".
Today's task
Open the CLAUDE.md that /init created. Add test commands, three style rules, two don’ts and a checklist for finishing a task.