Every new Claude Code session starts "from scratch": the assistant does not remember what you did yesterday or what your rules are. That is what the CLAUDE.md file is for: a plain text file with rules that Claude Code reads by itself at the start of every session. Here is what ours looks like and what we learned while writing it.
1. Where it lives and how to make one
- In the project folder:
/path/to/project/CLAUDE.md. It applies when you runclaudein that folder. - For all projects:
~/.claude/CLAUDE.md. Put things like "always answer me in English" here. - The
/initcommand in Claude Code looks at the project and creates a starting CLAUDE.md that you then extend.
2. The skeleton we use
This is a shortened, anonymised version of our CLAUDE.md for the project that runs our VPS services. Copy it and adapt it to your own:Code: Select all
# My project — rules for Claude Code
## Project
Working directory: /home/user/my-project
You are continuing an existing project. Do not start it over
and do not replace the existing architecture.
## Roles and names
- Admin 1 = the main administrator (has the final say).
- Admin 2 = the operator (called "Admin 3" in older code).
Do not mix up the roles and IDs.
## Language
Talk to me in English only.
Technical names, commands and identifiers stay unchanged.
## Workflow
1. Read only the docs and code needed for the current task.
2. Check the actual state before making changes.
3. Work on one explicitly assigned task only.
4. Back up the affected files before changes.
5. Before database changes, also make a verified DB dump.
6. Keep the existing security restrictions.
7. Make the minimum necessary changes.
8. Run the tests without touching production data.
9. Update the handoff document.
10. Give a short report and stop.
## Not allowed
- Do not start the next task without permission.
- Do not launch new products or services publicly.
- Do not take real actions on virtual machines without explicit permission.
- Do not change the production database, servers or billing without explicit permission.
- Do not run destructive operations without explicit permission.
- Do not change other projects.
- Do not show passwords, tokens, keys or the contents of a DB dump.
- Do not browse backups/ or browser profiles without a specific need.
- Do not treat the docs as proof if the code shows otherwise.
- Do not use --dangerously-skip-permissions.3. Why these rules
- "One task, then stop" is the most useful rule. Without it, the assistant "helps" and starts the next thing that seems logical to it. With it, every change goes through you.
- "Check the actual state" and "do not treat the docs as proof". Documents go stale. The code and the server show the truth.
- Backup and a verified DB dump. "Verified" means someone tested that the copy restores, not just that the file exists.
- Roles and names. If the same thing has two names in your project (for us "Admin 2" in the docs and "Admin 3" in the database), write it down explicitly. Otherwise the assistant will mix them up sooner or later.
- --dangerously-skip-permissions turns off every permission prompt. It is convenient, but then nothing protects you from a wrong command.
4. The mistake we made: CLAUDE.md as a diary
Our file started with 50 lines of rules. Then we began adding a "current state" section under them after every task. It grew to 169 lines and almost 40 KB, most of it history.Why that is a problem: CLAUDE.md is loaded in every session. A long file eats into your usage limit on every start, and the important rules get lost among dozens of lines about past tasks.
What we recommend:
- Keep only rules and a short pointer in CLAUDE.md: "The current state is in docs/handoff-YYYYMMDD.md".
- Keep the history in separate handoff documents, one per working session.
- Review CLAUDE.md once a month and remove what is out of date.
5. Rules help, but they are not a guarantee
CLAUDE.md is an instruction, not a lock. The assistant follows it very well, but it can still make a mistake, especially in a long session. So we also protect the important things technically: a separate user with few rights, secret files readable only by root, and a permission prompt before risky commands. More on that: Safety rules when an AI works on your server.How to install Claude Code on a VPS: Claude Code on your own VPS: installation in 5 minutes. Share your own CLAUDE.md (without the secrets) in this topic and we will give feedback.