# Best of N

Generates candidate solutions in worktrees and applies the one that passes checks.

- Repository: https://github.com/codewhale-hq/Codewhale (41164 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add codewhale-hq/Codewhale --skill best-of-n -g -a claude-code -y`
Codex: `npx skills add codewhale-hq/Codewhale --skill best-of-n -g -a codex -y`
Cursor: `npx skills add codewhale-hq/Codewhale --skill best-of-n -g -a cursor -y`
Gemini CLI: `npx skills add codewhale-hq/Codewhale --skill best-of-n -g -a gemini-cli -y`

## Description

Generate a small set of independent candidate solutions in worktrees, judge them against one explicit rubric, and apply the winner only after PASS verification.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Best of N

Use this skill when a consequential design, implementation, explanation, or
debugging task has several plausible solutions and comparison is worth the
extra model work. In Operate mode this is the preferred ensemble pattern for
high-stakes or ambiguous approaches. Do not use it for a tiny change or when
the user has already chosen the approach.

## Set The Tournament

1. Define one task, one evidence packet, and one explicit scoring rubric before
   launching candidates. Include correctness, fit to the request, simplicity,
   risk, and verification.
2. Choose `N` from 2 to 4 for a quick comparison (default 3). For an explicit
   experimental search, use the Workflow search option: 2, 16 live candidates,
   with larger validated populations queued at the Workflow host's 16-worker
   concurrency gate rather than launched at once.
3. Give every candidate the same task and rubric. Add only a candidate number;
   do not steer candidates toward different conclusions unless diversity is an
   explicit part of the request.
4. Prefer a session goal (`create_goal` or active `/goal`) when the tournament
   spans more than one parent turn.

## Generate Independently

Start the candidates as parallel background `agent` workers and return agent_ids
immediately so the parent stays free. For proposals, reviews, or research, keep
them read-only:

```json
{
  "action": "start",
  "name": "candidate_1",
  "prompt": "Produce candidate 1 for the task below. Return the proposal, evidence, risks, and rubric self-score. Do not edit files.\n\n<TASK AND RUBRIC>",
  "type": "worker",
  "model_strength": "same",
  "write_authority": "read_only"
}
```

Launch the remaining candidates with the same contract, then use `agent` wait
or completion events to collect every result. Do not show one candidate another
candidate's answer before generation finishes.

When candidates must implement code, give each one:

The rest: https://github.com/codewhale-hq/Codewhale/blob/HEAD/crates/skills/assets/skills/best-of-n/SKILL.md
