01 — Documentation and AI_README
Documentation in a project with an AI assistant has one goal: so the next session (or another agent) understands a directory without reading all of its code. It isn’t an archive for posterity but an onboarding interface, read at the start of every conversation. Below is what stands behind the rules of chapter 01.
Who reads it — and why that decides where a fact goes
Where does a fact go? Ask who reads it ↗
Splitting by reader means every fact is written once, and everything else just links to it:
README.md→ for the person who landed on the Repository (repo) — A store of the whole project’s code together with its full history of changes — who changed what and when. The repo is the project’s memory: code, documentation and change history in one place. more in the glossary →. What the project is, why, how to start. No Maintenance window — A short, planned period when users see a “work in progress” page while the database or configuration changes behind it. It guarantees the app never runs, even briefly, on half-changed data. more in the glossary → details.CLAUDE.md→ for the agent and whoever maintains this repo. How to run, build and test it; which policies apply. One working language — nobody translates their own repo’s constitution.- AI_README — A map file in every code directory: what’s here, what it’s for and what to watch out for — written for search. The assistant finds the right file with one search instead of reading the whole directory. more in the glossary → → for the agent navigating a directory’s content. A map of the files and an Index (database) — A lookup in the database that makes searching instant instead of scanning everything in order. The first move for slow queries — like an index at the back of a book instead of reading 400 pages. more in the glossary → for searching.
A good constitution (CLAUDE.md) opens with a short orientation (layer → technology → place in the repo), gives the exact commands to run things (with interpreter and port, not “start the server”), lists the policies that override default behaviour — the most important: “never Deploy — Releasing a new version of the app “live”, where real people use it. It’s the moment a change reaches real people — which is why it happens only on an explicit “deploy”. more in the glossary → automatically” — and ends with a dated “Current state” section with numbers (how many records, which Migration (database) — A controlled change to the database layout — adding a column, a table or moving data — step by step. Like a renovation to plan: rebuilding data in a set order so nothing “collapses”. more in the glossary → applied). It’s the first thing the agent reads, so it has to be current. Policies are written like law: specific, and with the “why”. Hard domain rules — e.g. privacy from day one — also go here as policy, not as a loose note.
The pointer from the constitution to the maps
CLAUDE.mdpoints to theAI_README.mdmaps ↗
The constitution says “what and where the project is”; an AI_README says “what exactly is in this directory”. The constitution delegates the details to the maps — but only when it says so outright. Without one sentence in CLAUDE.md, a new session has no way of knowing the maps exist, and starts by scanning every file.
The map updated in the same commit
AI_README.mdis updated before the Commit — A saved, labelled point in the project’s history — a confirmation of a specific batch of changes. Small, described commits make a history you can return to any working state from. more in the glossary → ↗
The rhythm goes: code → update the map (ideally with an /update-ai-readme skill) → commit. What belongs in a directory’s map:
- an index of files and modules — each with a one-sentence “what it’s for”;
- the API — An agreed way for two programs to talk to each other — one asks, the other answers in a set format. Through an API your app connects to outside services (payments, maps, AI). Treat an API key like a password. more in the glossary → of key functions (signature + contract), so nobody has to read the implementation;
- traps invisible from the code, e.g. “Facebook doesn’t render WebP — A modern image format, noticeably lighter than JPG or PNG at the same quality. Lighter images mean a faster page — especially on a phone. more in the glossary → as Open Graph (OG) — Tags that decide how a link looks when pasted into Facebook, LinkedIn or a messenger (image, title, description). A good link card means more clicks — a bad one can show what you don’t want (e.g. a price). more in the glossary →” or “this CDN returns 200 and an HTML page on error”;
- numbers — how many records, how many tests.
The map quality test: after reading it, can the agent safely change code in this directory without scanning every file? If not — something is missing. Since version 1.1.1 a test enforces this too (every module listed, a size ceiling) — a ready template is in chapter 17.
An index for searching, not for reading
Write the index for
grep, not for reading. ↗
In a real project the agent doesn’t read everything — for a specific task it searches for a keyword and reads only the file that matched. So an index entry should be dense with the specifics someone will actually look for: function names, concepts, technologies, synonyms and — in a bilingual project — both languages (GDPR — The EU’s data-protection law — how you may collect, keep and delete users’ data. It concerns every app with people’s data. Better to write in consents and retention from the start than pay fines later. more in the glossary →/RODO, migration/migracja, queue/kolejka). grep -i <topic> should hit one line that points to the right file.
Why the effort? Context is a budget. The more precisely the index points, the less of the assistant’s working memory goes on searching and the more is left for the actual work. It’s Commandment II (“search before you write”) applied to reading.
One file, one topic
One file = one topic. ↗
A topic spread over five files is five search hits and burned memory; a topic kept in one file is one hit and one read. The same principle works at the scale of folders: clear boundaries (data / ingest / web / scripts, → 12) and a specific map in each beat one vague file at the repository root. Important information lives close to the code it’s about. The Craft’s core applies this to itself — which is why in 1.1.1 chapter 05 was split into three.
State, not wishes
State, not intent. ↗
The agent acts on what is written, not on what someone intended to do. A map describing wishes instead of the current state sends it to the wrong places. A reference to removed code is worse than no entry — it sends someone looking for something that isn’t there.
docs/ — only what is true now
docs/describes the current version only. ↗
Documentation heavier than a directory map lives in docs/, so neither AI_README nor CLAUDE.md bloats. An example layout:
docs/
AI_README.md # table of contents: “where to start for task X”
architecture.md # layers, boundaries, flows
data_model.md # database schema, diagram, allowed values (→ 11)
deployment_runbook.md # procedure + numbered lessons from incidents (→ 05, 14)
plans/ # open plans, one file = one topic
Git keeps the history: git log on an .md file tells you when and why a rule changed. That’s why the source of truth is a hand-written .md with relative links (clickable and automatically checkable), not generated HTML.
Plans that end
docs/plans/is a living backlog. ↗
A plan is a document, not a thought in someone’s head: problem → options → choice → why. When a plan lands, its decision goes into the document it governs, and the plan file goes away. A folder full of “done” plans is noise — zombies you have to read just to learn they no longer mean anything. The history is in git anyway.
A new folder comes with its map
A new directory is created together with its
AI_README.md↗
A folder without a map is a puzzle folder: the next session has to open every file to understand what’s in it. The same goes for a refactor — split a module into subdirectories, and each new directory gets its map in the same step. A skeleton is enough; “later” never comes.
Generated files and regeneration on request
Generated artifacts (HTML, Snapshot — A saved state of data from a specific moment — e.g. a database copy or a file of computed statistics. It speeds things up and keeps them safe, but is stale from the moment it’s taken — you need to know where fresh data comes from. more in the glossary →) are derivatives: ↗
People read more comfortably in a browser than in raw markdown, so it’s worth having a single-file reader at the repo root (e.g. index.html) that renders the .md files — it works from a double-click and from a server. The Craft pack ships such a reader.
The generated output is committed but never edited by hand — the next regeneration would overwrite it anyway. Regeneration doesn’t fire on every commit (noise, delays, conflicts); it runs on request, ideally via a skill (02). A good regeneration skill doesn’t blindly rebuild everything: it looks at the git history since the last docs update, sees what actually changed, updates the affected sections and prints what it changed. Cheap, deliberate, checkable.