prompt-caching

prompt-caching is a skill for Claude Code, Codex from orlando-japan/claude-code-setting. It costs 30 tokens per session (1,139 once invoked), scanned A, original, MIT.

A guide for using Claude API prompt caching, which reuses repeated parts of requests such as instructions, tool definitions, or long documents.

In plain words
What is it for?
Use it when building or tuning a production feature that sends repeated Claude API requests. It covers cache breakpoints, cache lifetime, request patterns, and minimum cache sizes.
Why use it?
It helps reduce waiting and API costs when many requests share the same beginning. It also explains when caching will not help, such as one-off requests or traffic spaced too far apart.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when building or tuning a production feature that sends repeated Claude API requests. It covers cache breakpoints, cache lifetime, request patterns, and minimum cache sizes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/orlando-japan/claude-code-setting/prompt-caching
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add orlando-japan/claude-code-setting --skill prompt-caching
Clone the repo
git clone --depth 1 https://github.com/orlando-japan/claude-code-setting

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for prompt-caching

README.md
[![agentmods](https://agentmods.dev/badge/skills/orlando-japan/claude-code-setting/prompt-caching/github.svg)](https://agentmods.dev/skills/orlando-japan/claude-code-setting/prompt-caching)
Your own site
<a href="https://agentmods.dev/skills/orlando-japan/claude-code-setting/prompt-caching"><img src="https://agentmods.dev/badge/skills/orlando-japan/claude-code-setting/prompt-caching/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for prompt-caching

Your own site · 80×15
<a href="https://agentmods.dev/skills/orlando-japan/claude-code-setting/prompt-caching"><img src="https://agentmods.dev/badge/skills/orlando-japan/claude-code-setting/prompt-caching.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,139 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00030 $0.01139
Opus 5 $0.00015 $0.00570
Sonnet 5 $0.00006 $0.00228
Haiku 4.5 $0.00003 $0.00114

Measured 9d ago against content hash 70e7a53a2876, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

prompt-caching scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

templates/extra/skills/prompt-caching/SKILL.md · 133 lines

How it starts

The opening of the file, as written. The whole thing — 133 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Prompt caching (Claude API)

Claude's prompt caching reduces repeated-prefix cost by up to 90% and can cut latency significantly. It also has a 5-minute TTL on the default cache tier — if you're not hitting within 5 minutes, the cache entry is gone. Design for this.

When caching helps

Caching helps when:

  • You make many requests with overlapping prefixes (system prompt, tools definitions, long documents).
  • Requests are frequent enough to hit within the TTL.
  • The cacheable content is ≥1024 tokens (Sonnet/Opus) or ≥2048 (Haiku) — smaller caches don't pay off.

Caching doesn't help when:

  • Each request is one-shot with a totally unique prompt.
  • The prompt content varies above the cache boundary.
  • Traffic is too sparse to hit the TTL window.

How it works (at a high level)

You mark the end of cacheable content with a cache_control breakpoint:

messages = [
  {
    "role": "user",
    "content": [
      {
        "type": "text",
        "text": "<long document or system instructions>",
        "cache_control": {"type": "ephemeral"}
      },
      {
        "type": "text",
        "text": "<the per-request query>"
      }
    ]
  }
]

Everything up to and including the marked block is cached. Anything after is the variable part.

On a cache hit, you pay a reduced rate for the cached tokens and normal rate for new tokens. On a miss, the first request incurs a cache-write cost (higher than normal), and subsequent requests within 5 minutes hit.

Design rules

1. Order content by stability

Put the most stable content first, least stable last.

Good:

[stable system prompt]
[stable tool definitions]
[stable shared context]
<cache breakpoint>
[variable per-request query]

Bad:

[variable per-request query]
[stable system prompt]
<cache breakpoint>

The variable part at the top breaks the cache on every call.

2. Use up to 4 breakpoints

Claude supports multiple cache breakpoints. Use them to cache at multiple layers:

Read the full file on GitHub · 133 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 133 lines · 30 tokens per session scan A 70e7a53a2876

Subscribe to this mod's changes

prompt-caching is a skill published in the GitHub repository orlando-japan/claude-code-setting (2 stars, last pushed 3mo ago), licensed MIT. It adds 30 tokens to every session and 1,139 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.