[BUG] uncachable system prompt caused by includeGitInstructions / CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS -> `git status`

Resolved 💬 3 comments Opened Apr 12, 2026 by wadabum Closed May 24, 2026

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
making the "skills" as well as "project-claude.md" blocks a guaranteed miss costing 6k cache writes for every session

(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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗