motiful

Cc Cache Audit — Security skill for Claude Code

Security community

A/B test proving Claude Code's billing header breaks cross-session prompt cache sharing.

How to install Cc Cache Audit

This entry records only its repository, not the path inside it, so there is no exact command to give. Open motiful/cc-cache-audit and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Cc Cache Audit does

A/B test proving Claude Code's billing header breaks cross-session prompt cache sharing. One env var fix saves ~85% on system prompt tokens.

Alternatives in Security

README

cc-cache-audit

Claude Code v2.1.69+ injects a dynamic billing header into the system prompt that breaks cross-session prompt cache sharing. This repo contains the A/B test that proves it and the one-line fix.

The Fix

echo 'export CLAUDE_CODE_ATTRIBUTION_HEADER=false' >> ~/.zshrc
source ~/.zshrc

Only affects new sessions. Existing ones keep running fine.

Root Cause

Since v2.1.69, Claude Code prepends an `x-anthropic-billing-header` string to the system prompt:

x-anthropic-billing-header: cc_version=2.1.88.a3f; cc_entrypoint=cli; cch=00000;

That `.a3f` suffix is a 3-char SHA-256 hash computed from the first user message in each conversation:

// Deobfuscated from cli.js
function computeHash(firstUserMessage, version) {
  const chars = [4, 7, 20].map(i => firstUserMessage[i] || "0").join("");
  return sha256("59cf53e54c78" + chars + version).slice(0, 3);
}

Different conversation → different first message → different hash → different system prompt prefix.

This also affects **subagents within the same conversation**. Each Agent tool call has its own message context, so its first "user message" (the agent prompt) produces a different hash. Verified in a real session — 3 distinct hashes in one conversation:

Main conversation:  cc_version=2.1.88.a3f  (34 API calls)
Subagent 1:         cc_version=2.1.88.e91  (3 API calls)
Subagent 2:         cc_version=2.1.88.7c2  (3 API calls)

Anthropic's prompt cache uses [prefix matching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) with no per-session isolation — cache is shared at the Organization/Workspace level. So all Claude Code sessions and subagents *should* share the same cached system prompt. But the billing header makes each one's prefix unique, causing the system prompt (~12K tokens) to get rebuilt from scratch every time.

A/B Test

4 sessions per round, each with a different prompt, sequential with 8-second gaps (within the 5-min ca