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.
npx skills add latestaiagents/agent-skills --skill prompt-cachinggit clone --depth 1 https://github.com/latestaiagents/agent-skillsWrote 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.
[](https://agentmods.dev/skills/latestaiagents/agent-skills/prompt-caching)<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/prompt-caching"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/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.
<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/prompt-caching"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/prompt-caching.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00127 | $0.01416 |
| Opus 5.5 | $0.00051 | $0.00566 |
| Sonnet 5.5 | $0.00025 | $0.00283 |
| Haiku 4.5 | $0.00013 | $0.00142 |
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 26d 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.
How it starts
The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Prompt Caching
Caching is a prefix match. If the bytes before a breakpoint are identical to a recent request, the API reads them from cache at a fraction of the normal input price. Any change earlier in the prefix invalidates everything after it.
When to Use
- Large system prompts or tool lists reused across requests
- Many questions against the same document or codebase
- Multi-turn conversations and agent loops whose history grows
- Any workload where
usage.cache_read_input_tokensis zero but should not be
Workflow
Step 1: Start with automatic caching
Put cache_control at the top level of the request. The API places the breakpoint on the last cacheable block and moves it forward as the conversation grows.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const MODEL = process.env.ANTHROPIC_MODEL!; // a current model ID
const response = await client.messages.create({
model: MODEL,
max_tokens: 4096,
cache_control: { type: "ephemeral" },
system: LARGE_STABLE_SYSTEM_PROMPT,
messages,
});
Step 2: Use explicit breakpoints when layers change at different rates
You can place up to 4 breakpoints per request, on individual blocks.
const response = await client.messages.create({
model: MODEL,
max_tokens: 4096,
tools: TOOLS, // deterministic order
system: [
{ type: "text", text: INSTRUCTIONS },
{ type: "text", text: KNOWLEDGE_BASE, cache_control: { type: "ephemeral", ttl: "1h" } },
],
messages, // conversation can use automatic caching or a moving breakpoint
});
The render order is tools, then system, then messages. Put the most stable content first and anything volatile (timestamps, request IDs, the current question) after the last breakpoint.
Step 3: Choose a TTL
| TTL | Syntax | Write cost (per docs) | Use for |
|---|---|---|---|
| 5 minutes (default) | { type: "ephemeral" } |
1.25x base input | Active conversations, agent loops |
| 1 hour | { type: "ephemeral", ttl: "1h" } |
2x base input | Shared prefixes reused less often than every 5 minutes |
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.
- 26d ago First seen · 126 lines · 127 tokens per session scan A 4de6b53732d5
prompt-caching is a skill published in the GitHub repository latestaiagents/agent-skills (6 stars, last pushed 26d ago), licensed MIT. It adds 127 tokens to every session and 1,416 once invoked, about $0.0005 per session on Opus 5.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-11-04.
prompt-caching compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| prompt-cachinglatestaiagents/agent-skills | Skill | 6 | 26d ago | MIT | A | 127 | Claude Code |
| agent-collective-intelligence-coordinatorruvnet/ruflo | Skill | 83k | today | MIT | A | 29 | Claude Code |
| agent-memory-coordinatorruvnet/ruflo | Skill | 83k | today | MIT | A | 19 | Claude Code |
| nexent-daily-testModelEngine-Group/nexent | Skill | 6.3k | yesterday | MIT | A | 78 | Claude Code, Codex |
| mem0-integrationa5c-ai/babysitter | Skill | 1.9k | 28d ago | MIT | A | 27 | Claude Code |
| langchain-memorya5c-ai/babysitter | Skill | 1.9k | 28d ago | MIT | A | 21 | Claude Code |
| knowledge-graph-managementa5c-ai/babysitter | Skill | 1.9k | 28d ago | MIT | A | 22 | Claude Code |