agentleFS
pmatospmatos/skills/best-of/SKILL.md

best-of

Skill2 starsChanged 4 months agoMITView on GitHub

This skill should be used when the user asks to "compare code", "compare worktrees", "compare solutions", "which solution is better", "compare branches", "best of", "diff worktrees", "evaluate solutions", "pick the better implementation", "compare implementations", "review both solutions", or wants a structured, criteria-driven comparison of code across two git worktrees. Also triggered by the /best-of command.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 10 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If either path is invalid, report the error and stop.

    line 28
  2. Distinctive:

    Run a quick orientation in both:

    line 34
  3. Distinctive:

    If the two worktrees share a common ancestor (same repo, different branches), compute the divergence:

    line 43
  4. Distinctive:

    Search both worktrees for contribution and convention files.

    line 53
  5. Distinctive:

    If the two worktrees have different guideline files, note the differences — this itself is a finding.

    line 66
  6. Distinctive:

    If the output reaches exactly 200 lines, warn the user that the file list was truncated and suggest narrowing the comparison scope with a …

    line 86
  7. Distinctive:

    Read-only: Do NOT modify any files in either worktree.

    line 214
  8. Distinctive:

    Evidence-based: Every claim must cite a specific file:line from one of the worktrees.

    line 215
  9. Distinctive:

    Fair: Do not favor one worktree over the other by default.

    line 216
  10. Distinctive:

    No phantom references: Every file:line citation must be verified against the actual code.

    line 218

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Comparison

Compare two git worktrees side-by-side against software engineering best practices and project contribution guidelines. Produce a structured, evidence-based verdict on which solution is better and why.

Task

$ARGUMENTS

Workflow

Step 1: Parse Inputs and Validate Worktrees

Extract the two worktree paths from the arguments. If an optional focus area or file path is provided, note it for scoped analysis.

# Validate both paths are git worktrees or repositories
git -C <worktree-A> rev-parse --show-toplevel
git -C <worktree-B> rev-parse --show-toplevel

If either path is invalid, report the error and stop. If only one path or no path is provided, ask the user for the missing worktree path(s) using the AskUserQuestion tool.

Identify the worktrees:

  • Worktree A: first path argument
  • Worktree B: second path argument

Run a quick orientation in both:

# For each worktree
git -C <worktree> log --oneline -5
git -C <worktree> branch --show-current
git -C <worktree> show --stat --oneline -1  # last commit's scope

If the two worktrees share a common ancestor (same repo, different branches), compute the divergence:

MERGE_BASE=$(git -C <worktree-A> merge-base HEAD $(git -C <worktree-B> rev-parse HEAD))
git -C <worktree-A> diff --stat $MERGE_BASE HEAD
git -C <worktree-B> diff --stat $MERGE_BASE HEAD

Step 2: Discover Project Guidelines

Search both worktrees for contribution and convention files. Collect every rule that applies.

Files to search for (using Glob in each worktree root):

  • CLAUDE.md, AGENTS.md, **/CLAUDE.md, **/AGENTS.md
  • CONTRIBUTING.md, CONTRIBUTING.rst
  • .editorconfig
  • Linter configs: .eslintrc*, .prettierrc*, pyproject.toml, setup.cfg, .flake8, .rubocop.yml, biome.json, deno.json
  • CI configs: .github/workflows/*.{yml,yaml}, Makefile, Taskfile.yml, justfile
  • package.json (scripts and lint config sections), Cargo.toml, go.mod, tsconfig.json

Read each file found. Extract every actionable rule, convention, or constraint. Compile them into a Project Rules Checklist — one line per rule, with the source file and its directory scope referenced (e.g. rules from src/backend/CLAUDE.md apply only to files under src/backend/). Root-level files apply globally. When evaluating compliance in Step 5, only apply each rule to files within its scope.

If the two worktrees have different guideline files, note the differences — this itself is a finding.

Step 3: Identify the Comparison Surface

Determine which files to compare. Use one of these strategies depending on context:

Strategy A — Common ancestor diff (preferred when worktrees share history):

# Files changed in A since divergence
git -C <worktree-A> diff --name-only $MERGE_BASE HEAD

# Files changed in B since divergence
git -C <worktree-B> diff --name-only $MERGE_BASE HEAD

Strategy B — Direct diff (when worktrees are independent):

diff -rq --exclude='.git' <worktree-A> <worktree-B> | head -200

If the output reaches exactly 200 lines, warn the user that the file list was truncated and suggest narrowing the comparison scope with a focus area argument.

Strategy C — Focused (when user specified a file or directory): Compare only the specified path(s) across both worktrees.

Build the File Comparison Manifest — a list of file pairs to compare, categorized:

  • Files modified in both (direct comparison)
  • Files only in A (unique to A's approach)
  • Files only in B (unique to B's approach)
  • Files identical in both (skip these)

Step 4: Deep Analysis — Parallel Agents

Dispatch three parallel agents (Agent tool, subagent_type: "general-purpose"). All three run in a single message. Each agent receives the File Comparison Manifest and the Project Rules Checklist from Step 2.

Agent 1 — Correctness & Logic

"You are reviewing two code solutions side by side. Read the following files from both worktrees and evaluate:

  1. Correctness: Does each solution produce correct results? Check edge cases, error paths, race conditions, off-by-one errors.
  2. Error handling: Are errors caught at boundaries, propagated meaningfully, not swallowed?
  3. Type safety: Are types precise? Are escape hatches (any, Object, void*) minimized?
  4. Security: Check OWASP top 10 — injection, XSS, path traversal, secrets in code.

For each criterion, state which worktree is stronger and cite specific file:line evidence.

Worktree A: <path-A> Worktree B: <path-B> Files to compare: <manifest> Project rules: <checklist>"

Agent 2 — Design & Architecture

"You are reviewing two code solutions side by side. Read the following files from both worktrees and evaluate:

  1. Readability & clarity: Names, control flow, comments, formatting.
  2. DRY: Duplication, reuse of existing utilities.
  3. SOLID principles: Single responsibility, open/closed, dependency inversion — applied pragmatically.
  4. Separation of concerns: Business logic vs I/O vs presentation.
  5. Complexity: Cyclomatic complexity, nesting depth, cognitive load.
  6. API & interface design: Function signatures, public surface area, consistency.

For each criterion, state which worktree is stronger and cite specific file:line evidence.

Worktree A: <path-A> Worktree B: <path-B> Files to compare: <manifest> Project rules: <checklist>"

Agent 3 — Practices, Testing & Compliance

"You are reviewing two code solutions side by side. Read the following files from both worktrees and evaluate:

  1. Testing: Coverage, test quality, edge case tests, alignment with project test patterns.
  2. Naming & conventions: Adherence to project naming conventions found in linter configs and contribution docs.
  3. Git hygiene: Commit atomicity, message quality, minimal diff, no debug artifacts.
  4. Performance: Unnecessary allocations, algorithmic complexity, appropriate data structures.
  5. Project guideline compliance: Check every rule in the Project Rules Checklist below. Flag each violation with the rule and source file.

For each criterion, state which worktree is stronger and cite specific file:line evidence.

Worktree A: <path-A> Worktree B: <path-B> Files to compare: <manifest> Project rules: <checklist>"

Step 5: Synthesize and Score

Collect findings from all three agents. For each of the 15 evaluation criteria (see references/evaluation-criteria.md), assign a score (1-5) to each worktree based on agent findings:

#CriterionWorktree AWorktree BNotes
1Correctness
2Readability & Clarity
3DRY
4SOLID Principles
5Error Handling
6Security
7Testing
8Performance
9Naming & Conventions
10Separation of Concerns
11Complexity
12Type Safety
13API & Interface Design
14Git Hygiene
15Project Guideline Compliance

Compute the totals. Do NOT use a simple sum as the verdict — weigh correctness and security higher than naming and git hygiene. Use this weighting:

WeightCriteria
3xCorrectness, Security
2xError Handling, Testing, Project Guideline Compliance
1xAll others

Step 6: Present the Verdict

Present to the user with this structure:

## Code Comparison: Worktree A vs Worktree B

### Summary
<2-3 sentence verdict: which solution is better overall and the primary reasons why>

### Scorecard
<the scoring table from Step 5, filled in with scores and notes>

### Weighted Totals
- **Worktree A**: <weighted score> / <max possible>
- **Worktree B**: <weighted score> / <max possible>

### Key Differentiators
<Top 3-5 criteria where the solutions differ most, with specific code citations>

#### Where A is Stronger
- <criterion>: <evidence with file:line>

#### Where B is Stronger
- <criterion>: <evidence with file:line>

### Project Guideline Violations
<List every violation found, grouped by worktree, with rule source>

### Recommendations
<If neither solution is clearly superior, describe how to combine the best parts of each.
 If one is clearly better, note any specific improvements it could still make.>

End by asking: "Would you like me to go deeper on any specific criterion, or apply the best parts of both solutions into a combined implementation?"

Constraints

  • Read-only: Do NOT modify any files in either worktree. This is a review, not an implementation.
  • Evidence-based: Every claim must cite a specific file:line from one of the worktrees. No vague assertions.
  • Fair: Do not favor one worktree over the other by default. Let the evidence decide.
  • Proportional: Scale depth to the size of the diff. A 5-line change doesn't need 15 criteria analyzed in depth — focus on what matters. A 500-line change warrants thorough analysis across all criteria.
  • No phantom references: Every file:line citation must be verified against the actual code.
  • Project-aware: The Project Rules Checklist from Step 2 is mandatory. Compliance with project guidelines is not optional.

Additional Resources

See references/evaluation-criteria.md (bundled with this skill) for detailed scoring guidance and criteria definitions.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.