prompt-caching-strategy
Helps your agent optimize how it uses prompts for language models. It analyzes how prompts are made to find ways to cut costs and make responses faster by reusing information when possible.
What it does
This tool helps reduce costs and speed up AI responses by better organizing the instructions you send to the AI. It does this by ensuring that repeated parts of your instructions are always the same, so the AI can reuse previous answers.
When to use it
- ✓When you send very similar requests to the AI repeatedly.
- ✓If you want the AI to respond faster.
- ✓To lower the cost of using AI services.
Example of what to ask your AI
“How can I organize my prompts so the AI uses the cache and I pay less?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The tool suggests separating the fixed part of your instructions (like rules or examples) from the part that changes each time (like the current question). This way, the AI can recognize and reuse the fixed parts more easily.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add affaan-m/ECC --skill prompt-caching-strategyOr download just the file:
curl -L https://raw.githubusercontent.com/affaan-m/ECC/main/skills/prompt-caching-strategy/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Prompt Caching Strategy
Arrange reusable prompt content to improve cache reuse, then measure input cost and latency. Savings depend on model, platform, cache eligibility, writes, retention, reuse and output volume. Runtime cache hits and savings for this skill are unmeasured; the examples below validate arithmetic without provider calls.
When to Activate
Use for repeated API requests that share authorized instructions, tools or reference material. First identify the exact provider endpoint, model, service tier and caching mode. Consult its current documentation before selecting rates, minimum prefix length or retention. Caching does not reduce context-window use.
How It Works
Preserve a stable prefix
Keep reusable instructions, tool schemas and examples stable; place changing questions, timestamps and retrieved results after that content where the API allows. Respect the provider's serialization order: Claude uses tools, system, then messages. Matching prefixes need identical content, including tool schemas and relevant request settings. A changed prefix can prevent reuse from that point. A dynamic suffix may itself be cached later if reused unchanged.
Reusable prefix: approved tools, instructions, stable examples/reference
Changing suffix: current question, fresh retrieval results, request metadata
Choose only relevant context. Padding prompts or broadening access just to meet an eligibility threshold needs its own cost and quality justification.
Preserve user and workspace boundaries
Authorize content access before cache lookup or reuse. Scope application-managed cache handles and accounting keys to the approved user, workspace, provider account, model and content revision. Share only material explicitly approved for that scope. A cache key is a routing/accounting hint, not an authorization gate or a sandbox. Provider cache isolation does not replace application access checks. Invalidate application references when permissions or content change; follow provider retention/deletion controls. Avoid logging private prompt contents. Context selection, capabilities, sandbox enforcement and evidence remain independent of cache optimization.
Provider Requirements and Usage Evidence
The linked documentation is authoritative; endpoint and SDK versions can expose different usage field names. Record that version alongside counters.
| Provider | Requirements to verify | Counters to record |
|---|---|---|
| OpenAI | Model-specific automatic/explicit modes, minimum length, retention and write/read prices; earlier and newer models differ | Responses usage.input_tokens_details.cached_tokens and, when present, cache_write_tokens; input and output totals. Chat Completions uses prompt_tokens_details.cached_tokens |
| Claude | Supported platform, model minimum, cache_control support and TTL; cache writes may cost more than ordinary input |
input_tokens, cache_creation_input_tokens, cache_read_input_tokens, output_tokens; split writes by TTL when rates differ |
| Gemini | Model minimum and API: Interactions supports implicit caching; explicit cache objects require GenerateContent | Interactions usage.total_cached_tokens; GenerateContent usage_metadata cache/input/output counters plus explicit-cache token count and retained duration |
Use OpenAI's prompt caching guide and pricing for the selected model. For Chat Completions, check the usage schema. Derive ordinary input from the total minus cached reads and any separately reported writes; do not count the same tokens twice.
Use Claude's prompt caching guide
for current model/platform limits and TTL rates. Its input_tokens counts
ordinary input separately from cache reads and writes. A short prefix can produce
zero cache counters even when marked for caching. Do not assume every Claude
model or hosted platform uses the same minimum or read price.
Use Gemini's caching guide, GenerateContent caching guide and pricing. Explicit-cache
…
FAQ
What is 'cache'?
Cache is like a temporary memory where the AI stores answers to questions that have already been asked. If the question is the same, it uses the stored answer instead of calculating everything again.
Does this work for any AI?
It works for some specific AIs, like OpenAI and Claude. You need to check the documentation for each one to know how to set it up.
Does caching reduce the context window size?
No, caching does not reduce the AI's context window usage. It just helps reuse information to make the process faster and cheaper.
Details
Original description by the author
Optimize LLM prompt caching hit rate to reduce API costs and improve latency. Analyzes prompt structure, identifies cacheable vs non-cacheable content, and recommends restructuring to maximize cache reuse. TRIGGER when: user says "prompt cache", "cache hit rate", "reduce LLM cost", "optimize token usage", "cheaper LLM calls", or asks about prompt caching strategies for OpenAI/Anthropic/other provi
repo: affaan-m/ECC
Popularity
- GitHub stars
- 280k
- Ranking position
- #261
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
accessibility
Helps your agent create interfaces that everyone can use. Ensures websites and apps work well for people with disabilities, like those who are blind or have reduced mobility.
affaan-m/ECC
agent-architecture-audit
Makes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
affaan-m/ECC
agent-eval
Helps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
affaan-m/ECC
agent-harness-construction
Makes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
affaan-m/ECC
Similar skills
enhance-prompt
Improves text prompts with design details and technical vocabulary. It's useful for getting more accurate and clear visual results.
nexu-io/open-design
advanced-evaluation
Helps your agent create evaluations for AI models. It defines criteria and compares results to measure response quality.
sickn33/agentic-awesome-skills
ai-prompt-regression-testing
Lets your agent test changes to AI prompts. It compares results and checks if alterations caused unwanted regressions.
sickn33/agentic-awesome-skills