# GEPA optimize_anything: auto-improve prompts and code by score (gepa-ai/gepa) — skill card for AI agents

> AgentGid skill card. Checked on 2026-11-17 against commit ce5b0d6 (version 0.1.0).
> Every fact comes from the pack's own files at that commit. Numbers marked "as reported" are the author's.
> Human page: https://agentgid.com/skills/gepa-ai/gepa/

## Explain it to a non-programmer
Your assistant learns to run GEPA's optimize_anything for you. You give it a starting text (a prompt, a piece of code, a config) and a way to score it. An AI model then proposes better versions and keeps the best one. The skill teaches the assistant how to set the run up, how big a budget to give it and which mistakes to avoid.

## Who it is for
- You want a prompt, code, config or agent instructions improved automatically against a score you can measure
- You can write a check that gives a number, or use an AI judge for quality, tone or style
- You want to compare several optimizers on the same task with the same scoring
- Not for: You cannot measure how good the result is: the whole method runs on a score
- Not for: You don't want to pay for AI model calls: every run calls a model with your own key

## What it is
- Kind: knowledge, scripts
- License: MIT
- Repository: https://github.com/gepa-ai/gepa

## What it does
- Four pieces: the text to improve, a scoring function that returns a number plus written feedback, an optimizer, and a budget
- Three modes, picked by the data you pass: one hard problem, many related problems with one shared answer, or an answer that must work on unseen cases
- Optimizers you switch with one setting: gepa (the default, an AI reflects on feedback and rewrites), autoresearch and meta_harness (a Claude Code session does the research), and best_of_n as a simple baseline
- Budget rule: let the optimizer try about 15 to 20 versions, so size the scoring calls to the data set, and add a stop score or a dollar cap
- A checklist of traps: gaming a weak score, over-optimistic picks, noisy single samples, and a seed that is already perfect
- A preflight script that checks the package, keys and command-line tools before a long run

## Skills
| Skill | Call | Changes code? | In plain words |
|---|---|---|---|
| gepa-optimize-anything | plain language, e.g. "optimize this prompt with GEPA" (the skill loads when the task matches) | yes | Sets up and runs an automatic improve-and-score loop on any text you can measure |

### gepa-optimize-anything
- Asks for: A starting text (or none, with a description of the goal)
- Asks for: A scoring function: text in, a number out, plus feedback
- Asks for: Examples to train on and, optionally, held-out examples to pick the winner
- Asks for: A goal and background rules
- Asks for: A budget: number of scoring calls and/or a dollar cap, and a stop score if there is a ceiling
- Gives: The best version found and its score
- Gives: A held-out test score for the seed and the final version, if you gave a test set
- Gives: A run folder with every step, plus per-call JSON, a progress log and a summary
- Say: "Use GEPA optimize_anything to improve my system prompt; here is my grading function and 40 examples"

## Know before installing
- It needs an AI provider key. The default proposer model is OpenAI's, so set that key or pass another model id.
- Runs cost money in model calls. The skill tells the assistant to set a dollar cap, a stop score and a timeout.
- The autoresearch and meta_harness modes start Claude Code sessions as separate processes; they are sandboxed by default, and turning the sandbox off gives the agent full access to your machine.
- The default budget is often too small: the run can stop after one proposal and still report a best candidate.
- If your starting text already passes every example, the default optimizer returns it unchanged.

## Install (official commands)
- Claude Code: `/plugin marketplace add gepa-ai/gepa` && `/plugin install gepa-optimize-anything@gepa` — Send as two separate prompts. Then the gepa Python package is needed: pip install "gepa[full]".
- Claude Code, Cursor, VS Code/Copilot, Codex, Gemini CLI (in a clone of the repository): Agents that read .claude/skills/ find the skill on their own when you work inside a clone of gepa-ai/gepa.
- Python library (needed for any run): `pip install "gepa[full]"` — [full] adds cloudpickle, needed when the scoring function uses outside data in parallel runs.

## What runs on the user's machine
- Code on the machine: yes (runs the assistant launches with the gepa library; the skill itself is markdown plus one check script)
- Network: True
- Install: A skill file, four reference files and one Python script. No hooks.
- Before a run (preflight.py): Checks that gepa imports, that a provider key is set in the environment, and that claude, jq and bwrap are on the PATH when needed. Reads environment variables only, writes nothing. With --test-lm it makes one short call to the AI model.
- Every optimization run: The gepa library calls the AI provider you chose for every proposed version; your scoring function runs on your machine and may call models too.
- Every optimization run: Writes per-call JSON, progress_log.jsonl and summary.json to output_dir (default outputs/optimize_anything/...) and an optimizer workspace to run_dir.
- autoresearch or meta_harness mode: Starts Claude Code (claude --print) as a separate process that posts candidates to a scoring server; sandboxed by default.
- Optional tracking: Logs runs to Weights & Biases or MLflow when you turn it on.

## Settings
- `OPENAI_API_KEY`: Key for the default proposer model
- `ANTHROPIC_API_KEY`: Key when you pass an anthropic/ model id
- `GEPA_REFLECTION_LM`: Model id preflight.py checks instead of the default
- `max_evals`: Cap on scoring calls (default 100)
- `max_token_cost`: USD cap on the optimizer's own model spend
- `sandbox`: True by default: jails the Claude Code subprocess in agentic modes

## Examples (from the pack's own files)
- Minimal run that optimizes a system prompt: output format defined in .claude/skills/gepa-optimize-anything/SKILL.md

## Author's numbers (as reported, not run by AgentGid)
- Coding agent resolve rate on Jinja rose from 55% to 82% with auto-learned skills. Source: gepa-ai/gepa/README.md
- 100–500 evaluations vs. 5,000–25,000+ for GRPO (35x faster than RL). Source: gepa-ai/gepa/README.md

## Steps only the person can do
- Get an API key from your model provider (OpenAI by default, or Anthropic or AWS Bedrock) and set it as an environment variable (Your model provider's account settings) Then: The assistant runs preflight.py and launches the optimization
- For autoresearch or meta_harness, install the Claude Code CLI and run claude once to sign in (.claude/skills/gepa-optimize-anything/SKILL.md (Install section)) Then: The agentic optimizers can start their Claude sessions

## Mistakes to avoid
- Not: Keep the default max_evals of 100 with a large valset. Instead: Size max_evals to about 15 to 20 times the selection set, and check how many proposals actually ran. Why: Otherwise the run stops after one proposal and still reports a best candidate
- Not: Score only whether the output is "correct". Instead: Gate the score on the real goal and return rich feedback, not just a number. Why: Every optimizer games a weak proxy
- Not: Switch engine= and keep the old engine_config block. Instead: Swap the engine_config block together with the engine. Why: Unknown keys raise TypeError at construction
- Not: Train only on examples the seed already gets right. Instead: Include real failures in the dataset. Why: The gepa backend then rejects every proposal and returns the seed unchanged
- Not: Turn on evaluation caching and rely on max_evals alone. Instead: Also set stop_at_score or max_token_cost. Why: With caching, max_evals counts only cache misses

## What leaves the machine
- Your candidate texts, the feedback from your scoring function and the task description → The AI provider of the proposer model (OpenAI by default), Every proposal round of a run. Opt out: Pass a self-hosted model function instead of a provider model id
- Run metrics → Weights & Biases or MLflow, Only when tracking is turned on. Opt out: Leave tracking off

## Lines in the pack aimed at agents (ask the person first)
- "npm install -g @anthropic-ai/claude-code   # or: curl -fsSL https://claude.ai/install.sh | bash" (.claude/skills/gepa-optimize-anything/SKILL.md): A global install or a piped install script; ask the person first, and only for the agentic modes
- "the default sandbox=True jails the claude subprocess with
# bwrap (`sudo apt install bubblewrap` / `sudo dnf install bubblewrap`)" (.claude/skills/gepa-optimize-anything/SKILL.md): Needs sudo; let the person run it
- "`sandbox=False` opts out — the agent then runs unsandboxed (loud warning)." (.claude/skills/gepa-optimize-anything/SKILL.md): Never turn the sandbox off without the person's explicit approval

## May I use it like this?
- commercial-app: yes (MIT: keep the copyright and permission notice)
- redistribute-files: yes (MIT: keep the notice in copies)
- client-work: yes (MIT)

## Which one to pick
- If You need score-driven optimization of any text through a Python API, with several optimizers behind one call: skill:gepa-ai/gepa
- If You want Claude Code itself to iterate toward a goal in your repo without writing a Python evaluator: skill:uditgoenka/autoresearch
- If You want a tool that finds what to measure in your codebase and runs the loop on its own: skill:evo-hq/evo
- If You want to evolve your own skill files with an evaluate, improve, test, keep-or-roll-back loop: skill:alchaincyf/darwin-skill

## Works well with
- tool:gepa: The Python package the skill drives
- tool:litellm: Proposer models are given as LiteLLM ids
- tool:dspy: The plugin manifest lists dspy among its keywords
- tool:wandb: The gepa backend can log runs to Weights & Biases

## Works in and needs
- Works in Claude Code: plugin
- Works in Cursor, VS Code/Copilot, Codex, Gemini CLI: skills folder (.claude/skills/ in a clone)
- Needs Python with the gepa package: The skill drives gepa.optimize_anything
- Needs An AI provider API key: The proposer model is called on every round
- Needs Claude Code CLI, jq: Only for the autoresearch and meta_harness modes
- Needs bubblewrap (Linux): The default sandbox for the agentic modes

## How to tell it works
Install the plugin and the gepa package, set your model key, then ask: "Use GEPA optimize_anything to improve this prompt; here is how to score it." The assistant should ask about mode and budget, run the preflight check, and return the best version with its score.

## Safety
Install only from github.com/gepa-ai/gepa. The skill tells the assistant to install Python and npm packages and, for two modes, to start Claude Code sessions that act on their own; keep the default sandbox on and set a dollar cap.
