Feature request: Re-inject CLAUDE.md after context compaction in long sessions
Hi team! First off, Claude Code has been an incredible tool for me. I'm using it daily to build and run a blog, and it's genuinely changed how I work.
I wanted to share something I've noticed during long sessions that might be worth considering.
What I observed
In sessions that run long (200k+ tokens), I've noticed that nuanced instructions from CLAUDE.md start getting lost after context compaction. Specific rules like "always use --exclude feedback/* when syncing to S3" seem to get summarized into something vaguer during compaction, and the model stops following them reliably.
Why it matters for my workflow
I rely on CLAUDE.md for project-specific rules that prevent data loss (like the S3 exclude flag that preserves reader feedback files). When these get diluted in long sessions, I have to re-state them manually or risk losing data.
What I did as a workaround
I set up PreToolUse/PostToolUse hooks to mechanically enforce the critical rules. This works great for rules that can be checked with grep/regex, but not for judgment-based instructions (like writing style rules).
What might help
Would it be feasible to re-read and inject the raw CLAUDE.md content after compaction (rather than summarizing it with everything else)? The file is typically small for most projects, so the token cost seems minimal compared to the instruction drift risk.
Totally understand if there are architectural reasons this is harder than it sounds. Just sharing what I've experienced in case it's useful signal.
Thanks for building such a great tool!
Environment: Claude Code CLI on macOS, Opus model, sessions regularly exceed 200k tokens
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗