# Pair optimize

> Pair optimize is an open-source agent skill for developer tools. Runs measured, output-checked speedup experiments on queries and Python code with a second. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/ccomkhj/skills/tree/main/pair-optimize
- **Repository:** https://github.com/ccomkhj/skills
- **GitHub stars:** 10
- **License:** MIT
- **Skill name:** pair-optimize
- **Collection:** https://github.com/ccomkhj/skills
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-02

## About

Pair-optimize guides an agent through a structured loop for making a concrete, runnable target faster or cheaper. The target can be a SQL or DuckDB query, a hot Python function, an endpoint, or a pipeline step. The agent first records a baseline, profiles to find the real bottleneck, and proposes ranked candidate changes.

Each candidate is implemented and benchmarked against the baseline on the same harness and data, with repeated runs reported as a median and spread. A candidate is kept only if it is measured better and produces output identical to the baseline; otherwise it is reverted or marked unverified. The workflow also covers equivalence checks for SQL, including row-multiplicity traps, and sampling profilers for Python.

The skill is built for a two-agent setup in which a second agent, such as Codex or Claude, re-runs the benchmarks and challenges the numbers in alternating rounds. State is kept in a local .optimize folder, and the skill ships bash helper scripts for handoff and waiting. It expects a repository with runnable code and representative data.

## When your agent uses it

> Use when the user wants a measured speedup or cost reduction for something concrete and runnable — a DuckDB/SQL query, a hot Python path, an endpoint, a pipeline step — with a second agent (Claude ↔ Codex) challenging the numbers, rather than vibes-based tuning. Also use when invoked as the peer ("Resume the pair-optimize skill"). Hard rule — no optimization is kept unless it is measured faster/cheaper AND produces output identical to the baseline.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Runs shell scripts](https://github.com/ccomkhj/skills/tree/HEAD/pair-optimize)
- [No network calls found in its scripts](https://github.com/ccomkhj/skills/tree/HEAD/pair-optimize)
- [License: MIT](https://github.com/ccomkhj/skills/tree/HEAD/pair-optimize)

## Features

- **Baseline measurement first:** Records a timed baseline with repeated runs before any change is considered.
- **Sampling-based bottleneck profiling:** Uses a sampling profiler to locate the real hotspot rather than relying on cProfile.
- **Output equality enforcement:** Requires candidate results to match the baseline, including row multiplicity for SQL.
- **Memory as a cost metric:** Measures peak memory and allocation deltas so cheaper, not only faster, changes can be kept.
- **Peer challenge rounds:** A second agent re-runs the benchmarks and audits the measurements and correctness checks.
- **Shared state and helper scripts:** Tracks rounds and status in a local folder and provides bash helpers for handoff and waiting.

## Good for

- Speed up a slow DuckDB or SQL query without changing its results
- Reduce the runtime of a hot Python function with measured benchmarks
- Cut the latency of an API endpoint while proving responses stay the same
- Find out whether a proposed pipeline optimization actually helps
- Check whether a memory-heavy Python step can stream instead of materializing

## Install

### Claude Code

Copy the skill folder to `~/.claude/skills/pair-optimize` to use it in all your projects:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ccomkhj/skills.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/pair-optimize &&
cp -R "$tmp/pair-optimize" ~/.claude/skills/pair-optimize &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/pair-optimize` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/pair-optimize` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ccomkhj/skills.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/pair-optimize &&
cp -R "$tmp/pair-optimize" ~/.agents/skills/pair-optimize &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/pair-optimize` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/pair-optimize` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ccomkhj/skills.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/pair-optimize &&
cp -R "$tmp/pair-optimize" ~/.cursor/skills/pair-optimize &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/pair-optimize` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ccomkhj/skills.git --path pair-optimize
```

Or copy the folder to `~/.gemini/skills/pair-optimize` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/pair-optimize`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ccomkhj/skills.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/pair-optimize &&
cp -R "$tmp/pair-optimize" ~/.copilot/skills/pair-optimize &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/pair-optimize` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ccomkhj/skills.git
```

Then copy `skills/pair-optimize` into your agent's skills folder as `pair-optimize`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does the skill trigger?

When the user wants a measured speedup or cost reduction for something concrete and runnable, with a second agent challenging the numbers. It also triggers when invoked as the peer with a resume instruction.

### What is the rule for keeping an optimization?

A change is kept only if it is measured faster or cheaper than the baseline and produces output identical to the baseline. Unmeasurable candidates are labeled unverified and the baseline stays.

### What does Pair optimize need to run?

A runnable target and a way to feed it representative data. The skill is built around a Python codebase and uses bash helper scripts; if the target cannot be run, it falls back to clearly marked static analysis.

### Does Pair optimize work with every AI client?

The skill is a plain SKILL.md folder and the content does not tie it to specific clients, so it is listed for all supported agents.

### How do I install Pair optimize in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/pair-optimize to use it in all your projects, or to .claude/skills/pair-optimize in one project.

### Does Pair optimize run scripts?

Yes. It runs shell scripts. No network calls were found in its scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Pair optimize?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Pair optimize?

The closest alternatives to Pair optimize are Benchmark optimization loop, Performance reasoning, Pair ratchet, Optimize and Optimize loop.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Benchmark optimization loop](https://ai-powered.com/skills/benchmark-optimization-loop): Benchmark optimization loop is an open-source agent skill for developer tools.
- [Performance reasoning](https://ai-powered.com/skills/performance-reasoning): Performance reasoning is an open-source agent skill for developer tools.
- [Pair ratchet](https://ai-powered.com/skills/pair-ratchet): Pair ratchet is an open-source agent skill for developer tools.
- [Optimize](https://ai-powered.com/skills/optimize-jasgujral): Optimize is an open-source agent skill for developer tools.
- [Optimize loop](https://ai-powered.com/skills/optimize-loop): Optimize loop is an open-source agent skill for developer tools.
- [Go performance review](https://ai-powered.com/skills/go-performance-review): Go performance review is an open-source agent skill for developer tools.
- [Benchmark checklist](https://ai-powered.com/skills/benchmark-checklist): Benchmark checklist is an open-source agent skill for developer tools.
- [Skill creator](https://ai-powered.com/skills/skill-creator): Skill creator is a free agent skill for ai models and llm tooling.

---
Source: https://ai-powered.com/skills/pair-optimize
