Prompt Cache Optimization

Maximize OpenAI prompt-cache hit rate to cut time-to-first-token latency by up to 80% and input token cost by up to 90%: prefix-stability rules, cache-aware prompt layout, prompt_cache_key routing, allowed_tools, Responses API vs Chat Completions, Flex vs Batch, extended 24h caching, and Realtime retention_ratio. Use when designing or reviewing prompt/message layout for any repeated OpenAI API workload, when cached_tokens is low or zero, when TTFT or input spend is high at scale, or when choosing truncation/compaction strategy for long conversations. Scope: models before GPT-5.6 (per the sourc

10 stars 2 forksAI, LLMs & Agents

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add Archive228/lab-skills --skill prompt-cache-optimization
Manual install
git clone --depth 1 https://github.com/Archive228/lab-skills.git /tmp/lab-skills
mkdir -p ~/.claude/skills
cp -r /tmp/lab-skills/skills/prompt-cache-optimization ~/.claude/skills/prompt-cache-optimization

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Prompt Cache Optimization (OpenAI)

Operating procedure for getting maximum prompt-cache hit rate on OpenAI API workloads, distilled from OpenAI's "Prompt Caching 201" cookbook. Applied correctly, caching cuts time-to-first-token (TTFT) latency by up to ~80% and input token cost by up to 90%, with discounts up to 98.75% on some models. Caching is automatic and free — your job is to stop breaking it: stabilize prefixes, route requests stickily, and measure `cached_tokens`.

**Scope note:** the source explicitly applies to models *before* GPT-5.6. For GPT-5.6 and later, consult the current platform Prompt Caching guide before relying on these mechanics.

## When to use

Use this skill when:
- Designing or reviewing prompt/message layout for any repeated OpenAI API call — system prompts, tool definitions, schemas, conversation loops, agents.
- `usage.prompt_tokens_details.cached_tokens` is low or zero on traffic that repeats a prefix.
- TTFT latency or input token spend is a problem at scale (long contexts benefit most: 67% faster TTFT at 150k+ tokens vs 7% at 1024 tokens, measured over 2,300 iterations).
- Choosing between Chat Completions vs Responses API, or Batch vs Flex Processing.
- Setting truncation/compaction policy for long conversations or Realtime (voice) sessions.

Do NOT use when:
- Prompts are under 1024 tokens and cannot reasonably be lengthened — caching never activates below 1024 tokens.
Read the full skill on GitHub

Details

Skill name
prompt-cache-optimization
Path
skills/prompt-cache-optimization/SKILL.md
License
MIT
Repo updated
12 August 2026

FAQ

What does the Prompt Cache Optimization skill do?

Maximize OpenAI prompt-cache hit rate to cut time-to-first-token latency by up to 80% and input token cost by up to 90%: prefix-stability rules, cache-aware prompt layout, prompt_cache_key routing, allowed_tools, Responses API vs Chat Completions, Flex vs Batch, extended 24h caching, and Realtime retention_ratio. Use when designing or reviewing prompt/message layout for any repeated OpenAI API workload, when cached_tokens is low or zero, when TTFT or input spend is high at scale, or when choosing truncation/compaction strategy for long conversations. Scope: models before GPT-5.6 (per the sourc

How do I install the Prompt Cache Optimization skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add Archive228/lab-skills --skill prompt-cache-optimization. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Prompt Cache Optimization popular?

It lives in Archive228/lab-skills, which has 10 GitHub stars and 2 forks.

Related skills

Agent Design Fundamentals

10

Archive228/lab-skills

Decision rules for whether to build an LLM agent and how to architect it, distilled from OpenAI's "A Practical Guide to Building Agents": build/no-build criteria, model selection, tool design, single-agent vs multi-agent orchestration (manager pattern vs decentralized handoffs), layered guardrails, and human-in-the-loop triggers. Use when designing, reviewing, or refactoring an agent system — before choosing an architecture, adding more agents, defining tools, or shipping an agent to production without guardrails.

AI, LLMs & Agents

Agent Evals

10

Archive228/lab-skills

Build and maintain evaluation suites for AI agents: bootstrap 20-50 tasks from real failures, pick code-based vs model-based vs human graders by agent architecture (coding, conversational, research, computer-use), write unambiguous tasks with reference solutions, and keep suites alive via ownership and transcript reading. Use when creating evals from zero, adding graders or eval cases, debugging suspicious eval scores, or deciding pass@k vs pass^k metrics for an agent product.

AI, LLMs & Agents

Agent Failure Preflight

10

Archive228/lab-skills

Pre-deployment failure-mode gate for agentic AI systems, distilled from Microsoft AI Red Team's Taxonomy of Failure Modes in Agentic AI Systems v2.0 (grounded in 12 months of red-team engagements). Run it before shipping or materially changing an agent — adding tools/MCP servers/plugins, enabling persistent memory, adding sub-agents or orchestration, enabling computer use, or expanding permissions — to verify concrete controls against memory poisoning, HitL bypass, goal hijacking, supply-chain compromise, session context contamination, capability disclosure, and multi-agent cascade failures.

AI, LLMs & Agents

Prompt Engineering Canon

10

Archive228/lab-skills

Canonical prompt-engineering operating procedure distilled from Google's 68-page Prompt Engineering whitepaper (Lee Boonstra, Feb 2025): when to use zero/few-shot, system/contextual/role prompting, chain-of-thought, step-back, self-consistency, ToT, ReAct, output-format control, and exact temperature/top-K/top-P starting values. Trigger whenever writing, reviewing, or debugging a prompt for an LLM, choosing sampling configuration, or deciding which prompting technique fits a task.

AI, LLMs & Agents

Planner Evaluator Harness

10

Archive228/lab-skills

Multi-agent harness pattern (planner / generator / evaluator) for long-running application builds, distilled from Anthropic's engineering post on harness design. Use when a build will run for hours or sits beyond what the current model ships reliably solo: covers sprint contracts, skeptical-evaluator calibration, hard-threshold QA grading via browser automation, context resets vs compaction, and how to strip the harness down as models improve.

AI, LLMs & Agents

Reverse Engineer Js

9

vladmdgolam/agent-skills

Reverse-engineer minified or obfuscated JavaScript bundles. Primary tool: humanify (humanifyjs) — uses an LLM to rename mangled identifiers back to meaningful names. Default model: gemini-3.8-flash. Use when the user says 'deobfuscate this bundle', 'humanify this', 'rename minified vars', 'reverse engineer this JS', 'what does bundle.js do', or is working in a project with a deobfuscated `og/` or `modules/` folder fed by humanify. Covers humanify CLI invocation, the pseudo-TTY workaround for cursorTo crashes, single-module extraction from a bundle, and chaining with beautifiers.

AI, LLMs & Agents

Browse the most popular Claude skills, all ai, llms & agents skills, or write your own with the skills generator.