claude-code - 💡(How to fix) Fix PostToolUse hook system-reminders include full file content, consuming excessive context [1 comments, 2 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#49471Fetched 2026-04-17 08:40:14
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

Root Cause

The PostToolUse hook system-reminders now include the full content of every file modified by a formatter/linter. When lint-staged runs on a commit touching 10 files, the hook injects ~1,500+ lines of complete file contents as system-reminders into the conversation context in a single turn.

This did NOT happen before — previously the reminders only notified that the file was modified without dumping the content.

RAW_BUFFERClick to expand / collapse

Problem

A single git commit message consumed ~18% of the session token budget. This is disproportionate — the actual work (writing code, running tests, taking screenshots) across 5 features in the same session used the other 82%.

Root Cause

The PostToolUse hook system-reminders now include the full content of every file modified by a formatter/linter. When lint-staged runs on a commit touching 10 files, the hook injects ~1,500+ lines of complete file contents as system-reminders into the conversation context in a single turn.

This did NOT happen before — previously the reminders only notified that the file was modified without dumping the content.

Token Impact

  • 10 files committed → lint-staged reformats them → 10 system-reminders with full file contents
  • Files ranged from 160 to 530 lines each
  • Total injected: ~2,500+ lines of code as context in one turn
  • Result: 18% of session budget consumed by a single commit operation

Reproduction

  1. Have a project with lint-staged configured (prettier + eslint on pre-commit)
  2. Stage and commit ~10 files via Claude Code
  3. Observe the system-reminders after the commit — each reformatted file includes its full content with line numbers
  4. Check session usage — single commit consumes disproportionate budget

Expected Behavior

  1. System-reminders from formatter hooks should NOT include full file content — just notify the file was modified (as they did before)
  2. A commit operation should not consume more than ~1-2% of session budget regardless of how many files lint-staged touches

Environment

  • Claude Code VSCode Extension
  • macOS Darwin 25.4.0
  • Model: claude-opus-4-6 (1M context)
  • lint-staged with prettier + eslint

extent analysis

TL;DR

Modify the PostToolUse hook system-reminders to only notify that a file was modified, without including the full file content, to reduce session token budget consumption.

Guidance

  • Review the PostToolUse hook configuration to identify where the full file content is being injected into system-reminders and modify it to only include a notification that the file was modified.
  • Verify that the modification is correct by checking the system-reminders after a commit operation and ensuring they no longer include full file contents.
  • Test the updated hook with different commit scenarios to ensure the session token budget consumption is within the expected range of 1-2%.
  • Consider adding a character limit or truncation to system-reminders to prevent similar issues in the future.

Example

No code snippet is provided as the issue does not include specific code details, but the modification should involve changing the PostToolUse hook to exclude full file contents from system-reminders.

Notes

The solution assumes that the PostToolUse hook is configurable and that modifying it will resolve the issue. If the hook is not configurable, alternative solutions may be necessary.

Recommendation

Apply workaround: Modify the PostToolUse hook to exclude full file contents from system-reminders, as this is the most direct way to address the issue and reduce session token budget consumption.

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 PostToolUse hook system-reminders include full file content, consuming excessive context [1 comments, 2 participants]