Write a CLAUDE.md File – CLAUDE.md prompt: project rules file for Claude Code
Free with your account
- Free with an account
- Copy filled in or download
- Updates included
Claude Opus 5.5
This prompt writes the CLAUDE.md file Claude Code reads at the start of every session. Add your stack, commands and the mistakes AI keeps making; you get a short file with rules and reasons.
What you get
- A CLAUDE.md under 80 lines with commands, layout, rules, workflow and gotchas
- Each repeated mistake turned into a rule with its reason
- Placeholders where a command or path is missing, instead of a guess
- A list of what each placeholder needs
How to use it
- 1List your commands and mistakes
Write down the commands you run and every mistake the AI has made more than once, in your own words.
- 2Fill the gaps and save
Fill every placeholder, then save the file as CLAUDE.md at the root of your repository and commit it.
- 3Update it when a mistake repeats
When Claude repeats a mistake, add one rule with its reason, and delete rules for problems that no longer happen.
Better results
- Write mistakes as they happened, such as "it edits migrations that already ran"; specific mistakes become specific rules.
- Keep it short. If the file grows past about 80 lines, move rarely needed detail into a separate doc and say where it is.
- For Codex or other agents that read AGENTS.md, save the same text under that name too.
Questions
What should a CLAUDE.md file include?
A CLAUDE.md file should include the commands to run, test and build the project, where key things live, the project's rules with their reasons and the mistakes to avoid. Leave out general coding advice and anything Claude can read in the code itself.
How long should CLAUDE.md be?
Keep CLAUDE.md short, roughly under 80 lines for most projects. It loads into every session, so each line costs attention, and a long file buries the rules that matter. Move rarely needed detail into separate docs and say where they are.
Does CLAUDE.md work with Codex or Cursor?
Codex reads AGENTS.md rather than CLAUDE.md, and Cursor reads its own rules files and AGENTS.md. The file this prompt writes is plain Markdown, so you can save the same text as AGENTS.md for those tools.
How do I prompt Claude Code effectively?
Prompt Claude Code with one clear task, what must keep working and how to check the result, and let it read the code and plan before editing. Keep stable facts such as commands and rules in CLAUDE.md, so you do not repeat them in every prompt.
Updated 6 Oct 2026
























