self-evolve-codex_KM
Use when the user asks Codex to set or run a goal for iterative self-improvement, skill improvement, prompt optimization, eval-driven refinement, plateau-based loops, or bounded autonomous runs such a
SKILL.mdskills/agentic/self-evolve-codex_KM/SKILL.md
GitHubSelf-Evolve Codex
Use this when the user wants Codex to improve a skill, prompt, plugin, or agent workflow through repeated measured attempts instead of one manual rewrite.
The core pattern is autoresearch for Codex skills: define one editable target, one metric suite, one run log, and one stopping rule. Codex should try focused changes, benchmark each attempt, keep winners, discard losers, and stop at the agreed goal, plateau, budget, or safety boundary.
First Read
Load only what you need:
references/loop-contract.mdfor the run protocol, safety boundaries, and/goalintegration.references/metrics-and-plateau.mdwhen defining metrics, scoring, plateau rules, or benchmark artifacts.references/source-notes.mdwhen you need the rationale from plugin-eval, self-evolve-skills, autoresearch, or Codex docs.templates/GOAL.mdwhen drafting a user-visible/goalobjective.templates/RUNLOG.mdwhen starting a durable run folder.
When To Use A Goal
If the user asks for goal, /goal, a maximum number of runs, a timebox, "until plateau", "keep going", or "benchmark results", treat the task as a goal-driven loop.
If a goal tool is available in this environment, create one with the concrete improvement objective before editing. If only the CLI slash command is available, draft a /goal ... command or GOAL.md file the user can launch. Either way, write the same objective to the run folder so it survives compaction.
Setup
Before changing the target:
Identify the target file or folder and the canonical source path.
Create a run root outside the live target, usually:
~/.codex/evolution-runs/self-evolve-codex/YYYYMMDD-HHMMSS/<target-name>/Snapshot the original into
original/.Write
GOAL.md,RUNLOG.md,metrics.jsonl, andDECISIONS.mdfrom the templates.Run the baseline benchmark before the first edit.
Do not edit live Skillshare or plugin source until the baseline is recorded and the run contract is written.
Improvement Loop
For each iteration:
- Inspect the latest benchmark failures and artifacts.
- Make one focused change to the candidate copy.
- Run the metric command or plugin-eval analysis.
- Record scores, token/runtime data when available, and a short change note in
metrics.jsonlandRUNLOG.md. - Keep the candidate only if it improves the primary metric, fixes an auto-reject issue, or preserves score while materially reducing complexity.
- Stop when the goal is met, the run hits max iterations/time, plateau is detected, or further progress needs user/product judgment.
Prefer plugin-eval for Codex skill structure checks:
plugin-eval analyze <skill-path> --brief-out <run-root>/brief.json
For skills, use $skill-creator principles: compact SKILL.md, heavy details in references/, deterministic helpers in scripts/, and trigger evals in evals/.
For GPT/Codex prompt text, use $gpt-prompt-architect: outcome-first instructions, explicit success criteria, evidence rules, stopping rules, and no personality padding.
Safety Boundaries
Keep experiments reversible:
- Work in a candidate copy unless the user explicitly asked for live edits.
- Do not change eval scripts, metric definitions, or benchmark fixtures mid-run unless the run log records why and preserves the prior metric.
- Do not publish, push, sync Skillshare, or overwrite canonical source until final review passes.
- Do not chase unbounded improvement. A bounded loop is the product.
Finalize
When the loop stops:
- Compare original versus finalist.
- Apply only approved hunks to the canonical target.
- Re-run the benchmark and any structural validator.
- If the target is a Skillshare skill, run the relevant
skillsharevalidation/sync command and report exactly what changed. - Mark the active goal complete only after the requested artifacts, metrics, and validation are done.
Final report: name the target, run root, best score, iteration count, stop reason, files changed, validation commands, and remaining risks.