spec-optimize

spec-optimize is a command for Claude Code from ronronner02/codepilot-agent. It costs 6 tokens per session (10,961 once invoked), scanned A, original, MIT.

A command for running repeated optimization cycles guided by measured results.

In plain words
What is it for?
Use it when improving a product or system through repeated, measurement-based iterations.
Why use it?
It helps compare changes using metrics instead of relying only on subjective judgment.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: mentions subagents; names the AskUserQuestion tool; mentions Claude Code.

Good fit Use it when improving a product or system through repeated, measurement-based iterations.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/ronronner02/codepilot-agent/spec-optimize
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.

Clone the repo
git clone --depth 1 https://github.com/ronronner02/codepilot-agent

Made for: Claude Code.

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 spec-optimize

README.md
[![agentmods](https://agentmods.dev/badge/commands/ronronner02/codepilot-agent/spec-optimize/github.svg)](https://agentmods.dev/commands/ronronner02/codepilot-agent/spec-optimize)
Your own site
<a href="https://agentmods.dev/commands/ronronner02/codepilot-agent/spec-optimize"><img src="https://agentmods.dev/badge/commands/ronronner02/codepilot-agent/spec-optimize/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 spec-optimize

Your own site · 80×15
<a href="https://agentmods.dev/commands/ronronner02/codepilot-agent/spec-optimize"><img src="https://agentmods.dev/badge/commands/ronronner02/codepilot-agent/spec-optimize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 6 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 10,961 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.00006 $0.10961
Opus 5.5 $0.00002 $0.04384
Sonnet 5.5 $0.00001 $0.02192
Haiku 4.5 $0.00001 $0.01096

Measured 1mo ago against content hash 7bf61aa52da1, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

spec-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 1mo 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.

.claude/commands/spec-optimize.md · 775 lines

How it starts

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

Command support root: .claude/spec-first/workflows/spec-optimize. Treat it as the loaded skill directory whenever this inlined workflow refers to SKILL_DIR or the directory containing SKILL.md.

Iterative Optimization Loop

Run metric-driven iterative optimization. Define a goal, build measurement scaffolding, then run parallel experiments that converge toward the best solution.

Workflow Contract Summary

When To Use

Use when a measurable outcome can improve through iterative experiments, hard gates, and/or LLM-as-judge scoring.

When Not To Use

Do not use for ordinary implementation, vague improvement requests without a metric, debugging without a feedback loop, or unbounded spend/concurrency.

Inputs

An optimization spec or goal, mutable/immutable scope, measurement command or scaffold plan, budget limits, experiment settings, repository instructions, and baseline evidence.

Outputs

A measurement scaffold and experiment log, scored experiment results, kept/rejected variants, final integrated changes when appropriate, and post-run recommendations.

Artifacts

Run state under .spec-first/workflows/spec-optimize/<spec-name>/, experiment worktrees/results, strategy digests, and no hidden workflow state outside the documented log.

Failure Modes

Missing metric, missing measurement command, unsafe scope, excessive or uncapped budget, failed baseline, write verification failure, or unavailable dispatch/worktree backend.

Workflow

Validate the spec and budget, establish the baseline, run bounded experiments, measure and write results immediately, select winners, integrate only verified improvements, and summarize evidence.

Downstream Consumers

Code review、benchmark maintainer、在性能/相关性变更时参与的 release reviewer,以及检查 experiment logs 的人工审查者。

Scenario Capability

Follows docs/contracts/workflows/scenario-capability-matrix.md (default). Overrides: none

Interaction Method

Use the platform's blocking question tool: AskUserQuestion in Claude Code (call ToolSearch with select:AskUserQuestion first if its schema isn't loaded) or request_user_input in Codex. Fall back to numbered options in chat only when no blocking tool exists in the harness or the call errors (e.g., Codex edit modes) — not because a schema load is required. Never silently skip the question.

Read the full file on GitHub · 775 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. 1mo ago First seen · 775 lines · 6 tokens per session scan A 7bf61aa52da1

Subscribe to this mod's changes

spec-optimize is a command published in the GitHub repository ronronner02/codepilot-agent (0 stars, last pushed 1mo ago), licensed MIT. It adds 6 tokens to every session and 10,961 once invoked, about $0.0000 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-08-31.