[BUG] Agent Loses CLAUDE.md project rules context on a regular basis.
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
After extended conversations that trigger automatic context compaction, the Claude Code agent stops following project-specific instructions defined in CLAUDE.md. Rules that were being followed earlier in the conversation are ignored or forgotten.
Environment:
Claude Code CLI (VSCode extension)
Model: claude-opus-4-5-20251101
Platform: macOS (Darwin 25.2.0)
Suggested Fix:
CLAUDE.md content should be treated as persistent system context that survives compaction, similar to how system prompts are handled. The summarization process should either:
Always re-inject CLAUDE.md content after compacts, or
Exclude CLAUDE.md instructions from summarization entirely
What Should Happen?
Expected Behavior:
The agent should maintain awareness of CLAUDE.md instructions throughout the entire session, including after compacts. Project-level rules should be preserved as critical context during summarization.
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce:
Create a comprehensive CLAUDE.md file with project-specific conventions (database patterns, testing approaches, code style rules, etc.)
Start a new conversation where the agent correctly follows the CLAUDE.md instructions
Continue working on multiple tasks until the conversation triggers one or more automatic compacts
Request a task that should follow CLAUDE.md conventions
Actual Behavior:
After compacts occur, the agent:
Forgets project-specific database conventions (e.g., using enums when CLAUDE.md explicitly says not to)
Ignores testing patterns defined in the file
Misses infrastructure setup steps documented in CLAUDE.md
Reverts to generic approaches instead of following documented project patterns
Impact:
Requires repeatedly re-stating rules already in CLAUDE.md
Leads to inconsistent code that doesn't match project conventions
Defeats the purpose of maintaining project documentation in CLAUDE.md
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
anthropic.claude-code@2.1.31
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗