Commerce Prompt Caching
anthropics/commerce-agents
The reference agents' cache-stable request assembly, covering the static system and per-request context split, the fixed tool list, the rolling conversation breakpoint, which config fields are…
Anthropic API prompt caching: TTL, breakpoints, stacking, invalidation, hit rate.
$ npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install softspark/ai-toolkit prompt-caching-patterns --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/app/skills/prompt-caching-patterns .claude/skills/prompt-caching-patterns && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "prompt-caching-patterns" agent skill from https://github.com/softspark/ai-toolkit/tree/main/app/skills/prompt-caching-patterns into .claude/skills/prompt-caching-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "prompt-caching-patterns", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/softspark/ai-toolkit/tree/main/app/skills/prompt-caching-patternsType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install softspark/ai-toolkit prompt-caching-patterns --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .agents/skills && cp -r skills-src/app/skills/prompt-caching-patterns .agents/skills/prompt-caching-patterns && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "prompt-caching-patterns" agent skill from https://github.com/softspark/ai-toolkit/tree/main/app/skills/prompt-caching-patterns into .agents/skills/prompt-caching-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "prompt-caching-patterns", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install softspark/ai-toolkit prompt-caching-patterns --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/app/skills/prompt-caching-patterns .cursor/skills/prompt-caching-patterns && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "prompt-caching-patterns" agent skill from https://github.com/softspark/ai-toolkit/tree/main/app/skills/prompt-caching-patterns into .cursor/skills/prompt-caching-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "prompt-caching-patterns", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/softspark/ai-toolkit.git --path app/skills/prompt-caching-patterns--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install softspark/ai-toolkit prompt-caching-patterns --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/app/skills/prompt-caching-patterns .gemini/skills/prompt-caching-patterns && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "prompt-caching-patterns" agent skill from https://github.com/softspark/ai-toolkit/tree/main/app/skills/prompt-caching-patterns into .gemini/skills/prompt-caching-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "prompt-caching-patterns", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install softspark/ai-toolkit prompt-caching-patternsInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .github/skills && cp -r skills-src/app/skills/prompt-caching-patterns .github/skills/prompt-caching-patterns && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "prompt-caching-patterns" agent skill from https://github.com/softspark/ai-toolkit/tree/main/app/skills/prompt-caching-patterns into .github/skills/prompt-caching-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "prompt-caching-patterns", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install softspark/ai-toolkit prompt-caching-patterns --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/app/skills/prompt-caching-patterns .opencode/skills/prompt-caching-patterns && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "prompt-caching-patterns" agent skill from https://github.com/softspark/ai-toolkit/tree/main/app/skills/prompt-caching-patterns into .opencode/skills/prompt-caching-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "prompt-caching-patterns", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
prompt-caching-patternsAnthropic API prompt caching: TTL, breakpoints, stacking, invalidation, hit rate.
Prompt Caching Patterns is an agent skill from softspark/ai-toolkit. Anthropic API prompt caching: TTL, breakpoints, stacking, invalidation, hit rate. Triggers: prompt caching, cachecontrol, cache breakpoint, cache TTL, hit rate.
Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in AI & LLM Engineering, covering LLM cost and token optimization and Responsive design. It works with Anthropic API. The repository describes itself as: Professional-grade AI coding toolkit: 94 skills, 44 agents, multi-platform (Claude, Cursor, Windsurf, Copilot, Gemini, Cline, Roo Code, Aider, Augment, Antigravity, Codex CLI… The licence is Apache-2.0.
Read from SKILL.md and the folder at commit d64db2b. It shows what the files ask for, not the result of running them.
Pre-approves these tools, so the agent can use them without asking each time:
ReadFrom allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are python).
From the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
platform.claude.comFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Prompt Caching Patterns loads about 1.1k tokens when it runs. Until then it costs about 46 tokens; SKILL.md has 414 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from softspark/ai-toolkit at commit d64db2b, republished under its Apache-2.0 licence (© softspark). 414 words, ~1,133 tokens.
.claude/skills/prompt-caching-patterns/SKILL.md (or your agent's skills folder).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.
| 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 | 1024 tokens | 10% |
| Claude Haiku 4.5 | 4096 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.
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.
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},
],
}],
)Use {"type": "ephemeral", "ttl": "1h"} for an approved one-hour write. When mixing
TTLs, put longer-lived breakpoints before shorter-lived ones. Do not send paid
heartbeat requests simply to keep an unused prefix warm.
Changing tools invalidates subsequent system and message prefixes; changing the system invalidates subsequent messages. Top-level effort changes invalidate message cache blocks and can affect earlier blocks depending on the model. Supported per-message effort updates preserve earlier prefixes. Changing the model is not a promise of cross-model cache reuse.
A static string passed as system alone does not enable caching: configure
cache_control at the request or content-block level. Keep tool definitions,
document serialization and stable instructions deterministic.
Include writes when calculating the fraction of input served from cache.
def cache_read_fraction(usage):
read = usage.cache_read_input_tokens or 0
written = usage.cache_creation_input_tokens or 0
uncached = usage.input_tokens or 0
total = read + written + uncached
return read / total if total else 0.0Record write/read counts and actual costs across cold and warm requests. Choose a target from observed reuse; a single universal hit-rate threshold is misleading. Both cache counters remaining zero can indicate an ineligible prefix.
Skip cache writes when no prefix will be reused before expiry or when measured cost exceeds uncached requests. Do not pad prompts with irrelevant content merely to reach a minimum. A one-hour TTL may fit intermittent reuse better than five minutes, within the approved cost policy.
Reviewed 2026-09-23:
Use model-routing-patterns for route evaluation and llm-ops-engineer for
application operations.
© softspark, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in app/skills/prompt-caching-patterns of softspark/ai-toolkit.
Open the folder on GitHubat commit d64db2b
Prompt Caching Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Prompt Caching Patterns this skillsoftspark/ai-toolkit | 179 | — | ~1.1k | Automated safety check: Pass | Apache-2.0 | |
| Commerce Prompt Cachinganthropics/commerce-agents | 3.2k | — | ~2k | Automated safety check: Pass | Apache-2.0 | |
| Prompt CachingArchive228/loopkit | 755 | — | ~735 | Automated safety check: Pass | MIT | |
| Token Optimizationcwinvestments/memstack | 423 | — | ~1.4k | Automated safety check: Pass | Proprietary | |
| Claude API In Prototypesasgeirtj/system_prompts_leaks | 69k | — | ~281 | Automated safety check: Pass | CC0-1.0 | |
| Claude APIkid-sid/claude-spellbook | 189 | — | ~2.7k | Automated safety check: Pass | MIT |
anthropics/commerce-agents
The reference agents' cache-stable request assembly, covering the static system and per-request context split, the fixed tool list, the rolling conversation breakpoint, which config fields are…
Archive228/loopkit
Cache the parts of the prompt that don't change so a long-running loop stops paying full price on every turn.
cwinvestments/memstack
A skill your agent uses when the user says 'token optimization', 'save tokens', 'context window', 'reduce tokens', 'token stack', or 'TokenStack', or asks about extending context window capacity.
asgeirtj/system_prompts_leaks
Call Claude from your HTML artifacts via window.claude.complete
kid-sid/claude-spellbook
A skill your agent uses when building or debugging apps that call the Claude API — implementing tool use, streaming, vision, prompt caching, batch processing, extended thinking, or an agentic loop…
warpdotdev/warp
Guides building, debugging and tuning apps on the Claude API and Anthropic SDK, including prompt caching, and migrating code between Claude model versions.
softspark/ai-toolkit
Prepare or verify a project QA environment with source identity, readiness, browser access, evidence paths and owned cleanup.
softspark/ai-toolkit
Accessibility validator: WCAG 2.1 AA, EN 301 549, EAA. An agent skill from softspark/ai-toolkit.
softspark/ai-toolkit
Analyzes code quality, complexity, patterns across codebase.
softspark/ai-toolkit
Drives a brief, specification, issue or existing PR through implementation, review, tests and QA to a ready PR.
softspark/ai-toolkit
Direct technical voice for docs, README, user-facing text. An agent skill from softspark/ai-toolkit.
softspark/ai-toolkit
Detect/generate/debug CI pipeline config (GitHub Actions, GitLab CI).
Works with
Categories
Anthropic API prompt caching: TTL, breakpoints, stacking, invalidation, hit rate. Prompt Caching Patterns is an agent skill from softspark/ai-toolkit. Anthropic API prompt caching: TTL, breakpoints, stacking, invalidation, hit rate.
Prompt Caching Patterns fits situations like: tasks that involve LLM cost and token optimization; tasks that involve Responsive design.
Run `npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a claude-code`. Or copy the skill folder (app/skills/prompt-caching-patterns in softspark/ai-toolkit) into .claude/skills/prompt-caching-patterns in your project. Claude Code loads it when a task matches its description.
Run `npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a codex`. Or copy the skill folder (app/skills/prompt-caching-patterns in softspark/ai-toolkit) into .agents/skills/prompt-caching-patterns in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add softspark/ai-toolkit --skill prompt-caching-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/prompt-caching-patterns, .gemini/skills/prompt-caching-patterns, .github/skills/prompt-caching-patterns and .opencode/skills/prompt-caching-patterns in your project.
SKILL.md names no scripts, command-line tools or credentials: Prompt Caching Patterns is instructions for the agent only. Our summary lists: Python 3. Its frontmatter pre-approves these tools: Read.
SKILL.md names 1 domain. As links in the text: platform.claude.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Prompt Caching Patterns is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.1k tokens (SKILL.md is roughly 4.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Prompt Caching Patterns: Commerce Prompt Caching (anthropics/commerce-agents, 3.2k stars), Prompt Caching (Archive228/loopkit, 755 stars), Token Optimization (cwinvestments/memstack, 423 stars) and Claude API In Prototypes (asgeirtj/system_prompts_leaks, 69k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
softspark (a GitHub user) maintains it in softspark/ai-toolkit, which has 179 GitHub stars. The repository holds 112 skills in this directory. The repository was last updated on October 7, 2026.
Source: softspark/ai-toolkit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.