darwinian-evolver

Evolve prompts, regex, SQL, and code snippets using an LLM-driven evolutionary search loop.

Updated Jun 7, 2026
One-click install
npx skills add https://github.com/Chensihakniroth/ANAKOT-AGENT --skill darwinian-evolver-chensihakniroth
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: darwinian-evolver
Source: https://github.com/Chensihakniroth/ANAKOT-AGENT/tree/main/optional-skills/research/darwinian-evolver
Command: npx skills add https://github.com/Chensihakniroth/ANAKOT-AGENT --skill darwinian-evolver-chensihakniroth

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires openai, jinja2, darwinian_evolver, and includes scripts (resource) components.

What problem does it solve? Manually iterating on prompts, regex patterns, SQL queries, or code snippets to improve their performance is slow and unsystematic. This Skill automates that optimization by running an evolutionary search loop that mutates candidates, scores them against a fitness function, and selects the best performers over multiple iterations. ## Core Features & Use Cases - LLM-Driven Evolution Loop: Wraps Imbue's darwinian_evolver to iteratively mutate and evaluate an organism (prompt template, regex, SQL query, or code block) against a scored evaluator. - Custom Problem Definitions: Ships a template for defining your own Organism, Evaluator (with trainable and holdout failure cases), and Mutator, plus a working OpenRouter-based driver supporting any model provider. - Snapshot Inspection & Lineage Visualization: Includes a script to dump ranked populations from pickled iteration snapshots and an HTML lineage visualizer for the evolutionary tree. - Use Case: You have a prompt that only sometimes makes an LLM repeat a phrase verbatim. Define exact-match scoring, run 3 iterations with gpt-4o-mini via OpenRouter, and get back 7 evolved prompt templates ranked by score, with the best reaching 0.6–0.8. ## Quick Start Ask the agent to install the darwinian_evolver repo and run the parrot OpenRouter example with your OPENROUTER_API_KEY to evolve a better prompt template.

Frequently Asked Questions about darwinian-evolver

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize a prompt with an evolutionary algorithm?▼

Define an Organism holding your prompt template, an Evaluator that scores outputs in [0,1] with trainable failure cases, and a Mutator that asks an LLM to propose fixes. Then run the EvolveProblemLoop for several iterations and inspect the ranked population snapshots.

How to run darwinian_evolver without an Anthropic API key?▼

Use the shipped parrot_openrouter.py driver, which routes LLM calls through OpenRouter via the OpenAI SDK. Set OPENROUTER_API_KEY and EVOLVER_MODEL to any OpenRouter model, since the upstream CLI is hardcoded to Anthropic.

Can I use OpenRouter or OpenAI models with darwinian_evolver?▼

Yes, but only through a custom driver script like parrot_openrouter.py. The upstream CLI requires ANTHROPIC_API_KEY and uses Claude Sonnet, while the OpenRouter driver works with any provider on that platform.

Why does my evolution run fail with HTTP 400 errors?▼

Azure-backed OpenRouter models apply content filters that reject phrases like "ignore previous instructions". Wrap the LLM call in try/except and return an error string so the evolver scores that organism 0 and continues instead of crashing.

When should I not use evolutionary prompt optimization?▼

Avoid it when the optimization target is differentiable (use gradient descent or DSPy instead), when you only need 2-3 variants you can write by hand, or when the fitness signal is purely subjective with no measurable criterion.

Why does unpickling evolution snapshots fail?▼

Snapshots are nested pickles, and the Organism class must be importable under the same dotted path used when it was pickled. Put your custom driver module on sys.path before running show_snapshot.py, and only unpickle files you created yourself.