Skill metadata
Reference: full SKILL.md
The following is the complete skill definition that Mibyan loads when this skill is triggered. This is what the agent sees as instructions when the skill is active.
Darwinian Evolver
Run Imbue’s darwinian_evolver — an LLM-driven evolutionary search loop — to optimize a prompt, regex, SQL query, or small code snippet against a fitness function. Status: thin wrapper around the upstream tool. The skill installs it, walks the agent through writing aProblem definition (organism + evaluator + mutator),
and drives the loop via the upstream CLI or a small custom Python driver.
License: the upstream tool is AGPL-3.0. The skill ONLY ever invokes it
via the upstream CLI or a subprocess/uv run call (mere aggregation). Do NOT
import upstream classes into Mibyan itself.
When to Use
- User says “optimize this prompt”, “evolve a regex for X”, “auto-improve this code/SQL”, “search for a better instruction”.
- You have a scorer (exact match, regex pass-rate, unit test, LLM-judge, runtime metric) AND a starting candidate (organism). If you don’t have a scorer, stop and define one first — that’s the hard part.
- Cost is OK: a typical run is 50–500 LLM calls. On gpt-4o-mini that’s pennies; on Claude Sonnet it can be a few dollars.
- The optimization target is differentiable (use gradient descent / DSPy).
- You only need to try 2–3 variants — just write them by hand.
- The fitness signal is purely subjective with no measurable criterion.
Prerequisites
- Python ≥3.11
git,uv(orpip)- One of:
OPENROUTER_API_KEY,ANTHROPIC_API_KEY, orOPENAI_API_KEY
parrot_openrouter.py driver that uses OPENROUTER_API_KEY
via the OpenAI SDK, so any model on OpenRouter works. The upstream CLI itself
hardcodes Anthropic and needs ANTHROPIC_API_KEY.
Install (One-Time)
Run via theterminal tool:
Quick Start — The Built-In Parrot Example
Tiny smoke test (requiresANTHROPIC_API_KEY):
~/.mibyan/cache/scratch/parrot_demo/snapshots/iteration_N.pkl— pickled population per iteration~/.mibyan/cache/scratch/parrot_demo/<jsonl>— per-iteration JSON log (path printed at end)
~/.mibyan/cache/darwinian-evolver/darwinian_evolver/darwinian_evolver/lineage_visualizer.html
in a browser and load the JSON log to see the evolutionary tree.
Quick Start — OpenRouter Driver (No Anthropic Key)
The skill shipsscripts/parrot_openrouter.py — same parrot problem, but the
LLM call goes through OpenRouter so any provider works.
scripts/show_snapshot.py:
Say {{ phrase }} scored 0.000).
Defining a Custom Problem
The skill shipstemplates/custom_problem_template.py — copy, edit, run.
Three things you must define:
-
Organism— a PydanticBaseModelsubclass holding the artifact being evolved (prompt_template: str,regex_pattern: str,sql_query: str,code_block: str, etc.). Add arun(*args)method that exercises it. -
Evaluator—.evaluate(organism) -> EvaluationResult(score=..., trainable_failure_cases=[...], holdout_failure_cases=[...], is_viable=True).scoreis in[0, 1]. Higher is better.trainable_failure_cases— what the mutator sees. Include enough context (input, expected, actual) for the LLM to diagnose.holdout_failure_cases— kept out of the mutator’s view. Use these to detect overfitting.is_viable=Trueunless the organism is completely broken (raises, returns None, etc.). A 0-score viable organism is fine — it just gets down-weighted in parent selection.
-
Mutator—.mutate(organism, failure_cases, learning_log_entries) -> list[Organism]. Typically: build an LLM prompt that includes the current organism + a failure case + an ask to propose a fix; parse the LLM’s response; return a newOrganism. Return[]on parse failure — the loop handles it.
Problem(initial_organism, evaluator, [mutators])
into EvolveProblemLoop and iterates over loop.run(num_iterations=N) — the
shipped scripts/parrot_openrouter.py is the reference.
Hyperparameters That Actually Matter
Pitfalls
Initial organism must be viable— setis_viable=Truein yourEvaluationResulteven on a 0-score seed. The loop refuses non-viable organisms because they imply the loop has nothing to evolve from.- Provider content filters kill runs. Azure-backed OpenRouter models
reject phrases like “ignore previous instructions” with HTTP 400. Wrap
the LLM call in
try/exceptand returnf"<LLM_ERROR: {e}>"— the evolver will just score that organism 0 and move on. loop.run()is a generator — calling it doesn’t run anything until you iterate. Usefor snap in loop.run(num_iterations=N):.- Snapshots are nested pickles.
iteration_N.pklcontains a dict withpopulation_snapshot(more pickled bytes). To unpickle you must have theOrganismclass importable under the same dotted path it was pickled at. - Concurrency defaults are aggressive. 10/10 will hit rate limits on most providers. Start with 2/2.
- CLI is hardcoded to Anthropic.
uv run darwinian_evolver <problem>reaches forANTHROPIC_API_KEYand uses Claude Sonnet. To use any other provider, write a driver likeparrot_openrouter.py. - AGPL. Never
from darwinian_evolver import ...inside Mibyan core. Custom driver scripts under~/.mibyan/skills/...are user-side and fine. - No PyPI package.
pip install darwinian-evolverwill pull the wrong thing. Always install from the GitHub repo.

