agent-optimize

A free-form optimization loop in which the coding agent proposes, tests, and evaluates changes to an agent-orchestration capability.

In plain words
What is it for?
Use it in agent orchestration mode to inspect a project, create a baseline, edit capability files, run screening and full validation, and decide when to stop.
Why use it?
It provides a controlled way to search for improvements while keeping run data, validation results, and a final test record.

Skill for Claude CodeCodex

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 skills/skillberry-ai/cap-evolve/agent-optimize
Any agent
npx skills add skillberry-ai/cap-evolve --skill agent-optimize
Clone the repo
git clone --depth 1 https://github.com/skillberry-ai/cap-evolve

Made for: Claude Code, Codex.

Per session 73 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,133 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.00073 $0.05133
Opus 5 $0.00036 $0.02567
Sonnet 5 $0.00015 $0.01027
Haiku 4.5 $0.00007 $0.00513

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

Security

Grade A, and why

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

The scan reads SKILL.md. This mod also ships 18 executable files (scripts/_bootstrap.py, scripts/abstract.py, scripts/check.py, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skills/algorithms/agent-optimize/SKILL.md · 312 lines

How it starts

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

agent-optimize — the free-form loop you own

The one algorithm with no deterministic subprocess and no per-iteration optimizer: you — the agent that ran intake — are the optimizer, the scheduler and the stopping rule. cap-evolve run (with orchestration_mode: agent) does check → baseline, prints a handoff with the run_dir, and returns. From there the search is yours, bounded by the invariants core enforces and the project's free-text stop_condition. Drive the existing primitives, so the run dir and dashboard stay populated as in a deterministic run.

Shell variables used below

R="<run_dir from the agent-mode handoff>"      # e.g. .capevolve/run_20250101_120000
P="<project dir>"                              # the dir holding capevolve.yaml + adapters/
S="${CAPEVOLVE_SKILLS_DIR:?set CAPEVOLVE_SKILLS_DIR to the skills/ dir}"
A="$S/algorithms/agent-optimize/scripts"       # this skill's helpers
mkdir -p "$R/work"                             # working copies live here (RunDir does NOT create it)

Every script imports _bootstrap itself (no PYTHONPATH) and prints JSON on stdout.

Phase 0 — understand before you optimize

Once, before any edit, and ask the user any blocking question here so the loop then runs unattended. Read PROJECT.md, capevolve.yaml, the adapter and every file under capability_path, and understand what one evaluation does: what a task is, what run_target produces, what score() rewards, and what the per-task feedback says — that is your learning signal. Note the val/test sizes, num_trials, gate_mode/gate_k_se and the allowed edit surface.

Then let spend.py parse the free-text stop_condition rather than restating it from memory: it prints constraints.predicates, every concrete check it could extract, with its measured actual. If constraints.ambiguous is non-empty, ASK THE USER before the loop starts — a vague clause ("don't spend too much", a bare number with no unit) is reported, never guessed at, and this is the one moment where asking is cheap.

Read the full file on GitHub · 312 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 · 312 lines · 73 tokens per session scan A 82d1e212f4ef

Subscribe to this mod's changes

agent-optimize is a skill published in the GitHub repository skillberry-ai/cap-evolve (47 stars, last pushed 2d ago), licensed Apache-2.0. It adds 73 tokens to every session and 5,133 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-08-30.