Prompt Caching Inefficiency - Dynamic Variables Placed Before Static Tool Definitions

Resolved 💬 4 comments Opened Dec 21, 2025 by cvgoudar Closed Feb 28, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Hi Claude Code team,

I've observed a potential prompt caching inefficiency in Claude Code's system prompt structure based on my limited understanding of how prompt caching works.

Issue: Dynamic variables (working directory, git status, date) appear to be placed in the system prompt before the static tool definitions (~16k tokens), which prevents those tool definitions from being cached effectively.

Impact: This causes ~16-19k tokens to be used as input tokens, with cache invalidation occurring on every project change, daily, and on every git commit. What is possibly local to the user can be optimized for entire user base prompting a significant reduction in token costs and infra requirements.

Proposed Fix: Reorder the prompt structure to place dynamic variables at the end (after static tool definitions), which would allow the largest static portion to be cached across all sessions.

Please see the attached markdown file for detailed analysis, reproduction steps, and the proposed optimization.

Regards,
C.V.Goudar

Proposed Solution

**

claude_code_cache_feedback.md

**

Alternative Solutions

_No response_

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

_No response_

Additional Context

_No response_

View original on GitHub ↗

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