Run optimizer
Skill skillberry-ai/cap-evolve/skills/optimizers/run-optimizer
Drives any shell-invokable coding agent (Claude Code, Codex, Gemini CLI, opencode, Cursor, Factory Droid, GitHub Copilot CLI, Kimi, Pi, Antigravity, OpenClaw, IBM Bob, or a fully custom command) as the edit proposer in a cap-evolve run, resolving the named optimizer from optimizers/registry.yaml. Use this as the optimizer for every run; pick the concrete agent with --name (or optimizer_skill in the spec). Use --name mock for a deterministic, zero-API proposer in tests and CI.From its SKILL.md
npx -y skills add skillberry-ai/cap-evolve --skill run-optimizerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- reads credentialsReads from 3 credential sources: `CAPEVOLVE_OPTIMIZER_CMD` and 2 more.
- runs commandsInstructs the agent to run 4 commands, including `python scripts/run.py --list` and 3 more.
SKILL.md
5.3 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it
run-optimizer — one runner, a registry of agents
An optimizer is the agent that reads the current capability + the failure
diagnosis and proposes an edit. Every such agent follows the same contract: given
a working directory (a copy of the parent candidate) and an INSTRUCTIONS.md,
edit the files in place. Because the contract is identical, one runner serves them
all — the only thing that varies per agent is the shell command, which lives as a
row in optimizers/registry.yaml. Adding an optimizer is one YAML row, not a
new skill directory.
How it works
- The loop calls
run.py --name <optimizer> --workdir <copy> --prompt INSTRUCTIONS.md. - The runner reads the registry, resolves the row, and expands its
command_template(placeholders below) into argv. - It runs that command with
cwd = workdir, so the agent edits the candidate files directly. Output is summarized as JSON (returncode,auth_present,stdout_tail).
Template placeholders
| placeholder | expands to |
|---|---|
{workdir} | the candidate working copy (also the cwd) |
{prompt} | path to INSTRUCTIONS.md |
{prompt_text} | the contents of INSTRUCTIONS.md (for CLIs that take the prompt inline) |
{model} | the resolved model id; an empty {model} drops itself and a preceding -m/--model |
{self_dir} | the runner's own scripts dir (used by the mock row) |
${VAR} | environment expansion (the generic/openclaw/antigravity escape hatches read their command from env) |
Choosing an optimizer (--name / optimizer_skill)
mock, generic, claude-code, codex, gemini-cli, opencode, cursor,
droid (Factory Droid), copilot (GitHub Copilot CLI), kimi, pi,
antigravity, openclaw, ibm-bob. Per-CLI install / auth / flag details are in
references/<name>.md.
mockis fully offline (runs a shipped JSON-driven editor, never a network CLI), so the end-to-end proof slice costs nothing and never flakes.generic/openclaw/antigravityread their command fromCAPEVOLVE_OPTIMIZER_CMD/CAPEVOLVE_OPENCLAW_CMD/CAPEVOLVE_ANTIGRAVITY_CMD— the escape hatch that makes "any optimizer" literal. (antigravityis a wrapper because its auth is Google-Sign-In-only and its headless approve flag is unconfirmed.)cursor,droid,copilot,kimi,piare verified headless commands; matches the agent set supported by obra/superpowers.
Standalone use
# list known optimizers
python scripts/run.py --list
# drive one agent over a candidate dir
python scripts/run.py --name claude-code --workdir ./cand --prompt ./cand/INSTRUCTIONS.md --model claude-opus-4-6
In a run, the orchestrator builds this command for you from the spec's
optimizer_skill (the optimizer NAME) and optimizer_model.
Headless JSON cost capture (optional, best-effort)
Coding-agent CLIs can emit a structured result that carries the exact spend.
Pass --json (or set CAPEVOLVE_OPTIMIZER_JSON=1) and the runner appends the
registry row's json_flag to the command, then parses total_cost_usd
(and token usage) out of the output:
python scripts/run.py --name claude-code --json \
--workdir ./cand --prompt ./cand/INSTRUCTIONS.md --model claude-opus-4-6
# -> {... "cost": {"total_cost_usd": 0.0123, "tokens": 4210}}
Per CLI (verify with <cli> --help):
- claude-code —
json_flag: --output-format json; the JSON result hastotal_cost_usd,usage, and per-model cost undermodelUsage. Add--json-schema '<JSONSchema>'(via--json-schemahere, orCAPEVOLVE_OPTIMIZER_JSON_SCHEMA) to also get.structured_outputfor a decision step. The runner only appends--json-schemawhen the row's json_flag contains--output-format. - codex —
json_flag: --json(a JSONL stream); pair withcodex exec --json --output-last-message <file>when you want the final message on disk. The runner parses the last JSON line for cost/usage. - gemini-cli —
json_flag: --output-format json;total_cost_usd/usageare parsed when present.
This is strictly additive. With no --json, or for a row whose json_flag is
empty (mock, generic, opencode, openclaw, ibm-bob), nothing changes —
the optimizer runs prose-fed exactly as before, and mock stays fully offline. If
the output isn't parseable JSON, cost.total_cost_usd is null and the loop
continues without a cost figure (never an error).
Back-compat
A spec that still names an old per-CLI optimizer skill (claude-code, ibm-bob,
…) resolves to the registry row of the same name, so existing specs keep working
without edits.
References
references/<name>.md— install, auth, and flags for each CLI.
What ships with it: 20 files
52.9 KB alongside SKILL.md, 5 of them executable
references/
- antigravity.md1.7 KB
- claude-code.md11.2 KB
- codex.md1.8 KB
- copilot.md1.5 KB
- cursor.md1.5 KB
- droid.md1.4 KB
- gemini-cli.md1.9 KB
- generic.md456 B
- ibm-bob.md1.9 KB
- kimi.md1.6 KB
- mock.md582 B
- openclaw.md1.4 KB
- opencode.md1.8 KB
- pi.md1.6 KB
scripts/
- abstract.pyruns1.1 KB
- _bootstrap.pyruns1.3 KB
- check.pyruns2.9 KB
- _mock_apply.pyruns2.9 KB
- run.pyruns13.9 KB
- meta.yaml366 B
Gives 0 of the 12 instructions most context ai engineering skills give in ~1.3k tokens
Counted across 1,328 of the 2,349 authors here whose files we hold, read 2026-09-06
- Dispatch a fresh subagent for each taskin 76 of 1328, across 59 files
- Perform spec compliance review before code quality reviewin 44 of 1328, across 34 files
- Dispatch a final code reviewer after all tasksin 38 of 1328, across 26 files
- Answer subagent questions before allowing implementationin 36 of 1328, across 26 files
- Use the least powerful model capable of the taskin 33 of 1328, across 26 files
- Create a TodoWrite list for all tasksin 32 of 1328, across 22 files
- Perform a task review after each implementationin 31 of 1328, across 24 files
- Extract all tasks and context from the planin 29 of 1328, across 20 files
- Provide full task text to subagentsin 28 of 1328, across 20 files
- Use git worktrees for isolated workspacesin 25 of 1328, across 20 files
- Specify the model explicitly when dispatching a subagentin 23 of 1328, across 18 files
- Execute all tasks from the plan without stoppingin 21 of 1328, across 16 files
Said here and by no other author read
- resolve optimizer from registry
- run command in working directory
- relay agent stderr to runner stderr
- use mock for deterministic testing
- pass json flag for cost capture
- parse total cost from json output
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.