Skip to main content

Tech blog14 min read

I wrote a rulebook for my coding agents. Here's where it breaks.

Pere PagesSoftware Engineer
A large rulebook lying open on a desk: the left page is fresh and indigo, the right page is yellowed and torn, and a small robot holds a magnifying glass over the faded page

Every repository I own has the same set of files that tell a coding agent how to work in it. I measured how well that rulebook holds up in my most developed repository, and found it is good at adding knowledge and bad at checking that the knowledge is still true. This post shows the numbers, what is missing, how I plan to fix it, and how I will test that the fix worked.

What the rulebook is

The idea is simple: each kind of knowledge about a project lives in exactly one file, and the agent knows which file to read for which task.

A coding agent starts every session knowing nothing about your project. Whatever it needs to know (how to build, which rules to follow, why things are the way they are) has to be written down somewhere it will read. Many projects now put this in an AGENTS.md file, an open format for giving coding agents project instructions that several coding tools now read[1].

One file is not enough once a project grows, so my repositories follow a small standard. It is part of craft, a Claude Code plugin (an add-on) I maintain, and it is on its second version. These are the files:

  • AGENTS.md: how to work here. The commands, the conventions, and a list of pitfalls.
  • principles.md: the rules every change must follow. Each rule is numbered (P1, P2…) and has a Why (the reason it exists) and a Check (what catches a change that breaks it).
  • architecture.md: how the project is built.
  • Architecture Decision Records (ADRs): one short file per real choice between alternatives, with an index in decisions.md. The format comes from Michael Nygard's 2011 essay[2]. An ADR starts as Proposed and becomes Accepted when the author agrees.
  • security.md: what can be attacked, where the secrets are, and the policy for dependencies.
  • GitHub Issues: the open work. There is no to-do file.

Claude Code reads a file called CLAUDE.md at the start of every session. Mine is only two lines: it pulls in the full text of AGENTS.md and principles.md, so both are loaded into every session[3]. The other files are read only when a task needs them.

This diagram shows where each kind of knowledge goes.

Flowchart

The standard also says where the lesson from a mistake goes. It is a ladder with three steps, and the rule is to use the strongest step that would have prevented the mistake:

  1. A check: a test, a lint rule (an automatic check of the code's style or mistakes) or a script. Nobody has to remember anything.
  2. A rule in principles.md, when only a person can judge it.
  3. A pitfall in AGENTS.md, written as symptom → cause → fix, when it is a trap to recognise.

A lesson that is ignored a second time should move one step up: a pitfall that bites twice becomes a rule, and a broken rule needs a check. I have written before about principles you can actually check. The ladder is that idea, applied to a whole repository.

How I measured it

To see where the standard breaks, I measured it in the repository of this website, which uses the standard more fully than any other repository I own. It has 23 principles, 8 ADRs and close to 10,000 words of knowledge files.

I didn't use any special tooling, only counts that anyone can repeat with grep, wc and git log:

  • how many words load into every session;
  • how many principles have a Check that is only "review";
  • how many ADRs say Proposed although the code has already shipped them;
  • how many dated history notes sit inside the rules;
  • how many file paths named in the docs no longer exist.

The last one is the most mechanical. This is the script, run from the repository root. It lists every path written in backticks in the knowledge files and prints the ones that are missing:

BASH
grep -ohE '`(src|scripts|project-docs)/[^` ]+`' AGENTS.md project-docs/*.md \
| tr -d '`' | sort -u \
| while read -r p; do
[ -e "$p" ] || [ -e "$p.js" ] || echo "missing: $p"
done

Where it stands today

The numbers show one clear weakness: the files are full and well organised, but almost nothing checks that they are still true.

QuestionResult in this repositoryVerdict
How many words load into every session?About 3,700 (AGENTS.md + principles.md)Too many
How many rules are checked only by a person?9 of 23 say only "review"; about 14 depend on it in partMost
Do the ADR statuses match the code?1 ADR says Proposed for a feature that has shippedSlightly out of date
Is old history mixed into the rules?4 dated history notes in principles.mdGrowing
Do the file paths in the docs still exist?0 of 90 are brokenFine, but unchecked

The last row surprised me. I expected paths in the docs to be out of date and none were. That is good, but nothing in the standard made it happen. The files were simply edited carefully, and careful editing is exactly the thing that fails when a project gets busy.

What is missing

All of the gaps come from one pattern. The standard says when to add knowledge, but never whether that knowledge is still true, still needed, or actually enforced. Each gap below is one form of that pattern.

Everything that loads at the start costs every session​

The standard says to read files "by need": a commit message needs AGENTS.md, not the ADRs. But CLAUDE.md pulls principles.md into every session, and most of its 23 rules are about Cascading Style Sheets (CSS) values, cards, images and the navigation bar. When the agent fixes a typo in a blog post, it still reads all 2,650 words. Pulling a file in keeps the files organised, but it doesn't make them smaller: the file loads in full[3].

Rules checked only by a person stay that way​

The ladder says a broken rule should become a check. But nothing makes that move happen. Nine principles have "review" as their only Check, and the standard never asks for a list of them or a plan to replace them. The ladder describes what should happen, not what does.

Decision records fall out of date​

ADR 0004 decided that the search box in the navigation bar opens a dialog. The dialog shipped. architecture.md describes it as working and links to the ADR. The ADR itself still says Proposed. The standard defines carefully how an ADR becomes Accepted, but nothing notices when the code moves ahead without it. A reader can no longer tell whether the decision was agreed, or only built.

Nothing is ever removed​

The standard explains when to add a rule, a pitfall or an ADR. It never says when to remove one. So the files only grow. Some of that growth is the very thing the standard forbids: it bans session logs, yet principles.md now contains notes such as "on 2026-09-22 the local-AI post was rewritten section by section". That is history. The reason for a rule belongs in its Why; the story of how it happened belongs in an ADR or in git.

Text can go out of date without anyone noticing​

A tool I use already checks the diagrams in architecture.md against the real code. Nothing checks the text. architecture.md has 5,000 words and has changed in 25 commits. Today every path in it is correct, but a paragraph that names a deleted file would stay "true" for ever.

Skills hold rules the standard doesn't know about​

The agent's skills (instruction files for one task, such as writing a post) also hold rules. The plain-English rule for this blog is spelled out in a skill's shared file, and the rules for the summary at the top of a post live inside another skill. The diagram of where knowledge goes has no box for skills, so nothing checks whether a skill and principles.md say the same thing.

The six gaps fall into three groups: knowledge that costs too much, knowledge that isn't enforced, and knowledge that may no longer be true.

Flowchart

How to fix it

The fixes follow the same ladder as the lessons: wherever a script can catch the problem, write the script before writing another rule. So the cheapest fixes come first, and they are all checks.

GapFixKind of fix
Decision records fall out of dateReport any ADR that has been Proposed for more than 14 days, or that architecture.md already links to as builtCheck
Text goes out of dateEvery path or name in backticks must exist (the script above, made part of the standard's check)Check
Rules checked only by a personCount them in every check run. Each one needs an issue that proposes a check, or a written reason why no script can do itCheck + rule
Nothing is ever removedA new rule: a Why holds the reason, not the history. Plus a word limit for each file, which a script can countRule + check
Rules hidden in skillsSkills get a place in the diagram of where knowledge goes: a skill may apply a rule but must name its P number, never own itRule + check
Everything loads at the startSplit principles.md into a short core that always loads, and files per area (design, writing, images) that load only for matching changesStructure change

The last fix is different from the others. It changes the layout of the files, which an earlier ADR decided, so it needs a new ADR that replaces the old one. That is the standard working as intended: changing it is itself a decision.

All six fixes together become version 3 of the standard. Each version lists what a repository must do to upgrade, and a script files an upgrade issue in every repository that is behind. So the fixes reach every repository, not only this one.

Where it should end up

A fix without a target can't be tested, so each gap gets a number to reach.

GapTodayTarget
Words loaded into every sessionAbout 3,7001,200 at most
Rules checked only by a person, with no issue and no reason90, and the count falls over time
ADRs Proposed although shipped10
Dated history notes in the rules40, and every file under its word limit
Broken paths in the docs00, but checked by a script instead of by careful editing
Rules that exist only in a skillNot measured yet0

The fifth row matters because it is easy to miss. The goal for broken paths doesn't change, because it is already 0. What changes is why it is 0: today it is careful editing, and after the fix it is a script that fails.

How to test that it worked

There are three tests, one for each kind of fix.

  1. The checks must fail when they should. A check that passes on a healthy repository proves nothing; it might pass on anything. So I'll build a small fake repository with one of each problem: a stale ADR, a missing path, a dated note in a rule, and a rule that exists only in a skill. The new checks must pass on this website's repository (once ADR 0004 is fixed) and fail on the fake one, once for each problem.
  2. The numbers must move. I'll run the same counts as in Where it stands today before and after, on the same repository, and compare them with the targets.
  3. A smaller start must not mean worse work. Loading fewer rules is only a win if the agent still follows them. I'll run the same three tasks in fresh sessions before and after the split: fix a typo in a post, restyle a card, and write a summary for a post. For each run I'll record how many words loaded at the start and whether any rule was broken. If the smaller start leads to broken rules, the split failed, whatever the word count says.

This is the same lesson as in my post on Goodhart's law: a number is only useful together with a test that the thing it stands for got better.

What I haven't solved

Two problems remain open, and neither is solved by a script.

The standard assumes one author. Every approval step says "the user" or "the author": the author accepts an ADR, and the author agrees to a new rule. On my own projects that is me. On a team, it isn't clear who accepts an ADR, or who is allowed to change a principle. The files would work for a team, but the approval steps would not.

Agents write the docs that agents then trust. The agent drafts most of these files, and in a later session an agent reads them as fact. Nothing marks the difference between "a person confirmed this" and "the agent wrote this and nobody objected". The rulebook could slowly fill with plausible text that nobody ever read. I don't have a good answer yet. A marker for "confirmed by a person", like the Accepted status of an ADR, is the obvious start. But a marker that has to be added by hand is one more thing nobody checks.

I have argued before that your repository is now an API (application programming interface) for agents. If that is true, the knowledge files are its documentation, and documentation that is never tested goes wrong in the same way as untested code. The next step is version 3 of the standard, and then a second run of the measurements above.

References

  1. InfoQ, AGENTS.md Emerges as Open Standard for AI Coding Agents (August 2025)
  2. Michael Nygard, Documenting Architecture Decisions — Cognitect blog (2011)
  3. Anthropic, How Claude remembers your project — Claude Code documentation

Found it useful? Pass it on.

XLinkedIn

Spotted a mistake? Suggest an edit on GitHub