Claude Code loads more than one always-loaded file per session: CLAUDE.md plus every .claude/rules/*.md (and ~/.claude/CLAUDE.md at user level). In our repo that is CLAUDE.md (6 KB) + 10 rule files (45 KB). Today resolveMemoryFiles picks the first existing entry as primary, the analysis prompt renders INSTRUCTION_INDEX from that file only (analyze.js), and the other configured files are reported as separate - not optimized.
Consequence: the largest part of the surface an agent actually pays for every session is invisible to the loss calculation, and the budget bar under-counts it. Running once per file is possible with --memory-file, but each run re-analyzes every transcript because the surface hash changes (≈ USD 17 per file on 50 sessions in our case).
Proposal:
memoryFiles (or a new memorySet) = one surface. Instruction ids prefixed per file (RULE-verify-before-act:AG-003), one shared evidence cache keyed on the set hash (which memorySetHash already computes).
- Synthesis stages every file of the set; each hunk already carries
file, so apply needs no new shape.
- Budget = the sum of the set + skill descriptions.
- Discovery helper:
--memory-glob ".claude/rules/*.md".
Happy to test a branch against our corpus (369 transcripts, 2 harnesses).
Claude Code loads more than one always-loaded file per session:
CLAUDE.mdplus every.claude/rules/*.md(and~/.claude/CLAUDE.mdat user level). In our repo that isCLAUDE.md(6 KB) + 10 rule files (45 KB). TodayresolveMemoryFilespicks the first existing entry asprimary, the analysis prompt rendersINSTRUCTION_INDEXfrom that file only (analyze.js), and the other configured files are reported asseparate - not optimized.Consequence: the largest part of the surface an agent actually pays for every session is invisible to the loss calculation, and the budget bar under-counts it. Running once per file is possible with
--memory-file, but each run re-analyzes every transcript because the surface hash changes (≈ USD 17 per file on 50 sessions in our case).Proposal:
memoryFiles(or a newmemorySet) = one surface. Instruction ids prefixed per file (RULE-verify-before-act:AG-003), one shared evidence cache keyed on the set hash (whichmemorySetHashalready computes).file, so apply needs no new shape.--memory-glob ".claude/rules/*.md".Happy to test a branch against our corpus (369 transcripts, 2 harnesses).