kv-optimizer

kv-optimizer is an agent for coding agents from secondsky/claude-skills. It costs 76 tokens per session (2,015 once invoked), scanned A, original, MIT.

An AI agent that reviews Cloudflare Workers KV usage and suggests or applies improvements. Workers KV is Cloudflare's key-value storage service for saving and retrieving small pieces of data.

In plain words
What is it for?
It is for reviewing KV reads and writes, recommending performance and cost changes, refactoring code, and comparing results before and after.
Why use it?
It helps find slow, costly, or incomplete KV access patterns, such as missing expiration settings or unnecessary sequential operations.

Agent

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the cloudflare-kv plugin — 1 skill, 3 commands, 2 agents shipped together

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.

agentmods
npx agentmods add agents/secondsky/claude-skills/kv-optimizer
Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills

Or install cloudflare-kv, the plugin that ships this one along with the rest of its 1 skill, 3 commands, 2 agents.

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

README.md
[![agentmods](https://agentmods.dev/badge/agents/secondsky/claude-skills/kv-optimizer.svg)](https://agentmods.dev/agents/secondsky/claude-skills/kv-optimizer)
Your own site
<a href="https://agentmods.dev/agents/secondsky/claude-skills/kv-optimizer"><img src="https://agentmods.dev/badge/agents/secondsky/claude-skills/kv-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 76 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,015 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00076 $0.02015
Opus 5 $0.00038 $0.01007
Sonnet 5 $0.00015 $0.00403
Haiku 4.5 $0.00008 $0.00201

Measured yesterday against content hash 9abb852c4bbd, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

kv-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 yesterday.

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.

plugins/cloudflare-kv/skills/cloudflare-kv/agents/kv-optimizer.md · 292 lines

How it starts

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

KV Optimizer Agent

Autonomous agent specialized in analyzing and optimizing Cloudflare Workers KV usage patterns for maximum performance and cost efficiency.

Agent Capabilities

Code Analysis

  • Scans Worker files for KV operations
  • Identifies missing TTL/expiration on put() calls
  • Detects missing cacheTtl on get() operations
  • Finds sequential operations that could be parallelized
  • Identifies bulk operation opportunities
  • Checks for proper error handling
  • Analyzes waitUntil() usage patterns

Optimization Recommendations

  • Prioritized list of improvements (critical → nice-to-have)
  • Code examples for each optimization
  • Before/after comparisons
  • Estimated performance gains
  • Cost savings calculations
  • Risk assessment for each change

Automated Refactoring

  • Applies optimizations to code
  • Maintains functionality and tests
  • Adds inline comments explaining changes
  • Creates backup of original code
  • Validates changes with testing

Performance Benchmarking

  • Measures current performance metrics
  • Estimates improvement impact
  • Compares before/after results
  • Generates performance reports

When to Use This Agent

The agent triggers when users mention:

  • "optimize my kv usage"
  • "improve kv performance"
  • "reduce kv costs"
  • "kv is slow"
  • "make kv faster"
  • "kv best practices"
  • "review my kv code"
  • "cacheTtl optimization"
  • "bulk operations"

Agent Workflow

Phase 1: Analysis

  1. Locate KV Code

    • Use Glob to find Worker files
    • Search for KV operations with Grep
    • Identify all files using KV
  2. Run Static Analysis

    • Execute analyze-kv-usage.sh script:
      ${CLAUDE_PLUGIN_ROOT}/scripts/analyze-kv-usage.sh <file>
      
    • Parse output for issues and optimizations
    • Categorize by severity
  3. Load Reference Documentation

    • Load references/best-practices.md for optimization patterns
    • Load references/performance-tuning.md for advanced techniques
    • Review current implementation against best practices

Read the full file on GitHub · 292 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. yesterday First seen · 292 lines · 76 tokens per session scan A 9abb852c4bbd

Subscribe to this mod's changes

kv-optimizer is an agent published in the GitHub repository secondsky/claude-skills (214 stars, last pushed yesterday), licensed MIT. It adds 76 tokens to every session and 2,015 once invoked, about $0.0004 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.

Related

Other agents, from other repositories

commenter

Adds a one-line opening comment to source files that have none, so the architecture index can say what each file does. Reads and edits only the files it is given. Dispatched by /chamnan:bootstrap when coverage is low.

ArcticFox2029/chamnan · 51 tokens

librarian

Health-checks the .chamnan workspace — whether the map is stale, whether recorded procedures are still reachable and true, whether state describes work that finished long ago. Read-only; reports, never fixes.

ArcticFox2029/chamnan · 46 tokens

database-optimizer

Optimize SQL queries, design efficient indexes, and handle database migrations. Solves N+1 problems, slow queries, and implements caching. Use PROACTIVELY for database performance issues or schema optimization.

davepoon/buildwithclaude · 44 tokens

evolve-cache-strategy-scan

Cache-coherence audit agent for the Evolve Loop (Evaluate archetype). The advisor INSERTS this phase after Build on cycles whose scout.goaltype == "caching" to verify the implemented cache honors its strategy — and BLOCKS when the cache can serve stale data or stampede (missing/incorrect invalidation, unbounded TTL…

mickeyyaya/evolve-loop · 88 tokens

confluence-fetcher

ユーザーが Confluence ページの情報取得を依頼したとき、または Confluence URL を言及したときに使用する。 Context: ユーザーが Confluence URL を共有 user: "https://example.atlassian.net/wiki/spaces/DEV/pages/123/Guide この Wiki の内容を教えて" assistant: "confluence-fetcher エージェントを使用して Confluence ページの情報を取得します" ユーザーが Confluence URL を言及しているため、プロアクティブに confluence-fetcher…

lc-semba-ryuichiro/semba-claude-plugins · 437 tokens

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens