[FEATURE] Cache CLAUDE.md between sessions — skip reload when file unchanged
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Problem
Per the official documentation:
Each Claude Code session begins with a fresh context window. Two mechanisms carry knowledge across sessions: - CLAUDE.md files - Auto memory Both are loaded at the start of every conversation.
This means the full contents of all discovered CLAUDE.md files are injected into context on every session start, regardless of whether the files have changed. For users who restart sessions frequently (context limits, breaks, task switching), identical tokens are consumed repeatedly with zero informational value.
The cost scales with:
- Number of
CLAUDE.mdfiles in the hierarchy (ancestor directory walking) - Files imported via
@syntax (up to 5 hops) .claude/rules/*.mdfiles- Frequency of session restarts
Context
- The memory documentation recommends keeping files under 200 lines but provides no mechanism to avoid redundant loading
MEMORY.mdalready has a 200-line / 25KB truncation limit, showing context budget is a recognized concernclaudeMdExcludesexists for monorepos, showing precedent for controlling what gets loaded/compactre-readsCLAUDE.mdfrom disk, confirming the system already has a reload path
Impact
Low-effort optimization (hash comparison is trivial) that saves tokens proportional to CLAUDE.md size x session restart frequency. Most beneficial for power users with structured project instructions who restart sessions often.
Proposed Solution
Option A — Full cache (best for unchanged files):
Cache a hash or mtime of each loaded CLAUDE.md file between sessions. On session start:
- Discover files as usual (directory walk, imports, rules)
- Compare hash/mtime against cached values
- If unchanged, reuse cached content without re-consuming tokens
- If changed, reload and update cache
Option B — Diff injection (best for small edits):
When a file has changed since last session, inject only the diff rather than the full file. For a one-line edit in a 200-line CLAUDE.md, this saves ~99% of the tokens that would otherwise be re-loaded. Full reload only when the diff exceeds a threshold (e.g. >50% of the file changed).
Both options are compatible and could be combined.
Written by Claude
Alternative Solutions
_No response_
Priority
Medium - Would be very helpful
Feature Category
Interactive mode (TUI)
Use Case Example
_No response_
Additional Context
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗