write-the-claude-md
Skill1 starsChanged 5 months agoApache-2.0View on GitHub
Use when an agent keeps relearning the codebase from a blank page every session and getting it confidently wrong. Reach for it when a founder says "write my CLAUDE.md", "the agent forgot how our system works again", "it reinvents the structure every time", "set up the master file", "do I need AGENTS.md and a Cursor rules file too", "keep memory across sessions", "it broke a rule nobody told it", or starts a repo and wants every session to begin where the last one stopped. Produces a populated master file (and its AGENTS.md / GEMINI.md / Cursor mirrors) holding the system inventory, principles, constraints, and decisions, plus a one-line session-end update ritual. Run during architect-before-code, before agentic-build-loop.
In this repository27 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/ai-native-os.mdcCursor rule
- agentic-build-loopSkill
- ai-assisted-salesSkill
- apply-ai-native-modelsSkill
- architect-before-codeSkill
- capture-learningSkill
- cognitive-architecture-reviewSkill
- compliance-readinessSkill
- customer-discovery-that-doesnt-lieSkill
- design-a-loopSkill
- design-the-mvaSkill
- eval-and-safety-harnessSkill
- frame-the-hypothesisSkill
- gateway-agent-opsSkill
- geo-contentSkill
- hypothesis-miningSkill
- map-the-terrainSkill
- measure-ai-native-pmfSkill
- moat-strategySkill
- pay-down-agentic-debtSkill
- red-team-the-agentSkill
- secure-the-connectorsSkill
- self-healing-fallbacksSkill
- share-of-model-auditSkill
- start-hereSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
Write the content once. Mirror the mirrors so they never disagree.
- Distinctive: line 69
Do not dump everything. The file is the standing context, not a changelog.
- Distinctive: line 70
Treat a model bump or prompt edit as load-bearing (CACE): if it changes behaviour, it earns a line in Decisions, not a silent commit.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Write the CLAUDE.md
A clever prompt dies the instant the context window clears. The agent forgets, reconstructs a theory of your system from whatever it can see, and builds against that improvised theory, slightly differently every session, until one repository houses three half-systems that almost agree. The master file is the cure. It is the memory the model does not have: the one document read at the top of every session so the work starts where you left it, not from a guess. Write it before the first feature, not after the first regression.
The method
Author one master file, mirror it to every platform, and keep it alive with a session-end ritual.
Full anatomy, worked before-and-after, and anti-patterns: references/master-file-anatomy.md.
Step 1: Write the seven sections, and nothing else
The file earns its keep by being short and current. Include the standing context an agent would otherwise guess; exclude anything that lives better in code or goes stale by Friday.
| Section | What it holds | Keep out |
| What this is | One paragraph: the product and its one closed loop. | Marketing copy. |
| System inventory | The four pillars named: Brain, Memory, Planning, Tools. | API keys, secrets. |
| Principles | The non-negotiable rules of this codebase. | Generic best practice the model already knows. |
| Constraints | The limits a newcomer would break by accident. | Anything enforced by a linter or test. |
| Decisions | Dated trade-offs made and why, newest first. | Decisions already reversed; prune them. |
| Glossary pointers | Links to the domain terms, not the definitions. | Full definitions that drift from source. |
| Update ritual | The one-line rule for keeping this file alive. | A changelog of every commit. |
Step 2: Mirror it across every platform you use
The same source serves four runtimes. A rule in only one file is a rule the other three agents break.
| Platform | File it reads |
| Claude Code | CLAUDE.md |
| Codex | AGENTS.md |
| Cursor | .cursor/rules/<name>.mdc |
| Gemini CLI | GEMINI.md |
Write the content once. Mirror the mirrors so they never disagree; a contradiction between them is worse than no file, because each agent obeys a different one.
Step 3: Install the session-end update ritual
At the end of every working session, add exactly one line naming the trade-off you just made. Not a diff, not a diary. One decision, dated. This is the discipline that keeps the file true; without it, the file rots into a confident, stale lie that misleads every session after.
Output
- A populated master file (
CLAUDE.md) with the seven sections filled for the founder's repo. - The platform mirrors (
AGENTS.md,GEMINI.md,.cursor/rules/<name>.mdc) carrying the same content. - A documented session-end update ritual: one dated line per session, naming the trade-off made.
- Next: run
agentic-build-loopto generate against the master file, never a blank page.
Constraints
- A stale file is worse than none. Forbid shipping the file without the update ritual that keeps it true.
- Do not dump everything. The file is the standing context, not a changelog; anything a linter or test enforces does not belong here.
- Treat a model bump or prompt edit as load-bearing (CACE): if it changes behaviour, it earns a line in Decisions, not a silent commit.
- Stay theme-agnostic; the founder supplies the domain, you supply the structure.
Dictionary
context window · CACE
Copy-paste version
For non-coders: paste into any chatbot or no-code builder (Claude.ai, ChatGPT, Lovable, Bolt, v0).
Act as my lead systems engineer. Write the master memory file for my repo so every AI session starts
where the last one stopped instead of reinventing my codebase.
My product: [ONE_LINER]. Domain: [DOMAIN]. My closed loop: [INTELLIGENCE_LOOP].
Draft a CLAUDE.md with exactly these seven sections, short and current:
1. What this is: the product and its one closed loop, one paragraph.
2. System inventory: name the four pillars (Brain, Memory, Planning, Tools) for my product.
3. Principles: the non-negotiable rules of this codebase.
4. Constraints: the limits a newcomer would break by accident, including [CONSTRAINT] and [GUARDRAIL].
5. Decisions: dated trade-offs, newest first (seed it with today's).
6. Glossary pointers: the domain terms to link, not define.
7. Update ritual: the one-line rule for keeping this file alive.
Then produce the same content as mirrors named AGENTS.md, GEMINI.md, and .cursor/rules/project.mdc,
so Codex, Gemini, and Cursor obey the same rules. Keep them identical.
CONSTRAINTS: do not dump a changelog or anything a linter enforces; keep it the standing context only.
Treat any model or prompt change that alters behaviour as a Decisions entry, not a silent edit.
OUTPUT: the filled CLAUDE.md, the three mirrors, and a one-line session-end ritual I run every time.Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

