best-of-n-solving — скилл для Claude Code: параллельные попытки
Запускает 2–3 подхода к сложной задаче одновременно, каждый в своей git-ветке, и помогает выбрать лучший результат.
npx skills add spencerpauly/awesome-cursor-skills --skill best-of-n-solving -a claude-codeЧто делает best-of-n-solving
Скилл пригодится, когда у задачи несколько путей решения и непонятно, какой сработает. Он разворачивает изолированные git worktrees: каждая попытка получает свою ветку и рабочий каталог, так что подходы не мешают друг другу. Дальше вы сравниваете результаты и выбираете победителя.
Работает через субагента best-of-n-runner. Сначала вы формулируете 2–3 разных стратегии, потом запускаете их через Task tool с subagent_type: "best-of-n-runner" — все в одном сообщении, чтобы шли параллельно. В промпт стоит вложить пути к файлам, условие задачи и понятный критерий успеха: прогон тестов, замер времени запроса. Когда все раннеры закончат, сравниваете, кто прошёл тесты, у кого чище реализация и лучше характеристики. Победившую ветку мержите или черри-пикаете нужные коммиты, остальные worktrees удаляете.
Для простых задач это перебор — хватит одного агента. Раннеры полностью изолированы и не видят правок друг друга, поэтому критерии успеха в промпте лучше прописать заранее. Ветки настоящие, так что при желании их можно посмотреть руками.
Какие задачи решает
- разобрать баг с несколькими возможными первопричинами
- выбрать между паттернами в рефакторинге: композиция или наследование
- сравнить библиотеки для одной и той же фичи
- ускорить медленный запрос несколькими способами сразу
- проверить несколько архитектурных решений до того, как зафиксировать одно
Примеры запросов агенту
- Прогони best-of-n-solving: попробуй три подхода к оптимизации этого запроса, каждый в своей ветке
- Запусти параллельные попытки через best-of-n-runner для рефакторинга модуля оплаты и покажи, какая ветка проходит тесты
- Используй скилл best-of-n-solving, чтобы сравнить два варианта кеширования и выбрать лучший
Как установить best-of-n-solving
1Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill best-of-n-solving -a claude-code2Вручную: положить файлы
~/.claude/skills/best-of-n-solving/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/best-of-n-solving/
1Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill best-of-n-solving -a codex2Вручную: положить файлы
.agents/skills/best-of-n-solving/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill best-of-n-solving -a cursor2Вручную: положить файлы
.cursor/skills/best-of-n-solving/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install spencerpauly/awesome-cursor-skills best-of-n-solving2Вручную: положить файлы
.github/skills/best-of-n-solving/SKILL.md1Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill best-of-n-solving -a gemini-cli2Командой платформы
gemini skills install https://github.com/spencerpauly/awesome-cursor-skills --path resources/best-of-n-solvingВручную: положить файлы
.devin/skills/best-of-n-solving/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill best-of-n-solving -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о best-of-n-solving
Как установить best-of-n-solving в Claude?
Выполните npx skills add spencerpauly/awesome-cursor-skills --skill best-of-n-solving -a claude-code. После этого файл скилла появится по пути ~/.claude/skills/best-of-n-solving/SKILL.md.
Что делает best-of-n-solving?
Решает сложную задачу, пробуя несколько подходов параллельно. Каждая попытка идёт в отдельном git worktree и своей ветке, затем вы сравниваете результаты и выбираете лучший.
Когда этот скилл не нужен?
Для простых задач он избыточен — там достаточно одного агента. Скилл рассчитан на случаи, где есть 2–3 осмысленные стратегии и нужно их сравнить.
Исходный текст
SKILL.md · CC0-1.0
---
name: best-of-n-solving
description: Solve a hard problem by trying multiple approaches in parallel using isolated git worktrees. Each attempt runs in its own branch, and the best solution is selected. Use for complex refactors, tricky bugs, or architectural decisions where multiple strategies could work.
---
# Best-of-N Problem Solving
Use this skill when facing a hard problem with multiple possible approaches — complex refactors, tricky bugs, performance optimization, or architectural decisions where you're not sure which strategy will work best.
## How It Works
Cursor's `best-of-n-runner` subagent type creates isolated git worktrees — each attempt gets its own branch and working directory. Multiple approaches run in parallel without interfering with each other. You compare the results and pick the winner.
## Steps
1. **Identify the approaches** — before launching, define 2-3 distinct strategies. For example, if optimizing a slow database query:
- Approach A: Add a composite index and rewrite the query
- Approach B: Denormalize the schema with a materialized view
- Approach C: Add application-level caching with Redis
2. **Launch parallel runners** — use the Task tool with `subagent_type: "best-of-n-runner"` for each approach. Launch them all in a single message so they run concurrently:
```
Task 1: { subagent_type: "best-of-n-runner", prompt: "Approach A: ..." }
Task 2: { subagent_type: "best-of-n-runner", prompt: "Approach B: ..." }
Task 3: { subagent_type: "best-of-n-runner", prompt: "Approach C: ..." }
```
Each runner gets its own branch and worktree. Include clear success criteria in the prompt (e.g., "run the tests and report if they pass", "measure the query time").
3. **Compare results** — when all runners complete, evaluate:
- Which approach passes all tests?
- Which has the cleanest implementation?
- Which has the best performance characteristics?
- Which is easiest to maintain long-term?
4. **Merge the winner** — check out the winning branch and merge it, or cherry-pick specific commits. Clean up the other worktree branches.
## When to Use This
- A bug that could have multiple root causes
- A refactor where you're choosing between patterns (e.g., composition vs. inheritance)
- Performance optimization with multiple strategies
- Trying different libraries or approaches for the same feature
- Any situation where "just try it" is faster than analyzing
## Notes
- Each runner is fully isolated — they can't see each other's changes.
- Keep prompts specific: include the file paths, the problem statement, and clear success criteria.
- For simpler problems, this is overkill — just use a single agent.
- The branches are real git branches, so you can inspect them manually if needed.
© spencerpauly · CC0-1.0 · spencerpauly/awesome-cursor-skills