CacheScope
scan your codebase for Claude prompt-cache leaks before they drain your token budget
npx -y github:Isco0819/cache-scopeEver run into this?
Like clinic.js which profiles Node.js perf bottlenecks with zero instrumentation, there is nothing equivalent for Anthropic SDK users. Developers unknowingly bust their prompt cache on every request — dynamic content placed before cache_control blocks, missing ephemeral flags, system prompts that shift by one token — and silently pay 3-5x more tokens with zero visibility into why.
The fix
npx cache-scope AST-scans your JS/TS/Python files for Anthropic SDK calls, flags cache_control misplacements and volatile-before-stable ordering violations, and estimates monthly token waste. Also ships as an MCP server so AI coding assistants can query cache health in real time while writing agent code.
What it does
- AST-level detection of cache_control misplacements in messages.create() calls across JS/TS (ts-morph) and Python (ast module)
- volatile-before-stable ordering check: warns when dynamic user content or per-request variables precede cached system prompt blocks
- token waste estimator: multiplies detected leak patterns by configurable call-frequency to show projected monthly $$ impact with fix diff