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-caching-ttlgit 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-ttl)<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/prompt-caching-ttl"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/prompt-caching-ttl/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-ttl"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/prompt-caching-ttl.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.00112 | $0.01667 |
| Opus 5 | $0.00056 | $0.00834 |
| Sonnet 5 | $0.00022 | $0.00333 |
| Haiku 4.5 | $0.00011 | $0.00167 |
Grade A, and why
prompt-caching-ttl 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 7d 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 — 178 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Prompt Caching — 5min & 1h TTL
Prompt caching reuses already-processed prefixes. Cache reads cost ~10% of fresh input. For apps with large repeated context, this is the single biggest lever on your bill.
When to Use
- Large system prompts reused across many requests
- Long documents/codebases with many follow-up questions
- Multi-turn conversations with growing history
- Tool/function definitions shared across sessions
- Any call where > 1024 tokens would be repeated (2048 for Haiku)
Two TTLs
| TTL | Use case | Cost of cache write |
|---|---|---|
| 5 min (ephemeral) | Conversation, active session, interactive tools | ~1.25× input |
| 1 hour | System prompts, knowledge bases, codebases | ~2× input |
Cache reads are ~0.1× input cost regardless of TTL. The only difference is how long the cache persists and what the write costs.
Rule: use 1h when the cache lives across sessions or independent users; use 5min for in-session reuse.
Basic Usage
const response = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 4096,
system: [
{ type: "text", text: "You are a helpful assistant." },
{
type: "text",
text: giantCodebase,
cache_control: { type: "ephemeral", ttl: "1h" },
},
],
messages: [{ role: "user", content: "Where is auth handled?" }],
});
console.log(response.usage);
// { input_tokens: 120, cache_creation_input_tokens: 450000, cache_read_input_tokens: 0, output_tokens: 200 }
Next call within 1h:
{ input_tokens: 120, cache_creation_input_tokens: 0, cache_read_input_tokens: 450000, output_tokens: 180 }
Cache Breakpoints
You can place up to 4 cache breakpoints per request. Everything up to a breakpoint is cached as a prefix. Typical pattern:
const response = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 4096,
system: [
{ type: "text", text: systemPrompt, cache_control: { type: "ephemeral", ttl: "1h" } },
],
tools: [
// all tool definitions
{ ...lastTool, cache_control: { type: "ephemeral", ttl: "1h" } }, // breakpoint at end of tools
],
messages: [
{ role: "user", content: "Long context document..." },
{
role: "assistant",
content: [{ type: "text", text: "Understood.", cache_control: { type: "ephemeral", ttl: "5m" } }],
},
{ role: "user", content: "Current question." }, // NOT cached — this changes every call
],
});
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.
- 7d ago First seen · 178 lines · 112 tokens per session scan A 3c2f65d4feef
prompt-caching-ttl is a skill published in the GitHub repository latestaiagents/agent-skills (5 stars, last pushed 4mo ago), licensed MIT. It adds 112 tokens to every session and 1,667 once invoked, about $0.0006 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-09-03.
Other skills, from other repositories
fw-review
Full Freshworks marketplace app review — iparams, frontend, serverless, FDK, security, and structured text report output — in one skill.
ai-account-research-sales-card
A sales-growth assistant for understanding why a customer is not moving a deal forward. It uses the information you provide to organize the situation and recommend actions.
ai-account-research
A customer-research assistant for breaking down a potential customer and deciding how to approach them. It uses the materials you provide to shape a sales plan.
ai-amazon-brand-analytics
An Amazon Brand Analytics assistant for working with Amazon brand-analysis tasks. The description does not provide enough detail about its exact data or outputs.
ai-amazon-international-listings
An Amazon localization assistant for checking whether a product listing is written correctly for an overseas market. Localization means adapting language and presentation to a specific country or region.
ai-amazon-inventory-management
An Amazon inventory-review assistant. Inventory means the products a seller has available to sell.