claude-code - ✅(Solved) Fix [BUG] uncachable system prompt caused by includeGitInstructions / CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS -> `git status` [1 pull requests, 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#47107Fetched 2026-04-13 05:41:16
View on GitHub
Comments
0
Participants
1
Timeline
11
Reactions
2
Author
Participants
Timeline (top)
cross-referenced ×6labeled ×5

Error Message

Error Messages/Logs

Root Cause

(seemingly caused by includeGitInstructions what defaults to true)

PR fix notes

PR #2: fix: stop claude token waste from git status cache busting

Description (problem / solution / changelog)

  • Resolve AGENTS.md merge conflict; merge upstream Working Rules + README/Tutorials with stashed Token & Tool Optimization, Content Structure, and Gotchas sections
  • Add .claude/settings.json with CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS=1 so git-status/recent-commits never invalidate the system-prompt cache (fixes ~6k token cache-write penalty per session; ref anthropics/claude-code#47107)
  • Unblock .claude/settings.json in .gitignore so the fix is committed

https://claude.ai/code/session_01Lo1NNhcnby1YvRzELWpr6E

Changed files

  • .claude/settings.json (added, +5/-0)
  • .gitignore (modified, +1/-0)
  • AGENTS.md (modified, +35/-75)

Code Example

currently the system prompt consists of 3 chunks:

"system": [
 {
  "type": "text",
  "text": "x-anthropic-billing-header: cc_version=2.1.104.f27; cc_entrypoint=cli; cch=00000;"
 },
 {
  "type": "text",
  "text": "You are Claude Code, Anthropic's official CLI for Claude.",
  "cache_control": {
   "type": "ephemeral"
  }
 },
 {
  "type": "text",
  "text": "{systemprompt} {~/CLAUDE.md} {git-status}",
  "cache_control": {
   "type": "ephemeral"
  }
 }
],

---

claude
> alive?
> -> Yes, alive and ready. What do you need? 
# (11k cache read, 6k cache write)

---

claude
> alive?
> -> Yes, I'm here. What can I help you with?  
# (18k cache read)
> /exit

---

git commit --allow-empty -m "Dummy"
claude
> alive?
> -> Yes, alive and well. What do you need?
# (11k cache read, 6k cache write)
RAW_BUFFERClick to expand / collapse

What's Wrong?

session to session generally only the "tools" block will hit a cache the last system section contains a git status output that will change very frequently

(seemingly caused by includeGitInstructions what defaults to true)

What Should Happen?

the system prompt should hit a cache as well.

  • either by moving that git status into user-messages (towards the project/CLAUDE.md content - seems like a better fit anyhow?)
  • or making it its own system[].text block (while keeping the cache_control header to the prompt-block before / having two) (since skills and project/CLAUDE.md will likely change less often than a git-status that still seems like a bad idea...)

the "instructions" part of this would actually be fine anywhere - the git status is not

Error Messages/Logs

currently the system prompt consists of 3 chunks:

"system": [
 {
  "type": "text",
  "text": "x-anthropic-billing-header: cc_version=2.1.104.f27; cc_entrypoint=cli; cch=00000;"
 },
 {
  "type": "text",
  "text": "You are Claude Code, Anthropic's official CLI for Claude.",
  "cache_control": {
   "type": "ephemeral"
  }
 },
 {
  "type": "text",
  "text": "{systemprompt} {~/CLAUDE.md} {git-status}",
  "cache_control": {
   "type": "ephemeral"
  }
 }
],

Steps to Reproduce

Have a statusline show/log you usage

claude
> alive?
> -> Yes, alive and ready. What do you need? 
# (11k cache read, 6k cache write)
claude
> alive?
> -> Yes, I'm here. What can I help you with?  
# (18k cache read)
> /exit
git commit --allow-empty -m "Dummy"
claude
> alive?
> -> Yes, alive and well. What do you need?
# (11k cache read, 6k cache write)

-> the "initial 11k" is likely some publicly shared tool cache that is hit.

note that this is precisely the same "alive?" message every time to bypass https://github.com/anthropics/claude-code/issues/47098 this is somewhat similar - but different (('different user-input' vs 'git changes with precisely the same user input'))

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.104

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Xterm

Additional Information

Sidenote: the "Primary working directory:" line likely also should be in the user-messages and not the system -> or git worktrees will miss very often

extent analysis

TL;DR

Move the git status output to a separate system[].text block or into user-messages to allow the system prompt to hit a cache.

Guidance

  • Identify the git status output as the likely cause of the cache miss, as it changes frequently.
  • Consider moving the git status output to a separate system[].text block, allowing the rest of the system prompt to be cached.
  • Alternatively, move the git status output to user-messages, as suggested, to improve cache hits.
  • Verify the cache behavior by checking the cache read and write counts after making the changes.

Example

No code snippet is provided, as the issue does not contain explicit code that can be modified.

Notes

The issue seems to be related to the includeGitInstructions defaulting to true, which includes the git status output in the system prompt. The suggested solutions aim to separate the dynamic git status output from the rest of the system prompt to improve caching.

Recommendation

Apply workaround: Move the git status output to a separate system[].text block or into user-messages to allow the system prompt to hit a cache, as this approach directly addresses the identified cause of the issue.

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 - ✅(Solved) Fix [BUG] uncachable system prompt caused by includeGitInstructions / CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS -> `git status` [1 pull requests, 1 participants]