claude-code - 💡(How to fix) Fix CLAUDE.md rules not propagated to Agent subagents and weakened after context compaction

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

CLAUDE.md instructions and skill rules are not reliably followed in two specific scenarios:

  1. Agent subagents do not inherit the parent's CLAUDE.md rules
  2. After context compaction, rule adherence degrades significantly

Root Cause

CLAUDE.md instructions and skill rules are not reliably followed in two specific scenarios:

  1. Agent subagents do not inherit the parent's CLAUDE.md rules
  2. After context compaction, rule adherence degrades significantly

Fix Action

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.

RAW_BUFFERClick to expand / collapse

Summary

CLAUDE.md instructions and skill rules are not reliably followed in two specific scenarios:

  1. Agent subagents do not inherit the parent's CLAUDE.md rules
  2. After context compaction, rule adherence degrades significantly

Reproduction

I have a detailed CLAUDE.md with specific tool restrictions:

  • "Use rg or ugrep instead of grep"
  • "Never use python3 -c / perl -e for 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 -c to parse JSON instead of using the Read tool
  • Using grep instead of the configured rg/ugrep

This is especially noticeable when the model is focused on completing a task quickly and "forgets" the custom tool preferences.

Expected Behavior

  1. 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.
  2. 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix CLAUDE.md rules not propagated to Agent subagents and weakened after context compaction