CLAUDE.md rules not propagated to Agent subagents and weakened after context compaction
Summary
CLAUDE.md instructions and skill rules are not reliably followed in two specific scenarios:
- Agent subagents do not inherit the parent's CLAUDE.md rules
- After context compaction, rule adherence degrades significantly
Reproduction
I have a detailed CLAUDE.md with specific tool restrictions:
- "Use
rgorugrepinstead ofgrep" - "Never use
python3 -c/perl -efor inline execution" - "Use Read/Edit/Write tools instead of Bash for file operations"
These rules are followed correctly at the start of a conversation, but are violated in the following conditions:
Case 1: Agent subagents don't inherit CLAUDE.md rules
When spawning subagents via the Agent tool (e.g., subagent_type: "Explore"), the subagent does not receive the parent's CLAUDE.md instructions. The subagent then uses unrestricted tools (e.g., grep instead of rg, or python3 -c for parsing).
The coordinator prompt passed to the agent does not and cannot reproduce the full CLAUDE.md rules. This makes any tool restriction rules effectively unenforceable when work is delegated to subagents.
Case 2: Rules weaken after context compaction
In long conversations where context is compacted, the detailed behavioral rules in CLAUDE.md (loaded at session start) appear to lose effectiveness. The model falls back to familiar patterns:
- Using
python3 -cto parse JSON instead of using the Read tool - Using
grepinstead of the configuredrg/ugrep
This is especially noticeable when the model is focused on completing a task quickly and "forgets" the custom tool preferences.
Expected Behavior
- Agent subagents should inherit at minimum the CLAUDE.md rules from the parent session, or there should be a mechanism to pass key restrictions to subagents.
- After context compaction, CLAUDE.md rules should maintain their priority throughout the entire session, not just in the initial turns.
Environment
- Claude Code CLI, model: Claude Sonnet 4
- CLAUDE.md with extensive tool restriction rules and skill plugin rules
- macOS Darwin 25.5.0
Workaround
Currently the only workaround is to manually correct the model each time it violates a rule, which defeats the purpose of having persistent instructions in CLAUDE.md.
This issue has 12 comments on GitHub. Read the full discussion on GitHub ↗