claude-code - 💡(How to fix) Fix Compensation needed: Repeated violation of explicitly injected rules consumes user tokens [1 participants]

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…
GitHub stats
anthropics/claude-code#46062Fetched 2026-04-11 06:29:59
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×1
RAW_BUFFERClick to expand / collapse

Symptom

Claude Code repeatedly violates a rule that is explicitly re-injected via hook on every user prompt submission, causing unnecessary token consumption.

How to reproduce

  1. User configures a rule via ~/.claude/hooks/reinject-rules.sh (e.g., "Always respond in 존댓말")
  2. Hook injects the rule at the start of each turn via UserPromptSubmit event
  3. Claude ignores the rule and responds in non-compliant format
  4. Rule re-injected on next turn, Claude violates again
  5. Repeat indefinitely — each violation wastes tokens on re-injecting the same rule

Expected behavior

  • Rule is injected once per turn
  • Claude respects the rule and responds accordingly
  • If Claude violates, it should be a rare edge case, not chronic

Actual behavior

  • Hook injects rule reliably every turn
  • Claude ignores rule consistently across multiple turns
  • User must point out violation and request correction
  • Correction lasts only until next turn, then same violation repeats
  • User token budget spent re-injecting the same rule on every turn

extent analysis

TL;DR

The issue can be mitigated by modifying the reinject-rules.sh hook to handle rule persistence across turns, ensuring Claude respects the injected rule.

Guidance

  • Investigate the UserPromptSubmit event handling to determine why the injected rule is not being respected by Claude.
  • Consider modifying the reinject-rules.sh hook to store the injected rule and check if it has already been applied before re-injecting, to prevent unnecessary token consumption.
  • Review the rule injection mechanism to identify potential causes for Claude's consistent ignoring of the rule, such as formatting or syntax issues.
  • Test the hook with a simplified rule to isolate if the issue is specific to the "Always respond in 존댓말" rule or a more general problem.

Example

No code snippet is provided due to lack of specific implementation details in the issue.

Notes

The solution may require additional modifications to the Claude Code or the hook mechanism, depending on the underlying cause of the issue. The provided guidance is based on the information given and may need to be adapted to the specific implementation.

Recommendation

Apply a workaround by modifying the reinject-rules.sh hook to handle rule persistence, as this approach can help mitigate the token consumption issue without requiring a full understanding of the underlying cause.

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…

FAQ

Expected behavior

  • Rule is injected once per turn
  • Claude respects the rule and responds accordingly
  • If Claude violates, it should be a rare edge case, not chronic

Still need to ship something?

×6

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

Back to top recommendations

TRENDING