Skip to content

docs(agents): AGENTS.md fits a context budget and Claude Code loads it #841

Closed

Description

@dan-petty

Context & Rationale

Claude Code loads CLAUDE.md. This repo's CLAUDE.md is an 825-byte stub that links to AGENTS.md only in prose, so sessions and subagents see the rules only if they choose to open the file. Claude Code's memory docs (code.claude.com/docs/en/memory) describe @AGENTS.md imports and recommend staying under 200 lines.

AGENTS.md is 96,310 bytes over 426 lines, about 20.7k tokens (docs/ROADMAP.md:896-900). 54 of those lines exceed 400 characters. The whole file is also injected into:

  • every review persona prompt (ai/review/classification.py:48-72, called at runner.py:1167);
  • the harness repo context (ai/harness/repo_context.py:258-273).

Importing it unchanged would add about 21k tokens to every session and every subagent. Research finds no general gain from more context, but does find value in documenting non-standard practices (arXiv 2602.11988, 2607.27250). The 'Instruction Envelope Audit' entry (ROADMAP.md:896, table row :1412) has no issue.

Scope & Deliverables

  • Deliverable:
    • Cut AGENTS.md to at most 40,000 characters, set by a constant in config/constants.py. A recorded second step lowers it to 20,000 characters, about 200 lines of typical length, once procedures move into skills or path-scoped rules.
    • Move procedures, with links, to the docs that already cover them. Release choreography, the PR monitoring loop and the review feedback loop go to docs/SDLC.md or docs/SELF_IMPROVEMENT.md.
    • Replace any rule that a named check enforces with a pointer to that check.
    • generate_pointer_stub emits @AGENTS.md into CLAUDE.md, and the generator mirrors the trimmed content.
    • Mark the ROADMAP entry and its table row as superseded. The gate-attribution command is not built.
  • Acceptance criteria:
    • A test asserts that len(AGENTS.md) is at most the budget constant, and that the constant is at most 40,000.
    • CLAUDE.md contains @AGENTS.md, and the generator test covers it.
    • The PR maps every moved or removed section to its new location or to the check that enforces it.
    • The PR records the token counts before and after, and the resulting per-persona review prompt size.
    • The PR records a fresh session's /memory listing showing AGENTS.md loaded.
  • Key questions:
    • Import AGENTS.md, or delete the stub and rely on Claude Code loading AGENTS.md when no CLAUDE.md exists? (proposed) Import it: the mechanism is documented and does not depend on a setting's default.
    • Who approves the cuts? (proposed) The owner, through the mapping table.
  • Constraint: No rule disappears without a recorded destination.

Strategic Alignment

Owner decisions (2026-10-01)

From the agentic quality assessment (https://claude.ai/artifact/K7S7AkKJymFydhjwexigiN), decided by the owner. These replace any matching proposed answer above.

Update 2026-10-08: refinement

AGENTS.md is 112,508 bytes over 479 lines. #840 landed. docs/ROADMAP.md is generated, so the ROADMAP deliverable is dropped. AGENTS.md reaches a model via the persona prompt (deleted by #1151) and ai/harness/repo_context.py:75. Procedures to move: AGENTS.md:298-356. #1308 and #1336 move the test rules to docs/TESTING.md; those moves count toward the budget and go in the mapping table.

Activity

  1. added
    type/docs
    scope/ai
    priority/p2-medium
    on Oct 1, 2026
  2. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    More evidence for this issue from the devsecops review session 20261001-224227 (2026-10-02). Each finding below was triaged against release/v0.2.25 (c279c18), judged real and covered by this issue, and then upheld by a second agent that tried to refute it.

  3. added this to the v0.2.34 milestone on Oct 10, 2026
  4. dan-petty-bot commented on Oct 10, 2026

    @dan-petty-bot
    Collaborator

    Moved to v0.2.34: v0.2.34 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)

  5. dan-petty commented on Oct 11, 2026

    @dan-petty
    OwnerAuthor

    Merged

  6. added a commit that references this issue on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/aitype/docs

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions