best-of-n

best-of-n is a skill for Claude Code, Codex from RoyZhao1991/LingShu. It costs 62 tokens per session (785 once invoked), scanned A, original, Apache-2.0.

A workflow for implementing the same coding task several different ways in parallel, then choosing and applying the best result. It uses separate worktrees so candidates can be compared independently.

In plain words
What is it for?
Trying two to ten implementations of a task, evaluating the candidates, and applying the selected winner.
Why use it?
It reduces the risk of settling on the first approach when several implementations could work.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions subagents.

Good fit Trying two to ten implementations of a task, evaluating the candidates, and applying the selected winner.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/royzhao1991/lingshu/best-of-n
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add RoyZhao1991/LingShu --skill best-of-n
Clone the repo
git clone --depth 1 https://github.com/RoyZhao1991/LingShu

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for best-of-n

README.md
[![agentmods](https://agentmods.dev/badge/skills/royzhao1991/lingshu/best-of-n/github.svg)](https://agentmods.dev/skills/royzhao1991/lingshu/best-of-n)
Your own site
<a href="https://agentmods.dev/skills/royzhao1991/lingshu/best-of-n"><img src="https://agentmods.dev/badge/skills/royzhao1991/lingshu/best-of-n/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for best-of-n

Your own site · 80×15
<a href="https://agentmods.dev/skills/royzhao1991/lingshu/best-of-n"><img src="https://agentmods.dev/badge/skills/royzhao1991/lingshu/best-of-n.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 62 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 785 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00062 $0.00785
Opus 5 $0.00031 $0.00392
Sonnet 5 $0.00012 $0.00157
Haiku 4.5 $0.00006 $0.00078

Measured 12d ago against content hash e0e1849ead8d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

best-of-n scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • best-of-n — 100% identical, 0 lines differ
Runtime/Grok/crates/codegen/xai-grok-shell/skills/best-of-n/SKILL.md · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/best-of-n -- Parallel Implementation Tournament

Implement a task multiple different ways in parallel, evaluate all candidates, and apply the best one.

Usage

/best-of-n [N] <task>

  • If the first token is a number 2-10, it sets the candidate count; the rest is the task.
  • If omitted, N defaults to 3.

Examples:

  • /best-of-n implement the login page (3 candidates)
  • /best-of-n 5 refactor the auth module (5 candidates)

Steps

  1. Parse the user's message to extract N (candidate count, default 3) and the task description.

  2. Spawn N subagents in a single message (parallel tool calls). Use the task tool for each with:

    • subagent_type: "general-purpose"
    • isolation: "worktree"
    • run_in_background: true
    • description: "Candidate <number>"
    • prompt: the task description, plus "You are candidate <number> of <N> independent implementations. Implement the task fully. When done, summarize your approach and the changes you made."
  3. Wait for all candidates to complete using get_task_output with block: true or wait_tasks with mode: "wait_all".

  4. Evaluate and pick the winner using the criteria below.

  5. Apply the winner's changes from its worktree to the main workspace. Review the changes in context and fix any remaining issues.

  6. End your response with WINNER: <number> (1-N).

Evaluation Criteria

Evaluate each candidate on these axes, in order of importance:

  1. Correctness -- Does the candidate actually solve the task? Does it handle the requirements completely, or does it miss important aspects? Are there logic errors, type errors, or broken imports?

  2. Code Quality -- Is the code clean, readable, and well-structured? Does it follow the patterns and conventions of the surrounding codebase? Does it avoid unnecessary complexity?

  3. Safety -- Does the candidate avoid introducing bugs, security issues, or breaking changes to existing functionality?

Read the full file on GitHub · 94 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 94 lines · 62 tokens per session scan A e0e1849ead8d

Subscribe to this mod's changes

best-of-n is a skill published in the GitHub repository RoyZhao1991/LingShu (12 stars, last pushed 23d ago), licensed Apache-2.0. It adds 62 tokens to every session and 785 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

massgen-log-analyzer

Run MassGen experiments and analyze logs using automation mode, logfire tracing, and SQL queries. Use this skill for performance analysis, debugging agent behavior, evaluating coordination patterns, and improving the logging structure, or whenever an ANALYSISREPORT.md is needed in a log directory.

massgen/MassGen · 60 tokens

backend-integrator

Complete guide for integrating a new LLM backend into MassGen. Use when adding a new provider (e.g., Codex, Mistral, DeepSeek) or when auditing an existing backend for missing integration points. Covers all 15 files that need touching.

massgen/MassGen · 57 tokens

massgen-develops-massgen

Guide for using MassGen to develop and improve itself. This skill should be used when agents need to run MassGen experiments programmatically (using automation mode) OR analyze terminal UI/UX quality (using visual evaluation tools). These are mutually exclusive workflows for different improvement goals.

massgen/MassGen · 63 tokens

release-prep

Prepare release documentation including CHANGELOG entry, announcement text, and validation. Run before tagging a new release.

massgen/MassGen · 25 tokens

model-registry-maintainer

Guide for maintaining the MassGen model and backend registry. This skill should be used when adding new models, updating model information (release dates, pricing, context windows), or ensuring the registry stays current with provider releases. Covers both the capabilities registry and the pricing/token manager.

massgen/MassGen · 60 tokens

serena

This skill provides symbol-level code understanding and navigation using Language Server Protocol (LSP). Enables IDE-like capabilities for finding symbols, tracking references, and making precise code edits at the symbol level.

massgen/MassGen · 41 tokens