Cachecut
by Sujal Tangde
Identify and fix prompt-cache busters to reduce LLM API costs using measured hit-rate optimization.
$1.90
Cachecut
Example session with this skill installed
Scan my repo for cache busters and optimize the prompt in src/chains/researcher.py. The Anthropic bill is too high because we keep sending the same 5k token context.
- Read your context and instructions
- Compiled the cachecut
I have analyzed src/chains/researcher.py and measured the cache hit rate. The primary buster was a dynamic current_time string injected at the very top of the system prompt, which invalidated the 5,200 token RAG context on every request. I also found that your tool list was being serialized from a Python set, causing random ordering.
CacheCut report
| Call site | Provider/model | Hit rate before | Hit rate after | Est. input cost change |
|---|---|---|---|---|
| src/chains/researcher.py:42 | claude-3-5-sonnet | 0.0% | 88.4% | −72.5% |
Busters fixed:
src/chains/researcher.py:45: Moveddatetime.now()from system prompt prefix to the user message block.src/chains/researcher.py:58: Wrappedtoolslist insorted()to ensure deterministic serialization.src/chains/researcher.py:112: Addedcache_control={"type": "ephemeral"}to the large RAG context block.
Skipped:
src/utils/summarizer.py:12: Left alone. Static prefix is only 140 tokens, which is below the 1024 token minimum for effective caching on this provider.
Assumptions:
- Based on 1,000 requests/day.
- Anthropic Claude 3.5 Sonnet pricing (Cache Write: $3.75/MTok, Cache Read: $0.30/MTok).
Next steps
- Deploy the changes to
src/chains/researcher.pyto start seeing immediate bill reductions. - Update your logging to capture
usage.cache_read_input_tokensin your production dashboard. - Re-verify hit rates in one week to ensure the 5-minute TTL is sufficient for your traffic patterns.
Connects securely to your tools. The creator never sees your data.
About this skill
High LLM bills often stem from a 0% cache hit rate caused by a single changing byte in your prompt prefix. This skill identifies cache-busters like timestamps, unsorted JSON, or dynamic user data that silently break prompt caching, and restructures your code to fix them.
What it does
- Automatic scanning of your repository to locate all LLM call sites and potential cache-breaking patterns.
- Hit rate measurement by analyzing raw usage objects or replaying traffic to establish a cost baseline.
- Prompt restructuring to move dynamic variables after static system instructions, tools, and RAG context.
- Deterministic ordering of tool definitions, examples, and JSON keys to ensure prefix consistency.
- Provider-specific implementation including Anthropic's
cache_controland OpenAI's prefix optimization rules. - Savings verification through before-and-after reports with real measured token counts.
How it works
- Inventory: Run the scan script to map out provider models, call sites, and static prefix sizes.
- Baseline: Capture current
cached_tokensusage from logs or test requests to calculate the existing hit rate. - Diagnose & Fix: Move busters like "Current Date" or user IDs out of the prefix and enforce sorted serialization.
- Report: Generate a table showing the hit rate delta and the percentage reduction in input token costs.
Frameworks & tools
Works with Python-based LLM applications using OpenAI, Anthropic, or Gemini SDKs. Includes specialized scripts for repo scanning and usage log analysis.
Why this beats prompting it yourself
Generic prompts often miss the subtle provider-specific rules, like Anthropic's explicit opt-in requirement or OpenAI's 1024-token block minimums. This skill uses measured usage data to prove savings rather than guessing, ensuring you don't pay "cache-write" premiums for prefixes that never get reused.
Use cases
- Cost optimization for RAG pipelines with large, static document corpora.
- Fixing broken caching in agents that use frequently changing tool definitions or system prompts.
- Scaling chat applications by optimizing append-only conversation history.
- Pre-ship audit to ensure new LLM features are cache-ready before hitting production.
Known limitations
Does not support prompts where the static prefix is below the provider's minimum cacheable threshold. Requires access to raw usage logs or the ability to run test traffic.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 7 days ago
- Software
Python
Permissions
What's inside
Frequently Asked Questions
New in LLM Ops
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.