
best-of-n-solving
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.
- Installs
- 428
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/spencerpauly/awesome-cursor-skills --skill best-of-n-solving- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads best-of-n-solving automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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
-
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
-
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").
-
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?
-
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.
FAQ
What does the best-of-n-solving skill do?
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.
How do I install best-of-n-solving?
Run npx skills add https://github.com/spencerpauly/awesome-cursor-skills --skill best-of-n-solving in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/best-of-n-solving/ (personal) or .claude/skills/best-of-n-solving/ (project).
Which AI agents can use best-of-n-solving?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is best-of-n-solving safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains best-of-n-solving?
It is published by spencerpauly in spencerpauly/awesome-cursor-skills. It has 428 recorded installs.
More from spencerpauly/awesome-cursor-skills
visual-qa-testing
spencerpauly/awesome-cursor-skills
Visually QA a web application by launching it in Cursor's built-in browser, taking screenshots, checking console errors, and auditing network requests. Use after making UI changes to verify they look correct.
auditing-security
spencerpauly/awesome-cursor-skills
Perform a systematic security audit of a codebase, checking for OWASP Top 10 vulnerabilities, secrets exposure, and insecure patterns.
responsive-testing
spencerpauly/awesome-cursor-skills
Open the app in Cursor's browser at multiple viewport sizes, screenshot each, and report any layout breakage.
suggesting-cursor-rules
spencerpauly/awesome-cursor-skills
When the user repeats the same correction or convention multiple times, suggest a Cursor rule to encode it permanently.
systematic-debugging
spencerpauly/awesome-cursor-skills
Structured debugging methodology — reproduce, isolate, hypothesize, verify. Covers git bisect, binary search, logging, and minimal reproduction.
grinding-until-pass
spencerpauly/awesome-cursor-skills
Keep iterating on code changes until the tests pass, the build succeeds, or linting is clean. Runs in a tight loop of fix → run → check → repeat. Use when you want the agent to autonomously grind through test failures or build errors.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.