Rules re-injected as system-reminders on every tool call, consuming ~46% of context window
Problem
Claude Code re-injects rule files (from .claude/rules/) as <system-reminder> blocks attached to tool call results throughout the conversation. This means the same rules are loaded into context repeatedly — not just once at conversation start.
In a real session with ~30 tool calls, this consumed approximately 93K tokens (46% of the 200K context window) just from rule re-injection, causing the context to fill up before meaningful work was completed.
Observed behaviour
- Rules with
paths:YAML frontmatter are correctly filtered (only matching rules appear) - However, matching rules are re-injected as
<system-reminder>blocks on tool results throughout the conversation - A single
Readtool call resulted in 11 rule files (~6,200 tokens) being injected as system reminders - Over a 30-tool-call session, the same rules are injected repeatedly, totalling ~93K tokens
Expected behaviour
Rules should be loaded into context once (or at most when the set of relevant files changes), not re-injected on every tool call.
Reproduction
- Create a project with 10-15 rule files in
.claude/rules/scoped to common patterns (e.g.**/*.py) - Start a conversation and perform several file reads/edits on matching files
- Observe
<system-reminder>blocks containing full rule text appearing in tool results - Note context window fills rapidly despite rules being modest in size individually
Impact
| Component | Tokens | % of 200K |
|-----------|--------|-----------|
| Initial config load | ~43K | 21% |
| Rule re-injections (~30 tool calls) | ~93K | 46% |
| Actual conversation content | ~50K | 25% |
| Total | ~186K | 93% |
The initial load (21%) is reasonable. The re-injection (46%) is the problem — nearly half the context window is consumed by repeatedly injecting rules the model has already seen.
Suggestion
- Inject rules once at conversation start (or on first relevant file access)
- Only re-inject if the set of relevant rules changes (e.g. user starts working on a different file type)
- Consider a hash/fingerprint approach to avoid re-injecting unchanged rules
Environment
- Claude Code VSCode extension
- ~45 master rule files (shared via symlinks) + 8 project-specific rules
- Rules use
paths:frontmatter for scoping - Model: Claude Opus
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗