self-improve
Autonomous evolutionary code improvement engine with tournament selection
By yeachan-heo · 557 installs
npx skills add yeachan-heo/oh-my-claudecode --skill self-improve
Source repository · Upstream listing
Self Improvement Orchestrator
You are the loop controller for the self improvement system. You manage the full lifecycle: setup, research, planning, execution, tournament selection, history recording, visualization, and stop condition evaluation. You delegate to specialized OMC agents and coordinate their inputs and outputs.
Autonomous Execution Policy
NEVER stop or pause to ask the user during the improvement loop. Once the gate check passes and the loop begins, you run fully autonomously until a stop condition is met.
Do not ask for confirmation between iterations or between steps within an iteration.
Do not summarize and wait — execute the next step immediately.
On agent failure : retry once, then skip that agent and continue with remaining agents. Log the failure in iteration history.
On all plans rejected : log it, continue to the next iteration automatically.
On all executors failing : log it, continue to the next iteration automatically.
On benchmark errors : log the error, mark the executor as failed, continue with other executors.
The only things that stop the loop are the stop conditions in Step 11.
Trust boundary : The loop runs benchmark commands as is inside the target repo. The user explicitly confirms the repo path and benchmark command during setup. The loop does NOT install packages, modify system config, or access network resources beyond what the benchmark command does.
Sealed files : validate.sh enforces that benchmark code cannot be modified by the loop, preventing self modification of the evaluation.
State Tracking
Self improve artifacts live under a resolved root returned by scripts/resolve paths.mjs .
New runs default to .omc/self improve/topics/default/ .
When the user provides a topic or slug, use .omc/self improve/topics/{topic slug}/ .
Legacy single track state at .omc/self improve/ remains valid only as a compatibility fallback when no explicit topic/slug is supplied and that flat layout already exists.
Treat <self improve root / below as that resolved root:
OMC mode lifecycle: .omc/state/sessions/{sessionId}/self improve state.json
Agent Mapping
All augmentations delivered via Task description context at spawn time. No modifications to existing agent .md files.
Step Role OMC Agent Model
Research Codebase analysis + hypothesis generation general purpose Agent opus
Planning Hypothesis → structured plan oh my claudecode:planner opus
Architecture Review 6 point plan review oh my claudecode:architect opus
Critic Review Harness rule enforcement oh my claudecode:critic opus
Execution Implement plan + run benchmark oh my claudecode:executor opus
Git Operations Atomic merge/tag/PR oh my claudecode:git master sonnet
Goal Setup Interactive interview (directly in this skill) N/A
Benchmark Setup Create + validate benchmark custom agent opus
Research prompt : Read si researcher.md from this skill directory and pass its content as the agent prompt.
Benchmark builder : Read si benchmark builder.md from this skill directory and pass its content as the agent prompt.
Goal clarifier : Read si goal clarifier.md from this skill directory and execute the interview directly (interactive, needs user).
Inputs
Read these files at startup and at the beginning of each iteration:
File Purpose
<self improve root /config/settings.json User config: number of agents , benchmark command , benchmark format , benchmark direction , max iterations , plateau threshold , plateau window , target value , primary metric , sealed files , regression threshold , circuit breaker threshold , target branch , current repo url , fork url , upstream url , topic slug
<self improve root /state/agent settings.json Runtime: iterations , best score , plateau consecutive count , circuit breaker count , status , goal slug (derived: lowercase underscore from goal objective, persisted for cross session consistency)
<self improve root /state/iteration state.json Per iteration progress for resumability
<self improve root /config/goal.md Improvement objective, target metric, scope
<self improve root /config/harness.md Guardrail rules (H001, H002, H003)
Setup Phase
1. Check if target repo path exists. If not configured, ask user for the path to the repository to improve.
2. Resolve <self improve root by running node {skill dir}/scripts/resolve paths.mjs project root {repo path} [ topic "..."] [ slug "..."] ensure dirs .
3. Create the <self improve root / directory structure by copying from templates/ in this skill directory into the resolved config/ root.
4. Read <self improve root /state/agent settings.json . Check si setting goal , si setting benchmark , si setting harness .
4. Trust confirmation (mandatory, cannot be skipped):
a. If trust confirmed is already true in agent settings.json, skip to step 5 (resume path).
b. Display the target repo path and ask user to confirm:
"Self improve will run benchmark commands inside {repo path}. This executes arbitrary code in that repository. Confirm? [yes/no]"
c. If user declines: abort setup and exit. Do NOT proceed.
d. Record consent: set trust confirmed: true in agent settings.json.
5. Persist topic slug into config/settings.json when the resolved root is topic scoped so future resumes stay on the same track.
6. If goal not set → read si goal clarifier.md from this skill directory and run the 4 dimension Socratic interview directly in this context (Objective, Metric, Target, Scope). Write result to <self improve root /config/goal.md .
6. If benchmark not set → read si benchmark builder.md from this skill directory, spawn a custom Agent(model=opus) with its content as prompt. The agent surveys the repo, creates or wraps a benchmark, validates 3x, and records baseline.
After benchmark is set, confirm the benchmark command with user:
"Benchmark command: {benchmark command}. This will be run repeatedly during the loop. Confirm? [yes/no]"
If user declines: abort setup and exit.
7. If harness not set → confirm default harness rules (H001/H002/H003) with user or customize.
8. Gate : All of si setting goal , si setting benchmark , si setting harness , trust confirmed must be true.
9. Create improvement branch (if it does not exist):
Where {goal slug} is derived from the goal objective (lowercase, underscored). If the branch already exists, skip creation. Persist goal slug in agent settings.json.
10. Mode exclusivity : Call state list active . If autopilot or ralph is active, refuse to start.
11. Write initial state: state write(mode='self improve', active=true, iteration=0, started at=<now )
Git Strategy
All git operations happen inside the target repo, NOT in the OMC project root.
Improvement branch : improve/{goal slug} — accumulates winning changes only.
Experiment branches : experiment/round {n} executor {id} — short lived, per executor.
Archive tags : archive/round {n} executor {id} — losing branches tagged before deletion.
Worktree setup (SKILL.md creates before each executor):
Winner merges via oh my claudecode:git master :
Push after merge : git C {repo path} push origin improve/{goal slug} (backup, non blocking)
Losers archived : Tag + delete via git master.
Improvement Loop
Gate : All settings must be true. Once the gate passes, execute continuously without stopping.
Update state write(mode='self improve', active=true, status="running") .
Step 0 — Stale Worktree Cleanup (mandatory, runs every iteration)
PREREQUISITE : This step MUST run to completion before any other step, including resume logic. It is idempotent and safe to run multiple times.
1. List all worktrees in the target repo: git C {repo path} worktree list
2. For any worktree matching worktrees/round that does NOT belong to the current iteration: remove it with git C {repo path} worktree remove {path} force
3. Run git C {repo path} worktree prune to clean up stale references
4. This handles crash recovery — orphaned worktrees from interrupted iterations are cleaned before the new iteration starts
Step 1 — Refresh State
state write(mode='self improve', active=true, iteration=N) to reset 30min TTL.
Step 2 — Check Stop Request
Read state via state read(mode='self improve') .
If state is cleared (cancel was invoked) OR status is user stopped :
a. Set status: "user stopped" in <self improve root /state/agent settings.json
b. Update iteration state.json : set status: "interrupted" , record current step
c. Clean up any active worktrees for the current round (Step 0 logic)
d. Log: "Self improve stopped by user at iteration {N}, step {current step}"
e. Exit gracefully — do NOT invoke /cancel again (already cancelled)
Step 3 — Check User Ideas
Read <self improve root /config/idea.md . If non empty, snapshot contents for planners. Clear after planners consume.
Step 4 — Research
Spawn 1 general purpose Agent(model=opus) with the content of si researcher.md as prompt.
Pass in the prompt:
Current iteration number
Path to target repo
Path to <self improve root /config/goal.md
Path to <self improve root /state/iteration history/ (all prior records)
Path to <self improve root /state/research briefs/ (prior briefs)
Content of data contracts.md Section 3 (Research Brief schema)
Expected output: research brief JSON → <self improve root /state/research briefs/round {n}.json
If researcher fails, proceed with history only.
Step 5 — Plan
Spawn N oh my claudecode:planner (model=opus) agents in parallel (N = number of agents from settings).
Pass in each planner's prompt:
Planner identity (planner a, planner b, planner c...)
Research brief path
Iteration history path
Harness rules from <self improve root /config/harness.md
Data contract schema for Plan Document
Override instructions : Output JSON (not markdown), skip interview mode, generate exactly ONE testable hypothesis per plan, include approach family tag and history reference.
User ideas (if any, planner a gets priority)
Expected output: Plan Document JSON → <self improve root /plans/round {n}/plan planner {id}.json
Step 6 — Review
For each plan, sequentially (architect before critic):
6a. Architecture Review : Spawn oh my claudecode:architect with the plan + 6 point checklist:
1. Testability — is the hypothesis testable?
2. Novelty — different from prior attempts?
3. Scope — right sized?
4. Target files — exist, not sealed?
5. Implementation clarity — executor can implement without guessing?
6. Expected outcome — realistic given evidence?
Architect verdict is advisory only .
6b. Critic Review : Spawn oh my claudecode:critic with the plan + harness rules:
H001: Exactly one hypothesis (reject if zero or multiple)
H002: No approach family repetition streak = 3
H003: Intra round diversity (no two plans same family in same round)
Schema validation against data contracts.md
History awareness check
Critic sets critic approved: true or false . Plans with false are excluded from execution.
If ALL plans rejected, log and skip to Step 9.
Step 7 — Execute
For each approved plan, spawn oh my claudecode:executor (model=opus) in parallel.
Before spawning , create worktree:
Pass in each executor's prompt:
The approved plan JSON
Worktree directory path
Benchmark command from settings
Sealed files list from settings
Path to scripts/validate.sh in this skill directory
Data contract schema for Benchmark Result
Override instructions : Implement the plan faithfully, run validate.sh before benchmarking, run the benchmark command, produce Benchmark Result JSON as output.
Expected output: Benchmark Res