Building an AlphaEvolve Skill
We will use Claude Code as our only development tool to build a reusable skill that brings evolutionary optimization to your coding workflow. The finished skill is open-source: alphaevolve-skill.
Before diving into implementation, let's clarify what we're building, why it's useful, and how it fits into your development workflow.
What We're Building#
We're building a Claude Code skill — a reusable, slash-command-invocable capability that turns Claude from a one-shot code generator into an iterative optimization engine. When you invoke this skill, Claude will:
- Take a target function or file you want to optimize
- Run it against an evaluator you define (benchmark, test suite, static analysis)
- Generate multiple variant implementations
- Score each variant on your metric
- Select the best candidates and repeat — accumulating improvements across generations
The end result is a skill you can invoke with a single command to evolve code toward a measurable objective, whether that's reducing latency, minimizing memory usage, or improving code quality scores.
Why Build This?#
If you've used Claude Code (or any LLM) to optimize code, you've probably noticed the pattern:
- You ask it to "make this faster"
- It produces a reasonable rewrite
- You benchmark it — maybe it's faster, maybe it's not
- If not, you ask again with more context
- Repeat manually until you give up or get lucky
This manual loop is slow, inconsistent, and doesn't accumulate knowledge between attempts. You're doing the evaluate-select-iterate loop in your head, one prompt at a time.
The AlphaEvolve skill automates this entire cycle. It:
- Closes the feedback loop — real measurements (not LLM intuition) drive what gets kept
- Accumulates knowledge — each generation's prompt includes what worked, what didn't, and why
- Explores broadly — generates multiple variants per iteration instead of a single rewrite
- Maintains diversity — keeps structurally different candidates to avoid local optima
How Claude Code Skills Work#
A Claude Code skill is a markdown file (placed in .claude/skills/) that defines a reusable capability. When you type the skill's slash command, Claude loads the skill's instructions and follows them. Skills can:
- Define multi-step workflows with explicit instructions
- Use all of Claude Code's capabilities (read/write files, run commands, iterate)
- Accept parameters from the user
- Maintain state across iterations within a single invocation
This makes skills ideal for algorithmic patterns like evolutionary optimization — the skill encodes the loop structure, and Claude handles the creative work of generating variants.
Project Structure#
The skill we'll build has these core components:
| Component | Purpose |
|---|---|
| Skill definition | The .md file that defines the slash command and orchestration logic |
| Evaluator interface | A convention for scoring functions that the skill invokes |
| Population management | Tracking multiple candidates, their scores, and lineage |
| Context assembly | Building rich prompts with parent code, scores, and mutation hints |
| Optimization loop | The generate → evaluate → select → repeat cycle |
Prerequisites#
Before starting this tutorial, you should have:
- Claude Code installed — see the Getting Started with Claude Code tutorial if you haven't set it up
- A GitHub account — for cloning and contributing to the skill repository
- Basic familiarity with Claude Code — you should know how to give it tasks, approve file edits, and run commands
- A project with something to optimize — any codebase with a function you can benchmark or score
What You'll Learn#
By the end of this tutorial, you'll understand:
- How to design a Claude Code skill with multi-step orchestration
- How to define proper evaluators (the most important and hardest part)
- How population-based search outperforms single-shot generation
- How to assemble rich context that guides productive mutations
- How to apply evolutionary thinking to everyday engineering problems
What's Next?#
We'll start with the background — understanding what AlphaEvolve is, how it works, and why the "single LLM call" approach has a hard ceiling that evolutionary optimization breaks through.