Skip to content

Rules re-injected as system-reminders on every tool call, consuming ~46% of context window #32057

@poodle64

Description

@poodle64

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 Read tool 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

  1. Create a project with 10-15 rule files in .claude/rules/ scoped to common patterns (e.g. **/*.py)
  2. Start a conversation and perform several file reads/edits on matching files
  3. Observe <system-reminder> blocks containing full rule text appearing in tool results
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workinghas reproHas detailed reproduction stepsplatform:vscodeIssue specifically occurs in VS Code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions