self-evolve

A self-improvement workflow for the coding agent. It reviews past sessions to find recurring failures, makes one targeted code improvement, tests it, and rebuilds the agent.

In plain words
What is it for?
Analyzing session logs, tracing recurring agent errors to their source, and applying and verifying a focused fix.
Why use it?
It addresses repeated problems in patching, tool arguments, schemas, prompt handling, or agent loops instead of treating each failure separately.

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/fortunto2/rust-code/self-evolve
Any agent
npx skills add fortunto2/rust-code --skill self-evolve
Clone the repo
git clone --depth 1 https://github.com/fortunto2/rust-code

Made for: Claude Code, Codex.

Per session 71 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 569 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.00071 $0.00569
Opus 5 $0.00036 $0.00284
Sonnet 5 $0.00014 $0.00114
Haiku 4.5 $0.00007 $0.00057

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

Security

Grade A, and why

self-evolve 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.

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/self-evolve/SKILL.md · 45 lines

What it actually says

Self-Evolution

Analyze your own performance history and fix recurring issues. ONE improvement per iteration.

Process

  1. Read .rust-code/evolution.jsonl + recent session logs
  2. Find patterns: patch failures, loop warnings, error spikes
  3. Trace to root cause in source code
  4. Apply minimal fix, make check, commit
  5. Signal RESTART_AGENT if you changed agent code

Reference files for diagnosis: references/diagnosis-paths.md

Key Source Files

Symptom Source
Patch matching failures crates/sgr-agent/src/app_tools/apply_patch.rs
Agent stuck in loops crates/sgr-agent/src/loop_detect.rs
Prompt confusion crates/rc-cli/src/agent.rs (SGR_SYSTEM_PROMPT)
Tool argument errors crates/rc-cli/src/agent.rs (execute_action)
Schema issues crates/sgr-agent/src/schema.rs

Signals

  • Fixed something → finish: "RESTART_AGENT — [what you fixed]"
  • Nothing to fix → finish: "<solo:done/>"
  • Stuck → finish: "<solo:done/> — need human input"

Gotchas

  1. RESTART_AGENT kills your context — everything in memory is lost. Commit first, write notes to .tasks/ for the next session to pick up.
  2. Simplicity threshold — a 0.001 score improvement that adds 20 lines of hacky code is NOT worth it. Removing code with equal results is always a win.
  3. make check can take 2+ minutes — don't call it in a tight loop. Run once after your change, fix issues, run once more to verify.
  4. Don't optimize what you can't measure — read actual session logs, grep for error patterns. Don't guess at improvements.
  5. Evolution log is append-only — don't edit evolution.jsonl. The loop engine reads it for scoring trends.
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 · 45 lines · 71 tokens per session scan A 71fb217c5c27

Subscribe to this mod's changes

self-evolve is a skill published in the GitHub repository fortunto2/rust-code (41 stars, last pushed 10d ago), licensed MIT. It adds 71 tokens to every session and 569 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.