Skip to content
Skills Library
AI & agents · Automation

run-optimizer

/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.

Repository
cap-evolve ↗
Licence
Apache-2.0
Last repository change
25.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
21
Scripts
5
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 25.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What to check before installing
  • 5 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/_bootstrap.py, scripts/_mock_apply.py, scripts/abstract.py, scripts/check.py, scripts/run.py

What it does and when to use it

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.

Arguments

/run-optimizer --name NAME --workdir DIR --prompt FILE [--model ID]
Original author description

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.

How it works

  1. How it works
  2. Choosing an optimizer (--name / optimizerskill)
  3. Standalone use
  4. Headless JSON cost capture (optional, best-effort)
  5. Back-compat
  6. References
Original SKILL.md headings · 105 lines, 743 words
SKILL.md preview
---
name: run-optimizer
description: 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.
component: optimizer
argument-hint: "--name NAME --workdir DIR --prompt FILE [--model ID]"
allowed-tools: Read, Write, Bash
provides: [candidate]
needs: []
---

# 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

1. The loop calls `run.py --name <optimizer> --workdir <copy> --prompt INSTRUCTIONS.md`.
2. The runner reads the registry, resolves the row, and expands its
   `command_template` (placeholders below) into argv.
3. 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`).
4. Streams: **stdout is exactly one JSON object**; the agent CLI's **stderr is
   relayed** to the runner's stderr on success as well as failure, so a CLI that
   prints a diagnostic and exits 0 is not silently successful.
5. `--prompt` must name an **existing** file — the caller resolves the path. A
   missing one is an error (exit 2), never an empty prompt: the `{prompt_text}` rows
   would otherwise bill a real agent CLI to run with no instructions at all.

### 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`.

- **`mock`** is 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`** / **`antigravity`** read their command from
  `CAPEVOLVE_OPTIMIZER_CMD` / `CAPEVOLVE_OPENCLAW_CMD` / `CAPEVOLVE_ANTIGRAVITY_CMD`
  — the escape hatch that makes "any optimizer" literal. (`antigravity` is a wrapper
  because its auth is Google-Sign-In-only and its headless approve flag is unconfirmed.)
- **`cursor`**, **`droid`**, **`copilot`**, **`kimi`**, **`pi`** are verified
  headless commands; matches the agent set supported by obra/superpowers.

## Standalone use

```bash
# 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:

```bash
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 has
  `total_cost_usd`, `usage`, and per-model cost under `modelUsage`. Add
  `--json-schema '<JSONSchema>'` (via `--json-schema` here, or
  `CAPEVOLVE_OPTIMIZER_JSON_SCHEMA`) to also get `.structured_output` for a
  decision step. The runner only appends `--json-schema` when the row's json_flag
  contains `--output-format`.
- **codex** — `json_flag: --json` (a JSONL stream); pair with
  `codex 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`/`usage` are
  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.
Files in this package (21)
  • SKILL.md 6 KB
  • meta.yaml 1 KB
  • references/antigravity.md 2 KB
  • references/claude-code.md 11 KB
  • references/codex.md 2 KB
  • references/copilot.md 1 KB
  • references/cursor.md 2 KB
  • references/droid.md 1 KB
  • references/gemini-cli.md 2 KB
  • references/generic.md 1 KB
  • references/ibm-bob.md 2 KB
  • references/kimi.md 2 KB
  • references/mock.md 1 KB
  • references/openclaw.md 1 KB
  • references/opencode.md 2 KB
  • references/pi.md 2 KB
  • scripts/_bootstrap.py 4 KB
  • scripts/_mock_apply.py 4 KB
  • scripts/abstract.py 1 KB
  • scripts/check.py 3 KB
  • scripts/run.py 26 KB

Versions

The database has no other skills named run-optimizer.

Database snapshot: 13.11.2026 · package version a2ba95f133e8 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95agents-cli
    Run and manage many AI coding agents (Claude Code, Codex, Cursor, Gemini/Antigravity, Grok, Kimi, OpenCode, Droid, …) from one CLI — the `agents` command. Use this to run multiple coding agents in parallel, manage multiple Claude Code accounts, keep working when I hit my usage…
  • 100dev-swarm-install-ai-code-agent
    Install AI code agent CLI tools including claude-code, gemini-cli, codex, and github copilot-cli. Use when setting up AI coding assistants or when the user asks to install an AI code agent.
  • 100harness-compile
    Use when user invokes /harness-compile or wants to compile a harness.yaml into native config files for Claude Code, Cursor, GitHub Copilot, Codex, OpenCode, Windsurf, Gemini CLI, or JetBrains Junie. Generates CLAUDE.md, AGENT.md, .mcp.json, .cursor/rules/, .vscode/mcp.json,…
  • 100create-subagent
    Create a user-scoped subagent for every installed agent (Claude Code, opencode, Cursor, Copilot, Codex, Antigravity) from one merged definition, then install and run the doctor on it. Use when the user asks to create a subagent, add a custom agent, delegate a role to a…
  • 100agenttrace-session-audit
    Audit local AI coding-agent sessions with agenttrace. Use when the user asks to inspect Claude Code, Codex CLI, Qwen Code, Cline, Aider, Cursor exports, Hermes Agent, OpenCode, OpenClaw, Pi, Oh My Pi, Kimi CLI, Copilot-style logs, or generic JSON/JSONL traces for cost, tokens,…
  • 90scaffolding
    Use when generating project structure for new bundle-plugins, adding or removing platform support (Claude Code, Cursor, Codex, OpenCode, Gemini CLI, OpenClaw), updating platform manifests, or migrating hooks and configuration between platforms

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.