Skip to content

Feature: treat memoryFiles as one always-loaded surface (multi-file instruction index), not "first existing wins" #111

Description

@jic-cc

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).

Activity

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

    ready-for-prIssue is in scope and ready for a PR

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions