Cursor Skill

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.

LLM Mart · 0 points · 20 views 1 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download spencerpauly-awesome-cursor-skills-resources_best-of-n-solving-99cd265.zip · 1 KB
Part of spencerpauly/awesome-cursor-skills — 65 skills

Install

skills CLI npx skills add https://github.com/spencerpauly/awesome-cursor-skills/tree/main/resources/best-of-n-solving
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install spencerpauly-awesome-cursor-skills@llmmart
Git git clone https://github.com/spencerpauly/awesome-cursor-skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole spencerpauly/awesome-cursor-skills collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

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.
Files (awesome-cursor-skills)
  • SKILL.md 2.7 KB
    ---
    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.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related