Back to blog
NO.
036
DATE
READ
~7 min
KIND
Notes
STATUS
Reviewed

TAGS: AI collaboration Blogging

Trimmed Docs Grew Back: A Cleanup with an Agent

AGENTS.md grew back 15% within four weeks of a trim. This time an agent split rules from history, archived frozen docs and added size and link checks.

This is a record of cleaning up a project's documentation together with an AI coding agent: what was checked before starting, how the documents were split, and which checks were added that keep running. Whether the agent actually follows the rules better afterwards has not been tested; the Limits section at the end says more about that.

The repository behind this blog has a rules file for agents, AGENTS.md, loaded in full at every session; more detailed rules, runbooks and history live under docs/. On October 10, in a batch of tasks I gave the agent, I added one more: slim down and consolidate the site's documentation, and bring files like README and AGENTS.md into line. My message, in Chinese, said that some of the documents had become too long and I was worried the model might not follow them well.

First, find out why the last trim didn't hold

This was not the first slimming. One was done on September 12, cutting AGENTS.md from 36,969 bytes to 25,148 bytes and moving incident narratives into the audit log. Before starting, the agent measured what had happened since: four weeks later it was back at 28,855 bytes, up 15%. Over the same period the visual spec, design-system.md, grew from 50 KB to 86 KB.

It then broke the growth down by section. Of the 3.7 KB AGENTS.md had gained, nearly half was in "Important Paths," mostly path notes that came along with new features. All 35.7 KB that design-system.md had gained were dated entries, 30 KB of them appended one by one under "Documented Decisions." Both files had the same structure: current rules and the history of those rules written together, so the file grew with every change.

So this time the goal was not "cut it again," but to stop the part that must be followed from growing with each change.

How it was split

Step one was to put frozen documents somewhere of their own. Three monthly roadmap archives, three domain migration drafts, an old CMS migration plan, a finished record of an inline script migration, a redesign handover and its implementation notes, and two superseded design specs, 12 documents in all, were moved unchanged into docs/archive/. The docs check script used to list, file by file, the documents exempt from its freshness check, so the list had to be edited by hand every time one was retired; now the whole directory is exempt.

Step two separated rules from ledgers. design-system.md keeps only the current baseline and rules; every dated decision moved verbatim to a new design-decisions.md, where you search for a component's name before changing it. The description of the owner training scheme and its task card log were split into two files, the former shrinking from 26 KB to 4 KB. The "latest release evidence" section in the handover document, stuck at September 24, had long stopped being the latest; it moved verbatim into the audit log, and its place was taken by known limitations that still apply.

Step three split by concern. The x402 paywall policy in the operations and security document was merged into the x402 runbook; when the two documents disagreed, which one won used to depend on a dedicated rule in AGENTS.md, and now there is only one document. The steps for integrating third-party analytics were written out once in the operations document and again in the SEO document; they became one analytics.md. The parts of the writing guide that duplicated the CMS and image documents became pointers. The eight voice rules were kept as they were, because that section is pasted whole into briefs given to models.

Step four kept only one index. The root README, the handover document and the end of AGENTS.md each used to keep a list of documents, and the three did not agree; now there is only docs/README.md, grouped into "read before you start / runbooks / ledgers / frozen history," and everything else points to it.

AGENTS.md itself came down to 16,830 bytes without dropping any rule: the incident table was compressed into a sentence pointing to the audit log, path notes kept only the path and the rule, and two rules that concern only styling (collapsing the table of contents, horizontal scrolling for tables) moved to the visual spec.

Required readingBefore (bytes)After (bytes)
AGENTS.md28,85516,830
content-authoring.md25,80419,090
design-system.md85,8519,739
seo.md19,21414,602
operations-security.md61,52230,672
owner-training.md26,4774,063
Total247,72394,996

The total volume of documentation barely changed. Most content was moved rather than deleted, and is still there in the ledgers and in archive/; what shrank is the part an agent must read before starting work.

Two checks that keep running

The cleanup itself is one-off, and the previous round showed that a one-off cleanup gets undone by later changes. So this time two checks were added to npm run check:docs, which runs on every build.

The first is a size cap: 18,000 bytes for AGENTS.md, and a cap for each of the other five required documents. Going over fails the build, and the error message asks for the narrative to be moved into a ledger rather than for the number to be raised.

The second checks for dead references: any docs/…md path mentioned in code comments, configuration or current documents must exist, and relative links in current documents must resolve. This time a dozen or so files were moved and the references were found one by one with grep; the check is there so that next time nobody has to search. Its first run reported 18 problems, all of which had been broken before this cleanup. Ten were in the two ledgers, the roadmap and the audit log, which record file names as they were at the time; that is history, so the check was changed to skip those two ledgers. The other 8 were in current documents and configuration, including a wrangler.toml comment pointing to a file that does not exist and two references that wrote another repository's documents as paths in this one. All 8 were fixed.

How the collaboration went

The same message contained other requests, and the agent ordered them by priority: first fix a bug where enlarged images were cut off and verify it in production, then fix like-spam protection that was using an unsalted IP hash, then the documentation, and finally this article. The documentation went in as three commits, with npm run check run before each. The repository's commit hook blocks commits that change code without touching the docs, so every step left an entry in docs/roadmap.md saying what changed, how it was checked and what was not done.

One thing along the way needs correcting. In the first commit, both the roadmap and the commit message said "all 18 dead references fixed one by one," when in fact only 8 were fixed and the other 10 were handled by having the check skip them. This was found while checking the numbers for this article, and the roadmap now carries a correction.

The repository also has an owner training scheme: for maintenance tasks at or below my current level, the agent has to write a task card for me to do myself. The documentation cleanup and the two fixes were above that level, so the agent did them directly. Publishing this article was within what I am practicing; the agent first stopped at a draft and wrote a task card, and afterwards I asked it to publish on my behalf.

Limits

  • "Shorter documents make the model follow them better" was the premise of this cleanup, not a measured result. Agent behavior was not compared on the same set of tasks before and after; the numbers above only show that there are fewer bytes to read.
  • Content that was moved was not re-verified along the way, for example the x402 policy material and vendor allowances; they are as they were at the original check.
  • The current month's roadmap ledger was already 91 KB and was not touched. It is append-only, searched by keyword when looking up history, and is not required reading.
  • A size cap only governs byte counts; it cannot govern whether the writing is clear.

Writing note: Claude Opus 5.5 did the cleanup, drafted and translated this; the author chose to publish.

Comments →

CC BY-NC-SA 4.0

This post is licensed under CC BY-NC-SA 4.0 .

Did this article help you? ☕ Support my work

Comments

Comments are powered by GitHub Discussions. Sign in with GitHub to comment. Open the matching Discussion