docs: restructure AGENTS.md and CONTEXT.md for progressive disclosure - #1402
Conversation
Size Report
Startup median (7 runs, lower is better):
Top changed chunks: no changes in the largest emitted chunks. |
|
Two required follow-ups before readiness:
|
|
Thanks — (2) is done. On (1) I think the current text is correct; evidence below. 2. Selector-owning sentinel — fixed in 2930be9You were right that this was a live hole, and the failure mode was worse than "inert docs": a matrix edit would have been silently classified docs-only while the selector kept deriving gates from a spec that had changed underneath it. Moved the sentinel to Ordering was worth confirming — Verified behaviorally, not just via the unit test:
The updated test is revert-sensitive: drop the model change and
One consequence to confirm: you said "transfer", so I moved it rather than covering both — 1.
|
Apply the Claude 5 context-engineering guidance to the repo's agent docs:
keep the always-loaded file to gotchas and invariants, and move situational
guidance one hop away behind a routing table.
AGENTS.md 315 -> 229 lines. Cut generic agent-behavior boilerplate, three-way
duplication (Common Mistakes restated Hard Rules; Finding Source Owners
restated the registry section), and facts visible from the repo itself.
Kept verbatim: the expensive-lessons principles, enforcement gates, Hard
Rules, and environment traps.
Split out docs/agents/{cli-flags,pull-requests,device-verification}.md and
folded the Testing Matrix into docs/agents/testing.md, reframed around
pnpm check:affected so the prose stops duplicating the selector.
CONTEXT.md keeps all 50 terms, now grouped under a section index so a task
loads one section instead of the whole glossary.
… Matrix The Testing Matrix moved from AGENTS.md to docs/agents/testing.md, but the affected-check selector still treated only AGENTS.md as selector-owning. A later matrix edit would have been classified as inert docs and skipped the fail-open, so the selector could keep deriving gates from a spec that had changed underneath it. Move the sentinel with the prose, as a named SELECTOR_OWNING_DOCS set so the next move is one line, and fix the two in-code comments plus the testing.md paragraph that still pointed at the AGENTS.md matrix.
2930be9 to
c63aaae
Compare
|
Re-reviewed exact head |
Review caught two repo-specific rules that did not survive the move. Both are prose without any backticked identifier, so the identifier-diff used to verify the split could not see them. - "Test through public interfaces; do not add unrelated production exports solely to enable tests" returns next to the behavioral-tests rule in docs/agents/testing.md, with the reason it exists. - The guidance-ownership rule (decide whether new guidance/schema/metadata belongs to the command surface, CLI grammar, CLI help, MCP projection, or daemon runtime) returns to the always-loaded Docs & skills section, since it governs all command-surface work and not just the flag case. Also point the ADR routing row at docs/adr/README.md, which is already the "read when you touch…" index, rather than at the bare directory.
|
All three points addressed in 15f2a9c, plus the PR body rewritten. Both dropped rules were real, and the way they escaped is worth recording. My completeness check for the split diffed backtick-identifier sets old vs new — which is why it caught the
Rather than fix only what was spotted, I re-ran the completeness check at the prose level — every one of the 200 original PR body rewritten. It no longer claims docs-only, the selector fix moved from Follow-up into Summary with its failure mode described, and Validation now covers On CI: 24/24 green on the pre-restoration head ( On the follow-up eval — I think that's the most valuable idea raised in this review, and I agree it shouldn't block. The honest limit of this PR is that it proves content survived, not that the routing hop gets followed. Worth noting the hop is genuinely cheaper here than for CLI help topics: |
|
* origin/main: docs(adr): rules-first ADR restructure + ADR 0017 proposal (unified event journal) (#1399) feat: add first-class Vega VVD TV support (#1396) fix(replay): preserve cwd scope for opened sessions (#1401) docs: restructure AGENTS.md and CONTEXT.md for progressive disclosure (#1402) fix(cli): compact stale device status (#1388) feat: add WebView accessibility lab (#1397) feat: parameterize sensitive recorded inputs (#1369) fix(daemon): keep an active replay session's daemon alive over the CLI path (#1390) # Conflicts: # docs/adr/0012-interactive-replay.md
Summary
Applies the Claude 5 context-engineering guidance (Thariq, 2026-07-24) to the repo's agent docs. The principle: the always-loaded file carries gotchas and invariants; everything situational lives one hop away and loads when the task calls for it.
AGENTS.md: 315 → 233 lines (~58% fewer words), with a routing table at the top.
Removed:
rgadvice. The article's "judgement over rules" case.typescriptbeing a dev dependency.Kept always-loaded, because this is the layer worth spending tokens on: the nine expensive-lessons principles, enforcement gates, Hard Rules, environment traps, the adopted-runner false negative, module-size tripwires.
Moved behind the routing table:
docs/agents/cli-flags.md— the 10-step flag checklist, plus where CLI help/schema livedocs/agents/pull-requests.md— readiness, PR body conventions, review checklistdocs/agents/device-verification.md— staleness defeat, helper-path proof, session hygiene, sandbox trapsdocs/agents/testing.md, reframed aroundpnpm check:affected. The script derives the gate set from repository sources of truth, so the prose table was drift risk; it now carries only the two traps agents actually miss.CONTEXT.md keeps all 51 terms — that vocabulary is exactly the team-specific knowledge worth the tokens — but adds a section index and groups them (sessions/devices, command surface, refs & guarantees, gestures, snapshots, recording, Maestro, providers), so a task loads one section instead of a 200-line wall.
Selector fix (not docs-only). Moving the Testing Matrix out of
AGENTS.mdbroke a sentinel:scripts/check-affected/model.tstreated onlyAGENTS.mdas selector-owning, so a later matrix edit would have been silently classified inert docs while the selector kept deriving gates from a spec that had changed underneath it. The sentinel now lives with the prose as a namedSELECTOR_OWNING_DOCSset, with the three stale references to the old location fixed (testing.md, and comments inmodel.ts/checks.ts).Validation
Static gates, all green locally:
pnpm check:affected:test(31/31),typecheck,lint,format:check. Full CI green on the pre-restoration head (24/24).Selector behavior, verified by running the model rather than trusting the unit test:
docs/agents/testing.mdscripts/check-affected/model.tsAGENTS.mdAGENTS.mdbecoming docs-only is intended: it no longer defines the selection model, so ordinary agent-doc edits should not force the full local suite. The updated test is revert-sensitive — revert the model change andfailOpenReasons[0]isundefined, so it fails rather than passing vacuously. Ordering also confirmed:isSelectorOwningruns before theisDocsshort-circuit, so adocs/path reaches the rule.Content preservation was the main risk in a split this size, so it was checked mechanically, not by eye. Diffing backtick-identifier sets old vs new confirmed all 51 CONTEXT.md terms survived and every AGENTS.md identifier was either intentionally cut or present in its new home; that caught two losses during the split (the over-budget
session.ts/apps.tsnote, and the full path torunner-contract.ts).That check had a blind spot: it only sees rules containing a backticked identifier. Review found two pure-prose rules it missed, both now restored — "test through public interfaces / no unrelated production exports for tests" (to
testing.md, next to the behavioral-tests rule) and the guidance-ownership rule (to the always-loaded Docs & skills section, since it governs all command-surface work, not just flags). A follow-up prose-level sweep over all 200 original bullets confirmed those two were the only real losses; the rest are intentional cuts or reworded survivors.Rebased onto
origin/main; the conflict with #1397 was one new term (iOS WebView semantic presentation), re-placed into the Snapshots & capture group and re-verified at 51/51 against main.Follow-up (not blocking)
This PR proves content survived, not that agents reliably follow the routing hop. Worth a small eval — SkillGym or a focused agent-doc eval — over representative prompts (add a CLI flag; change a platform response; verify on Android; review a routing PR; add a test), measuring both compliance and context consumed. That would turn this from a plausible documentation optimization into an evidence-backed one.