docs(agents): route AGENTS.md detail into lazily-loaded modules

✂️ What does this MR do?

The root AGENTS.md is loaded into every agent session, and most of it applied only to specific tasks (508 lines when this MR opened; 1,316 on main today). This MR slims it to 225 lines — the always-on rules plus a Context Routing table — and moves each detail to the module that owns its topic, so the text loads when the task needs it instead of always. Two editorial passes then reshaped the moved prose: a review-requested conciseness pass (a guideline states what is true today on main — the rule, one checkable example, what breaks without it; incident narration, second examples, measurements, and references to ongoing or future work removed), and a scope pass that sends every rule to the doc that owns its domain instead of one catch-all file.

🗂️ Where the content went

Content Home
Prose-writing rules: comment discipline, doc claims, documented absences, tracking issues, spec/plan authoring, fact sweeps, multi-step plan ownership, secret lifetimes, precedents, adjacent gates, guard reasons, steady-state claims docs/dev/writing-discipline.md (new; 428 lines, 18 sections)
Failure-log field rules and log-volume sampling docs/dev/logging.md
Metric-absence tests, nothing-emits catalog rows, cardinality-pin seeding, observation-multiplicity assertions docs/dev/observability.md
The response-write-deadline re-arm census docs/dev/remote-read-budgets.md (merged into its existing section)
The exported-sentinel error-table row rule docs/dev/storage.md, beside the table it governs
Mirrored-suite rules, integration-tagged lint discipline, test-only security-relaxation rule, documented-distinction-owes-a-test docs/dev/go-testing.md
Status-table single-writer rule, step-MR marker, merge-order rule, issue-search commands, docs(plans): prefix docs/dev/conventions.md
Module-cache resolution and LabKit as the one library-shaped reference implementation docs/dev/go-libraries.md
Type and Seam Conventions and the database doc index internal/AGENTS.md (new)

🧹 The editorial passes

  • Conciseness: each rule keeps its statement, one checkable example (exact symbols and values), and the consequence of breaking it. writing-discipline.md sections went from 20–60 lines each to 8–25.
  • Scope: nine instrumentation rules that arrived as writing-discipline essays moved to their domain docs (table above), trimmed on arrival and deduplicated against what those docs already said.
  • Merges: seven single-trap sections folded into their parents (claim-time → tracking-issue; ask-to-a-DRI → multi-step ownership; second-clause, compile-time-safety, and second-discriminator → docs-make-claims; catch-all-arm → adjacent-gates; arm-keyed-on-presence → guard's reason).
  • Deduplications: the no-process-coordinates rule now lives only in go-style.md's ### Reference only what does not rot (writing-discipline points to it); the defensive-branch rule only in the multi-step ownership section; three guardrail bodies that duplicated fuller conventions.md text kept the fuller copy.

📏 Invariants kept

  • Guardrails keep their count, order, and numbering — ordinals are cited by number elsewhere (plans, skills). Condensed items keep their opening rule and point at the exact heading now carrying the full text.
  • Every heading a root pointer names was verified to exist verbatim in its module.
  • Content moved verbatim first, then was trimmed and relocated in separate commits — the move and the cuts are separately reviewable in the history.
  • Content main added to the root during review (the essay sections, the Go 1.27 ReadFrom behavior change) was routed into the same structure on each rebase.
  • The AGENTS.md#reference-implementations anchor links in docs/dev/agentic-development.md still resolve; that section and its table stay in the root.
  • markdownlint: 0 issues; vale: 0 errors across all changed files.

🌱 Nested AGENTS.md pattern

internal/AGENTS.md carries the directory-scoped rules and gets an internal/CLAUDE.md twin holding only an @AGENTS.md import: Claude Code loads it on first read under internal/, and agents that read nested AGENTS.md natively pick up the same file. The root's Maintaining These Instructions section records the pattern for future nested files.

📏 Change size

+838/−1226 across 20 files. Splitting would not help: the root's deletions are only reviewable against the module additions that absorb them, so every split boundary would separate a move from its destination. By file group:

Group +
Root AGENTS.md 112 1,201
New modules (docs/dev/writing-discipline.md, internal/AGENTS.md + CLAUDE.md twin) 481 0
Existing docs/dev/ modules absorbing routed content 231 17
Skills (mr-watch, review-branch, implement-step) — pointer retargets only 13 9
One Go test-file comment retarget 1 1

📡 Follow-through

The chore(skills): commits retarget the mr-watch remember: flow at the routed modules (so captured conventions land in the module the Context Routing table names instead of regrowing the root), and point review-branch's lens loading and implement-step's lint citation at the modules. These ride this MR rather than a dedicated skills MR because they are consequences of the pointer moves above — no skill behavior changes, so the benchmark requirement does not apply.

Known gap, accepted: merged plan files cite section names (for example "Secret-Lifetime Claims Name Where the Value Is Materialized") against AGENTS.md. Plans are write-once history; the routing table puts a reader one hop from the moved text.

💰 Tokens savings

Before this MR:

Screenshot_2026-09-10_at_11.04.44

After this MR:

Screenshot_2026-09-10_at_11.10.33

The savings are for every session opened on this project from any member.

Edited by David Fernandez

Merge request reports

Loading
Loading