debug
Investigation-first debugging — gather evidence, form confirmed root-cause hypothesis, hand off to fix mode with diagnosis file. TRIGGER when: user reports a…
Optimize a measurable metric with bounded iterations, guardrails, and regression gates.
$ npx -y skills add Borda/AI-Rig --skill optimize --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/optimizeContext preview
The summary Claude sees to decide when to auto-load this skill.
Optimize a measurable metric with bounded iterations, guardrails, and regression gates.
name: optimize description: Optimize a measurable metric with bounded iterations, guardrails, and regression gates.
Metric-driven optimization with explicit guards, rollback criteria, experiment log.
{
"goal": "required measurable improvement objective",
"mode": "single|campaign",
"metric_cmd": "required command that emits or validates the target metric",
"metric_direction": "higher|lower",
"guard_cmd": "required command that must continue to pass",
"max_iterations": "optional integer, default 1",
"min_delta": "optional practical significance threshold",
"scope_files": [
"paths the optimization may edit"
],
"done_when": "metric improves without guard regression"
}Run `create_run.py --skill optimize` per `../../shared/helper-cli-contract.md`.
Require:
Dry-run both before edit:
Execute configured `metric_cmd` and `guard_cmd` separately with host-native command runner. Write complete combined output to `<run-directory>/metric-baseline.txt` and `<run-directory>/guard-baseline.txt`; retain both exit codes and stop before editing if either command cannot run.
Write `<run-directory>/hypothesis.md`:
For `campaign`, noisy metrics, GPU/ML performance, or correctness-sensitive code, read and apply `../../shared/specialist-orchestration.md`; otherwise do not load it. Write `<run-directory>/specialist-optimization-plan.md` with narrow context packs for:
No fan-out for one small measured change with stable metric/guard. Never let specialist change metric/guard scripts unless explicitly in `scope_files` and measurement-integrity risk recorded.
**Structural context (optional)**: when `scope_files` resolves to Python module/symbol, select one task-neutral route and probe codemap-py once before first iteration: `python PLUGIN_ROOT/shared/codemap_adapter.py context --category implementation --query-kind <kind> [--target <qname>] --out <run-directory>/codemap-context.json`. Use `skip` for exact localized optimization with no unresolved structural fact, matching single route (`central`, `callers`, `blast`, `dependencies`, `test-impact`, or `coupling`) for one unresolved fact, and `standard` for broad or unknown scope. Map direct, all, or production caller questions to `callers`; use `blast` only for explicitly transitive caller questions. An explicit user or tool request for structural evidence overrides `skip`. Per `../../shared/codemap-contract.md`, absence/incompatibility is non-fatal — continue with hypothesis above. Persist result once here, before step 04 applies any change; any triggered specialist consumes `<run-directory>/codemap-context.json`, never fresh query.
Initialize machine-readable iteration log:
Create empty `<run-directory>/experiments.jsonl` with filesystem tool before first iteration.
One independent hypothesis per iteration. Do not optimize unmeasured paths. Before each, write `<run-directory>/iteration-<n>-before.patch` with scoped-file diff. If iteration fails and only its patch is present, revert with `git apply -R` against iteration diff; otherwise fail run when clean reversal cannot be proven. Never use `git reset --hard`.
Re-run same retained `metric_cmd` and `guard_cmd` separately with host-native command runner. Write complete combined output to `<run-directory>/metric-after.txt` and `<run-directory>/guard-after.txt`; retain both exit codes.
Required fields:
Append one JSON object/iteration to `<run-directory>/experiments.jsonl`:
{
"iteration": 1,
"hypothesis": "one-line mechanism",
"metric_before": 0.0,
"metric_after": 0.0,
"delta": 0.0,
"guard": "pass|fail",
"decision": "kept|reverted|inconclusive|failed",
"rollback_evidence": "path or reason"
}Inspect `python PLUGIN_ROOT/shared/run_gates.py --help`. Tests runs configured test or guard command; give real commands or explicit reasons for other gates.
Follow `../../shared/helper-cli-contract.md` and authoritative help. Write `OPTIMIZE_METADATA`, validate as `optimize`, promote only validated candidate.
1. Missing metric or guard command => fail. 2. Baseline cannot be captured => fail. 3. Scope is unbounded => fail. 4. Guard regression after change => fail unless reverted. 5. Metric/guard script changed without explic
Practical agent workflows for Python, ML, and open-source maintenance. AI-Rig turns recurring work—scoping a change, reproducing a bug, reviewing a pull request, running an experiment, or checking release readiness—into explicit workflows with specialist
Repo: Borda/AI-Rig
Investigation-first debugging — gather evidence, form confirmed root-cause hypothesis, hand off to fix mode with diagnosis file. TRIGGER when: user reports a…
TDD-first feature development — crystallise API as a demo test, drive implementation to pass it, run quality stack and progressive review loop. TRIGGER when:…
Reproduce-first bug resolution — capture bug in failing regression test, apply minimal fix, run quality stack and review loop. TRIGGER when: user reports a…
Analysis-only planning — classify and scope a task without writing code; outputs a structured plan to .plans/active/. TRIGGER when: user wants to understand…
Test-first refactoring — audit coverage, add characterization tests, apply changes with safety net, run quality stack and review loop. TRIGGER when: user wants…
Multi-agent code review of local Python files, directories, or the current git diff covering architecture, tests, performance, docs, lint, security, and API…