# prompt evolve

> A data-driven prompt optimization loop that scores, versions, and evolves prompts against test sets.

prompt evolve is a free AI agent skill on Agensi by kktestdev, in Prompt & Skill Engineering. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [kktestdev](https://www.agensi.io/creators/supakit-kitjanabumrungsak)
- Category: [Prompt & Skill Engineering](https://www.agensi.io/skills/prompt-skill-engineering)
- Uses: 2
- Version: 1.1
- Last updated: 2026-10-23
- Security: scan passed (2026-10-23); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/prompt-evolve
- Tags: prompt-engineering, python, testing, llm-ops

## About this skill

Stop guessing whether a prompt change actually worked. This skill replaces trial-and-error manual editing with a measured optimization loop that scores outputs against a test set, identifies specific failures, and evolves the prompt version-by-version. It treats prompt engineering like software engineering, persisting every iteration as a diffable file.

### What it does
- **Systematic optimization** runs prompts against a defined test set to measure real performance gains.
- **Version tracking** saves every iteration in a `generations/` directory for diffing and rollbacks.
- **Failure analysis** identifies specific test cases where the prompt fails to generate actionable improvement data.
- **Two ways to score**: deterministic checks (exact match, regex, required JSON keys), or your agent grades each output 0–1 against the case's rubric and `--scorer rubric` saves those grades.
- **Progress reporting** generates a `report.md` tracking the score curve and highlighting the best-performing version.

### How it works
1. **Initialize** the workspace with a `prompt.tmpl` containing an `{input}` placeholder and a `testset.jsonl` file.
2. **Execute** iterations where you render the prompt, capture outputs, and score them with a deterministic scorer or by grading each output against its rubric.
3. **Persist** results using the `pevolve.py score` command to save the current version and its performance metrics.
4. **Refine** the prompt based on reported failures and repeat until the target score is met or the loop plateaus.

### Frameworks & tools
The skill ships a Python 3 CLI (`pevolve.py`, standard library only) for file management and scoring. The CLI never calls a model: your agent runs the prompt (and grades the outputs when you score by rubric), and `pevolve.py` scores or saves those grades. Written for Claude Code.

### Why this beats prompting it yourself
Manual tweaking is subjective and prone to regression where fixing one case breaks three others. This skill enforces a data-driven approach that ensures the "best" prompt is chosen based on evidence, not intuition, while maintaining a full audit trail of every change.

### Use cases
- Tuning an extraction prompt until every output contains the required JSON keys.
- Tuning a support-reply or writing prompt against a quality rubric.
- Debugging edge-case failures in a complex classification task.

### Known limitations
The prompt template only supports a literal `{input}` placeholder. Deterministic JSON schema scoring is limited to checking for the presence of specific keys rather than full validation. Rubric grades come from your agent, so they are only as consistent as its judgement; keep rubrics specific.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the prompt evolve skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this skill differ from manually refining prompts in a chat interface?

You score every prompt version against the same test set, see exactly which cases fail, and keep every version on disk, so a change that breaks other cases shows up in the scores.

### What AI agents or development environments are compatible with this skill?

It is written for Claude Code. It needs Python 3 to run the bundled `pevolve.py` CLI (standard library only, no extra packages).

### What types of scoring methods can I use to evaluate my prompt versions?

Four scorers: exact match, regex, a required-JSON-keys check, and `rubric`, which saves your agent's own 0–1 grade (and optional note) for each case.

### What specific files and tools are included in the 'prompt evolve' package?

Three files: `SKILL.md` (the workflow), `scripts/pevolve.py` (the CLI) and `LICENSE`. You write your own `prompt.tmpl` and `testset.jsonl`.

### Can I use this skill for prompts that require multiple input variables?

Currently, the template system is optimized for a single `{input}` placeholder; more complex multi-variable templates may require pre-processing before being passed to the optimization loop.

### How does the skill handle version control and progress tracking?

Each scored version is saved as `generations/vN.tmpl` with its scores in `generations/scores.jsonl`; `pevolve.py report` writes `report.md` with the score curve and the best version.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
