kv-cache-prefix-optimizer

kv-cache-prefix-optimizer is a skill for Cursor from roedyrustam/vibes-plug. It costs 102 tokens per session (2,535 once invoked), scanned A, original, MIT.

A guide to structuring repeated parts of AI prompts for prompt-cache reuse. A prompt is the instruction and context sent to an AI model; caching can avoid repeatedly processing unchanged parts.

In plain words
What is it for?
Use it when building long-running AI agents or other applications with repeated prompts and large amounts of recurring context.
Why use it?
Unstable prompt structure can reduce cache reuse and increase request cost or delay. The guide covers consistent prefixes, tool ordering, data formatting, and separating changing context from stable context.

Skill for Cursor

Written for Cursor: shipped in a Cursor plugin.

Part of the vibes-plug plugin — 176 skills, 9 agents, 2 MCP servers shipped together

Good fit Use it when building long-running AI agents or other applications with repeated prompts and large amounts of recurring context.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/roedyrustam/vibes-plug/kv-cache-prefix-optimizer
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 roedyrustam/vibes-plug --skill kv-cache-prefix-optimizer
Clone the repo
git clone --depth 1 https://github.com/roedyrustam/vibes-plug

Made for: Cursor.

Or install vibes-plug, the plugin that ships this one along with the rest of its 176 skills, 9 agents, 2 MCP servers.

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 kv-cache-prefix-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/roedyrustam/vibes-plug/kv-cache-prefix-optimizer/github.svg)](https://agentmods.dev/skills/roedyrustam/vibes-plug/kv-cache-prefix-optimizer)
Your own site
<a href="https://agentmods.dev/skills/roedyrustam/vibes-plug/kv-cache-prefix-optimizer"><img src="https://agentmods.dev/badge/skills/roedyrustam/vibes-plug/kv-cache-prefix-optimizer/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 kv-cache-prefix-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/skills/roedyrustam/vibes-plug/kv-cache-prefix-optimizer"><img src="https://agentmods.dev/badge/skills/roedyrustam/vibes-plug/kv-cache-prefix-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 102 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,535 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.00102 $0.02535
Opus 5.5 $0.00041 $0.01014
Sonnet 5.5 $0.00020 $0.00507
Haiku 4.5 $0.00010 $0.00253

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

Security

Grade A, and why

kv-cache-prefix-optimizer 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 3d 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.

.cursor/skills/kv-cache-prefix-optimizer/SKILL.md · 199 lines

How it starts

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

kv-cache-prefix-optimizer — vibes-plug Skill

English | Bahasa Indonesia


English

Orchestration & Integration

  • Upstream & Orchestration: zero-to-prod-orchestrator (Phase 4 AI agent integration), brainstorming, session-memory-manager.
  • Frontier LLM & Model Caching: frontier-ai-models-expert (Gemini 4 Pro, Claude 5.5, GPT Astra 6 caching specs), gemini-agent-booster (Google 2M+ native context caching), vercel-ai-sdk-expert (provider cache controls).
  • FinOps & Adaptive Execution: llm-finops-router (cost calculation & cache routing), adaptive-model-cascade (cascade tier prefixing), thinking-budget-orchestrator (prefix pinning with thinking tokens).
  • Prompt Engineering & Context Windows: ai-prompt-engineering-expert (prompt canonicalization), context-window-engineer (large context sliding windows).

Description

Production guide for engineering deterministic prompt prefixes, stabilizing KV-cache boundaries, and optimizing context reuse across frontier models (Google Gemini 4 Pro / 3.x context caching, Anthropic Claude 5.5 prompt caching, and OpenAI prefix caching). Delivers architectures that guarantee 90%+ cache hit rates through canonical tool definition sorting, stable JSON serialization, and dynamic context partitioning.

Trigger Conditions

Activate this skill when:

  • Operating large-context agents (>100k tokens) where recurring prompt costs dominate operational budgets.
  • Experiencing high Time-to-First-Token (TTFT) latencies in interactive chat or agentic coding loops.
  • Configuring model caching primitives (cache_control: { type: 'ephemeral' } or Gemini explicit cache tokens).
  • Architecting system instructions, tool schemas, and workspace context maps for multi-turn sessions.

Core Concepts & Patterns

1. The Anatomy of a High-Cache Prompt

Modern frontier models utilize prefix-matching algorithms. Even a single changed byte (such as a timestamp, random ID, or altered tool order) invalidates all subsequent cached tokens:

Read the full file on GitHub · 199 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. 3d ago Changed · -22 lines 04499bff4d7a
  2. 4d ago Changed · +1 lines a2356cd4e359
  3. 7d ago Changed e707aa10a24f
  4. 16d ago Changed bd5ea1e30573
  5. 21d ago First seen · 220 lines · 102 tokens per session scan A 3cae90ad5691

Subscribe to this mod's changes

kv-cache-prefix-optimizer is a skill published in the GitHub repository roedyrustam/vibes-plug (113 stars, last pushed today), licensed MIT. It adds 102 tokens to every session and 2,535 once invoked, about $0.0004 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-10-04.