# pi-gepa

Genetic Evolution for Prompts and Agents. Evolve Pi skills and prompts through mutation, crossover, and selection.

## Install

```bash
pi install npm:@artale/pi-gepa
```

## What it does

GEPA applies evolutionary algorithms to prompt/skill optimization:

1. **Mutate** — create variants of a skill with targeted changes
2. **Crossover** — combine strengths of two skills
3. **Select** — evaluate variants against a fitness function
4. **Evolve** — repeat until convergence

## Results

Tested on real Pi skills:
- `canvas-design`: **−69% token reduction** while maintaining quality
- `pptx`: **−60% token reduction**
- `xlsx`: **−63% token reduction**

## Commands

```
/gepa evolve <skill>         — start evolution of a skill
/gepa status                 — show evolution state
/gepa history                — past evolution results
```

## How it works

Uses the LLM itself as the mutation operator. Each generation:
1. Reads the current skill SKILL.md
2. Generates N mutated variants (shorter, restructured, different examples)
3. Evaluates each variant on a benchmark task
4. Selects the best performer
5. Repeats for M generations

The fitness function measures: output quality + token efficiency + instruction clarity.

## License

MIT
