Cache-aware cost guard for Claude Code
npx claudepluginhub banyudu/claude-cacheCache-aware cost guard for Claude Code — warns before submitting prompts that may trigger expensive cache rewrites
Cache-aware cost guard for Claude Code. Intercepts tool calls that may cause expensive prompt cache invalidation — warns or blocks operations that read/write large files, protecting your token budget.
Claude Code's prompt caching saves significant costs by reusing previously cached context. But certain operations silently invalidate the cache:
Without visibility into these costs, a single Read of a 100KB file can silently waste thousands of cached tokens — turning a cheap conversation into an expensive one.
Cache Control hooks into Claude Code's PreToolUse and UserPromptSubmit events to estimate the token impact of every file operation before it happens.
Read, Write, Edit, and Bash tool calls to estimate cache impact based on file sizeThe result: visibility into cache costs before they happen, with configurable thresholds to warn or block expensive operations.
Two commands inside Claude Code:
/plugin marketplace install banyudu/claude-cache
/plugin install cache@claude-cache
That's it. Restart Claude Code and Cache Control is active.
npm install -g claude-cache
claude --plugin-dir $(npm root -g)/claude-cache
git clone https://github.com/banyudu/claude-cache.git
cd claude-cache && pnpm install && pnpm run build
claude --plugin-dir ./claude-cache
Cache Control works out of the box with sensible defaults. To customize, create a config file:
~/.claude/cache-control.yaml.claude/cache-control.yamlConfig is evaluated in layers with project > user > default priority:
.claude/cache-control.yaml) — highest priority~/.claude/cache-control.yaml)| Threshold | Default | Description |
|---|---|---|
warnTokens | 40,000 (~160KB) | Ask before proceeding |
blockTokens | 400,000 (~1.6MB) | Deny the operation |
warnCumulativeTokens | 500,000 | Warn on all subsequent ops |
protectClaudeMd | true | Always ask before modifying CLAUDE.md |
thresholds:
warnTokens: 80000
blockTokens: 800000
warnCumulativeTokens: 1000000
protectClaudeMd: true
tools:
Read:
warnTokens: 100000
Write:
warnTokens: 20000
| Command | Description |
|---|---|
/setup | Show setup status |
/config | View or edit thresholds |
/status | Show session cache impact stats |
/reset | Reset session tracking data |
MIT