[FEATURE] Inject skill content into cached system prompt instead of message history (lower token cost per turn)

Open 💬 1 comment Opened Jun 22, 2026 by stevef-del

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

When a skill is invoked (e.g. /claude-api), its content is injected into the conversation as a message. This means the skill content is billed at full input token price on every subsequent turn and accumulates in the growing message history. The ideal architecture would place skill content in a cached system prompt position, paying the cache-write premium once and cache-read rates (~0.1×) thereafter.

Current behavior

/claude-api invoked
~200k tokens of documentation injected into message history
→ Turn 2: pay full price for those 200k tokens again
→ Turn 3: pay full price again
→ Turn N: pay full price again, plus any history growth

The /context command confirms this — Messages: 213.8k tokens (21.4%) after a single skill invocation, with Skills: 1.1k tokens (0.1%) reflecting only the always-present skill descriptors.

Proposed Solution

Ideal behavior

/claude-api invoked
→ skill content added to a cached system prompt layer with cache_control: {type: "ephemeral"}
→ Turn 2: cache hit, ~0.1× cost for skill content
→ Turn N: same cache hit rate, no accumulation

Impact

For large skills like claude-api (~200k tokens), across a 10-turn session this is roughly:

  • Current: 10 × 200k = 2M tokens billed
  • Cached: 200k (write) + 9 × 20k (reads) = 380k tokens billed
  • ~5× cost difference for a single skill in a short session

Proposed approach

Claude Code could maintain a "skill cache layer" — a prefix that extends when skills are invoked and is passed as part of the system prompt (with cache_control) on every subsequent API call within the session. The system prompt assembly would need to be dynamic per-turn rather than fixed at conversation start.

Constraints to consider:

  • System prompt is currently fixed at conversation start
  • role: "system" mid-conversation (Opus 4.8) is still message-tier billing — not equivalent
  • Pre-loading all skills defeats on-demand loading

Alternative Solutions

_No response_

Priority

Medium - Would be very helpful

Feature Category

CLI commands and flags

Use Case Example

Many questions about the environment itself can trigger loading claude-api skill which is 200K tokens. They inject as messages. All turns that follow pay the high cost of reading the entire claude-api skills documentation as message history.

Additional Context

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗