Repository navigation
Closed
Labels
Description
Goal
Research published good practices for AGENTS.md (and equivalent agent instruction files), then apply them to the repository's root AGENTS.md so it carries only the always-needed guidance and consumes materially fewer tokens in every agent session.
Background
AGENTS.md is loaded into the context of every agent session. It is about 36 KB, 523 lines and 3,700 words, and Claude Code reports that it consumes too many tokens. Every session pays that cost, including sessions where most of the content is irrelevant.
- It mixes always-needed rules (linting gate, GPG signing, branch naming) with reference material only needed for some tasks (package catalog and tables, configuration file table, container volume mappings, documentation navigation).
- Several sections restate content that already lives in skills or
docs/, which conflicts with the file's own Engineering Policy 6 (documentation single source of truth). - The package catalog duplicates
cargo metadata --no-depsanddocs/packages.md, and drifts when packages are added or extracted. - No
CLAUDE.mdis needed: Claude Code acceptsAGENTS.mdas an automatic replacement, soAGENTS.mdstays the single source of truth.
Scope
In scope:
- Research good practices for agent instruction files and record sources and adopted practices in an issue-local
research.md. - Measure and record the baseline token footprint with a reproducible method.
- Classify every
AGENTS.mdsection (keep inline, move to a skill, move todocs/, link, replace with a command, or delete) in an issue-localsection-disposition.md, after maintainer review. - Apply the dispositions without losing any rule or duplicating guidance.
- Define a lightweight guard against regrowth.
Out of scope:
- Changing repository policies, rewriting skills or docs beyond receiving moved content, changing
.github/agents/*.agent.md, and provider-specific tuning. - An ADR is not planned for now; this is re-evaluated after implementation.
Acceptance criteria
- The research documents sources and adopted practices, each tied to evidence.
- Baseline and final token measurements use the same documented method, and the final footprint is materially lower (target agreed with the maintainer after the research).
- Every original section has a recorded disposition, and every moved rule is reachable from
AGENTS.mdby link or skill reference. - No procedural guidance is duplicated between
AGENTS.mdand a skill ordocs/page. AGENTS.mdremains the sole source of truth and no provider-specific adapter file is introduced.- A regrowth guard is documented.
The full specification will live at docs/issues/open/<number>-reduce-agents-md-token-footprint/ISSUE.md.
Activity
docs(issues): add issue specification for #2691
Merge #2692: docs(issues): [#2691] add specification to reduce the AG…
jimy-r commentedon Oct 30, 2026
Three things from trimming the always-loaded files in my own Claude Code workspace.
Moving a section to a skill doesn't take it to zero. Skill descriptions stay in every session, and mine currently cost about 9k tokens, so a move pays only when the description is far shorter than the text it replaces.
Test nested
AGENTS.mdfiles before relying on them for path-scoped loading. In my probes on Claude Code 2.1.286, in a repo with a rootCLAUDE.md, a nestedAGENTS.mdwith no siblingCLAUDE.mddid not load. Your root-AGENTS.md-only layout may behave differently.For "without losing any rule", build the checklist from the original file before you edit, then assert each rule is still reachable afterwards. A check seeded from the list of moves you made can only confirm those moves.
I maintain a reference architecture that documents the pointer approach your dispositions describe: https://jimy-r.github.io/agent-workspace-architecture/patterns/17-one-canonical-copy-and-pointers-from-everywhere-else.html
I'd like to see your before and after numbers, and the measuring method you settle on.
Drafted with Claude Code and reviewed by me before posting.
docs(agents): [torrust#2691] point to the linter and hook skills inst…
docs(skills): [torrust#2691] add history and PR-title rules to the op…
docs(agents): [torrust#2691] move Git Workflow detail to the open-pul…
docs(skills): [torrust#2691] document the VS Code agent skills settin…
docs(agents): [torrust#2691] condense the remaining AGENTS.md sections
docs(issues): [torrust#2691] record the final AGENTS.md token measure…
docs(issues): [torrust#2691] record the fresh-session rules check and…
docs(issues): [torrust#2691] record the fresh-session discoverability…
docs(issues): [torrust#2691] add the implementation retrospective and…
docs(issues): [torrust#2691] record the AC4 and ADR decisions
docs(issues): [torrust#2691] record the independent review and fix it…
docs(issues): [torrust#2691] record the re-review and correct the R03…
docs(issues): [#2691] record the AGENTS.md token baseline and best-pr…
docs(issues): [#2691] record the Claude Code /context baseline for AG…
docs(issues): [#2691] propose a disposition for every AGENTS.md section
docs(issues): [#2691] record the maintainer review decisions for the …
docs(packages): [#2691] make docs/packages.md the canonical package c…
docs(issues): [#2691] add a rule inventory built from the baseline AG…
docs(agents): [#2691] link package naming conventions and container u…
Merge torrust#2704: docs(agents): [torrust#2691] reduce the AGENTS.md…
chore(issues): archive closed issue #2691 spec to docs/issues/closed
Merge #2717: chore(issues): archive closed issue #2691 spec to docs/i…
josecelano-bot commentedon Nov 4, 2026
Thanks for the comment. It was useful: it led us to build the completeness checklist from the original file instead of from the planned moves.
Result (PR #2704): the root
AGENTS.mdwent from 12.4k to 4.8k tokens as reported by Claude Code's/context(about 61% less). It went from 523 to 229 lines and from 35,910 to 13,027 bytes.How we measured it:
/contextin a fresh session, with the checkout state recorded (git rev-parse,wc -l). One early reading showed the old size because the session had loaded the old file, so we discarded it. Atiktokenscript was used only for quick estimates.How we avoided losing rules: all 99 rules and facts of the original file are in a rule inventory. Each has a final location or a recorded reason for removal. Content moved to
docs/packages.md(the package catalog), theopen-pull-requestskill and existing docs. Two fresh-session checks confirmed an agent still finds the commit, signing and branch rules, and the moved package and port content. An independent review found no lost rules and some stale cross-references, which are now fixed.Not done, on purpose: no size guard in CI, no
CLAUDE.md, and no ADR. We can revisit those later. Details are indocs/issues/closed/2691-reduce-agents-md-token-footprint/.