cpv-batch-caching-optimize

A batch command for checking and applying prompt-cache invalidation fixes across plugins. Prompt-cache invalidation means preventing old cached instructions from being reused after relevant content changes.

In plain words
What is it for?
Use it with a marketplace, plugin list, local path, or GitHub URL to audit, fix, and re-check each plugin's cache-related issues.
Why use it?
It removes the need to run the cache-fix workflow manually for every plugin in a marketplace or list.

Command

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 commands/emasoft/claude-plugins-validation/cpv-batch-caching-optimize
Clone the repo
git clone --depth 1 https://github.com/Emasoft/claude-plugins-validation
Per session 121 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,783 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.00121 $0.01783
Opus 5 $0.00060 $0.00892
Sonnet 5 $0.00024 $0.00357
Haiku 4.5 $0.00012 $0.00178

Measured 2d ago against content hash 53996167b967, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cpv-batch-caching-optimize 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 2d 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.

commands/cpv-batch-caching-optimize.md · 182 lines

How it starts

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

/cpv-batch-caching-optimize — Apply cache-invalidation fixes across many plugins

For users who maintain a marketplace and want to apply the cache-invalidation pattern fixes (CA-01..CA-07) across every plugin in one pass, this command fans out one cpv-cache-optimizer-agent per plugin in batch_fix mode. Each agent runs Phase 1 (Audit) → Phase 2 (Fix) → Phase 3 (Re-validate) on its assigned plugin and writes its result back as the per-plugin status JSON.

Phase 4 (Broader cache-aware refactor) is deliberately skipped in batch mode: Phase 4 changes require interactive per-step approval and that doesn't compose with a parallel dispatch (each agent would block waiting for the orchestrator's permission). Run the interactive cache flow from /cpv-main-menu (menu-tree §3.3.3 "Audit + broader refactoring") on a single plugin if you want Phase 4.

Same input grammar as the rest of the batch family.

You are the orchestrator

You — the model running THIS turn — drive the batch. You do NOT optimize anything yourself.

Step 0 — Resolve arguments

If no target was given, ask plain-text:

Which marketplace, plugin, or list should I cache-optimize? Provide a path, URL, or @listfile.

Step 1 — Build the batch plan

BATCH_SPEC="$1"
MAX_PARALLEL=8

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/cpv_batch_orchestrator.py" plan \
  "$BATCH_SPEC" \
  --agent cpv-cache-optimizer-agent \
  --mode batch_fix \
  --max-parallel "$MAX_PARALLEL"

Capture the orchestrator's stdout (PLAN, STATUS_TABLE, SESSION_DIR, PLUGIN_COUNT, DISPATCH_GROUPS). Queue the initial status table for the claude-menu-system Stop hook (emitted post-turn via systemMessage — zero token cost, NEVER printed inline by the orchestrator):

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/print_menu.py" "$STATUS_TABLE"

NEVER print menu inline; the CMS Stop hook emits via systemMessage at turn end.

Step 2 — Dispatch optimize agents in parallel

for plugin_index in group:
    plugin = plan.plugins[plugin_index]
    Agent(
      subagent_type: "cpv-cache-optimizer-agent",
      description: "Batch-cache-optimize {plugin.display_name}",
      prompt: |
        <context>
        source: /cpv-batch-caching-optimize
        mode: batch_fix
        plugin_index: {plugin.plugin_index}
        plugin_path: {plugin.abs_path}
        source_url: {plugin.source_url or "—"}
        display_name: {plugin.display_name}
        session_dir: {plan.session_dir}
        status_path: {plan.session_dir}/plugin-{plugin.plugin_index}.status.json
        </context>

        Run Phase 1 (Audit) → Phase 2 (Fix) → Phase 3 (Re-validate)
        on your standard cache workflow. SKIP Phase 4 (Broader
        refactor) — batch mode does not allow per-step user
        prompts. Write per-plugin status JSON to `status_path` with:

          {
            "status_symbol": "✓" | "✗" | "⚠",
            "status_label": "clean" | "fixed" | "partial" | "failed",
            "before": {"critical": N, "major": N, "minor": N, "nit": N, "warning": N},
            "after":  {"critical": N, "major": N, "minor": N, "nit": N, "warning": N},
            "report_path": "<abs-path-to-final-cache-report>",
            "notes": "<short summary, e.g. fixed 5/5, 0 remaining>"
          }

        Return ONE line exactly:

          [plugin-{plugin.plugin_index}] {label}: fixed=X remaining=Y (status: {status_path})

        Do NOT render menus. Do NOT prompt the user for Phase 4 —
        this is non-interactive batch mode.
      run_in_background: false
    )

Read the full file on GitHub · 182 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. 2d ago First seen · 182 lines · 121 tokens per session scan A 53996167b967

Subscribe to this mod's changes

cpv-batch-caching-optimize is a command published in the GitHub repository Emasoft/claude-plugins-validation (4 stars, last pushed 4d ago), licensed MIT. It adds 121 tokens to every session and 1,783 once invoked, about $0.0006 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-08-31.