skills/self-improvement-loops/SKILL.md
This skill should be used when the harness, scaffold, workflow, or optimizer itself is the optimization target: recursive self-improvement (RSI) loops, meta-harnesses, self-improving harnesses that mine their own failures and propose bounded edits, evolutionary or population-based search over agent scaffolds, acceptance gates for self-modifying systems, and agentic context evolution where the mechanism that produces context is versioned and evolved. Route governance of a single autonomous loop (locked surfaces, durable logs, rollback, novelty gates, approval boundaries) to harness-engineering, measurement and quality-gate design to evaluation, judge design to advanced-evaluation, and remote sandbox infrastructure to hosted-agents.
npx skillsauth add muratcankoylan/Agent-Skills-for-Context-Engineering self-improvement-loopsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill covers systems where the harness is the artifact being optimized: an agent mines its own failures and edits its own scaffold, a meta-agent searches over harness code, a population of workflow candidates evolves against an evaluator, or the mechanism that produces context is itself versioned and improved. The design question shifts from "how do I control one loop" (harness-engineering) to "how do I let a loop rewrite parts of itself without corrupting the signal that steers it".
The controlling constraint across every published system: the loop optimizes whatever signal it is given, including the signal's own weaknesses. Design the loop assuming the optimizer will find every gap between the metric and the intent.
Activate this skill when:
Do not activate this skill for adjacent work owned by other skills:
harness-engineering. That skill defines the control surfaces; this skill defines what happens when the surfaces themselves become the optimization target.evaluation.advanced-evaluation.context-optimization.hosted-agents.project-development.Published self-improvement systems target progressively deeper objects:
| Rung | Optimized object | Example systems | | --- | --- | --- | | 1 | Instruction prompts | Promptbreeder, GEPA | | 2 | Structured context | ACE (playbook of itemized bullets) | | 3 | Context mechanism | MCE (the skill that produces context) | | 4 | Workflow graph | ADAS, AFlow | | 5 | Harness code | Self-Harness (bounded self-edits), Meta-Harness, Darwin Godel Machine | | 6 | Optimizer code | STOP (the improver improves the improver) |
Each rung up buys a larger design space and more leverage, and costs more per evaluation with a larger surface for gaming. Fix a recurring failure at the lowest rung that can express the fix. A stale-library failure is a context fix, not a workflow rewrite. Only move up when failure clusters at the current rung persist across candidates.
Recursive structure amplifies base-model quality in both directions. The same recursive improver design that compounds gains with a strong model degrades mean performance across iterations with weaker models (claim-self-improvement-capability-threshold). Two implications:
The evaluator, its instrumentation, permission control, and budget enforcement must live outside the surface the loop can modify. Every documented reward hack broke this invariant: agents removed the logging markers a hallucination detector depended on, and hacking became more frequent when the checking code was visible to the agent (claim-self-improvement-visible-evaluator-hacking). Agents given sight of scoring functions overwrote timing functions and monkey-patched evaluators to return perfect scores (claim-self-improvement-scorer-visibility).
Operational rules:
Accept a self-modification only on measured evidence, using two splits: a held-in split that checks the targeted weakness was resolved, and a held-out split the proposer never sees that checks nothing else regressed. The strictest published gate accepts only when neither split regresses and at least one strictly improves, with repeated evaluation under stochastic scoring; this produced held-out gains across every base model tested (claim-self-improvement-two-split-acceptance). Reject candidates that trade one split against the other even when the sum improves. Log rejected candidates with their evidence so the proposer stops rediscovering them.
Store every candidate as a directory containing its source, scores, and raw execution traces. Let the proposer navigate the archive with search tools (grep-style queries over files) instead of stuffing history into its context window. In direct ablation, a proposer with full raw-trace access materially outperformed both a scores-only proposer and a proposer fed LLM-written summaries of the same traces; summaries recovered none of the lost signal and sometimes hurt (claim-self-improvement-raw-trace-ablation). Do not pre-summarize the archive. Curate access paths, not content.
Evolutionary and RL-style loops collapse toward variants of the current best unless diversity is engineered in. The mechanisms that survived ablation across published systems:
The strongest published pattern for an agent improving its own harness has three stages:
When searching whole harness programs from outside rather than editing a running harness from inside:
Context playbooks that update themselves are the entry-level self-improvement loop, with two named failure modes. Brevity bias: optimizers collapse toward short generic instructions, dropping the domain-specific heuristics that carried the value. Context collapse: letting a model monolithically rewrite accumulated context shrinks it catastrophically in a single step, below the no-adaptation baseline (claim-self-improvement-context-collapse). The working pattern:
One level up, version the mechanism that produces context (the skill: static components plus dynamic operators) separately from the produced context, evolve the mechanism against a validation split only, and warm-start each iteration from the prior best artifact plus its rollout results. Check the train-validation gap explicitly each iteration to catch mechanism overfitting.
Humans move up the stack rather than out of the loop. Reserve for human decision points: changes to the evaluator or acceptance gate, expansion of editable surfaces, promotion of a discovered harness to production, and abandonment decisions for research directions. Models trained mostly on successful outcomes are poorly calibrated on when to abandon a line of work, and preserved negative results are the cheapest way to trim a successor's search space. Make failed candidates first-class artifacts.
Do not enable self-modification until every item holds:
| Recurring failure | Fix at | Loop pattern | | --- | --- | --- | | Missing domain heuristics, repeated known mistakes | Structured context | Itemized playbook with delta updates | | Context playbook itself plateaus across tasks | Context mechanism | Evolve the skill on validation data | | Wrong sequencing, missing verification steps | Workflow | Search over workflow graphs with per-node experience | | Failure clusters persist across workflow candidates | Harness code | Failure-driven bounded self-edits or meta-level search | | Improvement strategy itself is weak | Optimizer code | Only with strong models and locked meta-evaluation |
Example 1: Two-split acceptance gate
def accept(candidate, baseline, held_in, held_out, repeats=3):
d_in = mean_score(candidate, held_in, repeats) - mean_score(baseline, held_in, repeats)
d_out = mean_score(candidate, held_out, repeats) - mean_score(baseline, held_out, repeats)
if d_in < 0 or d_out < 0:
return False # no regression on either split
return max(d_in, d_out) > 0 # strict improvement on at least one
The held-out split is invisible to the proposer. A candidate that gains on held-in by sacrificing held-out is rejected even if the sum is positive.
Example 2: Experience archive layout
search-run/
candidates/
c0041/
harness.py # full candidate source
scores.json # per-split, per-repeat results
traces/ # raw prompts, tool calls, outputs, state updates
lineage.txt # parent id, diff summary, decision, evidence
frontier.json # current Pareto set over (quality, cost)
rejected.jsonl # rejected candidates with reasons, append-only
The proposer greps this tree selectively. Nothing is summarized into its prompt by default.
Example 3: Routing a failure to the right rung
Observed: agent repeatedly uses a deprecated API despite instructions.
Wrong fix: propose a harness-code edit adding retry logic.
Right fix: rung 2. Inject current API docs into task context at
execution time. Training-data defaults override prompt instructions,
so ground the context; do not add machinery.
This skill connects to:
Internal reference:
Related skills in this collection:
External resources:
Numeric, benchmark, volatile, or vendor-performance claims in this skill carry inline claim-* IDs backed by researcher/claims/index.jsonl. Detailed numbers live in the dated reference file.
Created: 2026-07-08 Last Updated: 2026-07-08 Author: Agent Skills for Context Engineering Contributors Version: 1.0.0
development
A comprehensive collection of Agent Skills for context engineering, harness engineering, multi-agent architectures, and production agent systems. Use when building, optimizing, evaluating, or debugging agent systems that require effective context management and reliable operating loops.
development
This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.
data-ai
This skill should be used when designing autonomous agent harnesses: research loops, evaluation scaffolds, locked and editable surfaces, durable logs, novelty gates, pruning, rollback, PR preparation, and human approval boundaries.
data-ai
This skill should be used when the user asks to "share memory between agents", "KV cache compaction for multi-agent", "orchestrator worker context", "latent briefing", "reduce worker tokens", "cross-agent memory without summarization", or discusses Attention Matching compaction, recursive language models with workers, or token explosion in hierarchical agents.