prompt-caching-ttl

prompt-caching-ttl is a skill for Claude Code from latestaiagents/agent-skills. It costs 112 tokens per session (1,667 once invoked), scanned A, original, MIT.

A guide to Claude prompt caching, which reuses repeated beginnings of requests such as system instructions, documents, or codebases for a limited time. It covers five-minute and one-hour cache lifetimes.

In plain words
What is it for?
Use it for repeated conversations, shared tool definitions, long documents, large codebases, or system prompts sent across multiple requests.
Why use it?
It helps reduce repeated processing and spending when many requests use the same large context.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the claude-4-6-features plugin — 6 skills shipped together , and of latestaiagents

Good fit Use it for repeated conversations, shared tool definitions, long documents, large codebases, or system prompts sent across multiple requests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/latestaiagents/agent-skills/prompt-caching-ttl
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 latestaiagents/agent-skills --skill prompt-caching-ttl
Clone the repo
git clone --depth 1 https://github.com/latestaiagents/agent-skills

Made for: Claude Code.

Or install claude-4-6-features, the plugin that ships this one along with the rest of its 6 skills.

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-ttl

README.md
[![agentmods](https://agentmods.dev/badge/skills/latestaiagents/agent-skills/prompt-caching-ttl/github.svg)](https://agentmods.dev/skills/latestaiagents/agent-skills/prompt-caching-ttl)
Your own site
<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.

agentmods 80×15 button for prompt-caching-ttl

Your own site · 80×15
<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>
Per session 112 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,667 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.00112 $0.01667
Opus 5 $0.00056 $0.00834
Sonnet 5 $0.00022 $0.00333
Haiku 4.5 $0.00011 $0.00167

Measured 7d ago against content hash 3c2f65d4feef, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

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.

skills/claude-4-6-features/prompt-caching-ttl/SKILL.md · 178 lines

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
  ],
});

Read the full file on GitHub · 178 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. 7d ago First seen · 178 lines · 112 tokens per session scan A 3c2f65d4feef

Subscribe to this mod's changes

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.