prompt-caching-patterns

prompt-caching-patterns is a skill for Claude Code from softspark/ai-toolkit. It costs 43 tokens per session (1,000 once invoked), scanned A, original, Apache-2.0.

A guided process for restructuring code while preserving its existing behaviour.

In plain words
What is it for?
Use it to extract functions or components, rename or move code, simplify logic, or remove unnecessary abstractions.
Why use it?
It makes cleanup safer by requiring a plan, tests before and after changes, small commits, and approval before execution.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the ai-toolkit plugin — 115 skills, 44 agents, 14 hooks shipped together

Good fit Use it to extract functions or components, rename or move code, simplify logic, or remove unnecessary abstractions.

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

Made for: Claude Code.

Or install ai-toolkit, the plugin that ships this one along with the rest of its 115 skills, 44 agents, 14 hooks.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/softspark/ai-toolkit/prompt-caching-patterns/github.svg)](https://agentmods.dev/skills/softspark/ai-toolkit/prompt-caching-patterns)
Your own site
<a href="https://agentmods.dev/skills/softspark/ai-toolkit/prompt-caching-patterns"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/prompt-caching-patterns/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-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/softspark/ai-toolkit/prompt-caching-patterns"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/prompt-caching-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,000 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00043 $0.01000
Opus 5.5 $0.00017 $0.00400
Sonnet 5.5 $0.00009 $0.00200
Haiku 4.5 $0.00004 $0.00100

Measured 14d ago against content hash 4c9d288c59f6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

prompt-caching-patterns 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 14d 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.

app/skills/prompt-caching-patterns/SKILL.md · 121 lines

How it starts

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

Prompt Caching Patterns

Cache repeated prefixes when reuse offsets write costs. Cache eligibility and pricing depend on the model and platform; a short system prompt is not cached merely because it repeats.

Dated cache reference (2026-10-08)

Model Minimum eligible prefix Cache read / base input price
Claude Opus 5.5 512 tokens 5%
Claude Fable 5.1 512 tokens 2.5%
Claude Sonnet 5.5 512 tokens 5%
Claude Haiku 5.5 512 tokens 10%

For the Claude API, a five-minute write costs 1.25 times base input and a one-hour write costs 2 times base input. Recheck current pricing before budgeting; provider-specific billing and model availability can differ.

Prefix design

Cache order is tools → system → messages, regardless of the order of request keys. An explicit breakpoint includes the marked block and everything before it. Keep dynamic material after the stable prefix.

[ tool definitions              ] breakpoint 1
[ reusable system instructions  ] breakpoint 2
[ reference documents           ] breakpoint 3
[ stable conversation prefix    ] breakpoint 4
[ current variable content      ]

There are at most four breakpoints. Top-level automatic cache_control moves a breakpoint to the last eligible block and consumes one slot. Explicit markers give control over a static prefix.

Explicit caching example

The caller supplies the approved model, text and output limit. Marking a prefix below its model's minimum silently produces no cache entry.

def cached_answer(client, model, policy, document, question, max_tokens):
    return client.messages.create(
        model=model,
        max_tokens=max_tokens,
        system=[{
            "type": "text",
            "text": policy,
            "cache_control": {"type": "ephemeral"},
        }],
        messages=[{
            "role": "user",
            "content": [
                {"type": "text", "text": document,
                 "cache_control": {"type": "ephemeral"}},
                {"type": "text", "text": question},
            ],
        }],
    )

Read the full file on GitHub · 121 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. 14d ago Changed 4c9d288c59f6
  2. 29d ago Changed · +6 lines 6414970dc975
  3. 1mo ago First seen · 115 lines · 43 tokens per session scan A 9c9caf4f3149

Subscribe to this mod's changes

prompt-caching-patterns is a skill published in the GitHub repository softspark/ai-toolkit (180 stars, last pushed 8d ago), licensed Apache-2.0. It adds 43 tokens to every session and 1,000 once invoked, about $0.0002 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-09-03.