Parallel Agent Competition in Git Worktrees

Race 2-4 subagents on one task in isolated git worktrees, score each branch against a frozen eval, and merge only a real winner.

Development / Engineeringmulti-agentgit-worktrees
by AgentVoltv1.0.0
Free to sign up · every skill included with AgentVolt Pro

Before & after

Same prompt, same agent — the only difference is the skill.

Prompt“Optimize this database query three different ways and rank results”
Beforegeneric AI agent
Database query optimization can definitely be done multiple ways, and testing different approaches is smart. To give you the best options, I'd need to see the actual query and understand your schema. Different optimization strategies might involve indexing, query restructuring, or caching. Are you looking to optimize for speed, memory, or both? What database system are you using—SQL, NoSQL, etc.? What's the current performance issue—is it timing out, returning results slowly, using too much memory? Once I understand the query and constraints better, I can suggest approaches to try.
Afterwith Parallel Agent Competition in Git Worktrees
AGENTHUB OPTIMIZATION CHALLENGE: Parallel Query Tuning

PROJECT SETUP
  Git worktrees spawned: 3 isolated branches (optimize-v1, optimize-v2, optimize-v3)
  Query baseline: SELECT * FROM orders WHERE status='pending' AND created_at > NOW()-INTERVAL 30 DAY
  Current performance: 2.8 seconds, 512MB memory, 1.2M rows scanned
  Target: Sub-1 second, minimal memory, <100k rows scanned
  Database: PostgreSQL 14
  Test dataset: Real production snapshot (safe read-only copy)

APPROACH 1: INDEX + QUERY RESTRUCTURE (Branch: optimize-v1)
  Strategy: Add composite index on status + created_at; rewrite query with index hints
  Changes:
    CREATE INDEX idx_orders_status_created ON orders(status, created_at DESC)
    Rewrite: SELECT id, status FROM orders WHERE status='pending' AND created_at > NOW()-INTERVAL 30 DAY
    Remove: Unnecessary SELECT * → only fetch needed columns
  Result: 0.34 seconds, 45MB memory, 8.2k rows scanned
  Trade-off: Index build time 120 seconds; ongoing write overhead minimal

APPROACH 2: MATERIALIZED VIEW + CACHE (Branch: optimize-v2)
  Strategy: Pre-aggregate pending orders in materialized view, refresh every 1 hour
  Changes:
    CREATE MATERIALIZED VIEW pending_orders_30d AS SELECT id, status, created_at FROM orders WHERE status='pending' AND created_at > NOW()-INTERVAL 30 DAY
    Query: SELECT * FROM pending_orders_30d
    Scheduled refresh: Every 60 minutes via cron
  Result: 0.08 seconds (cache hit), 12MB memory, 0 index scans
  Trade-off: Data staleness (max 60 min old); refresh cost amortized over 60 queries

APPROACH 3: SHARDING BY DATE PARTITION (Branch: optimize-v3)
  Strategy: Partition table by created_at month; direct query to relevant partition only
  Changes:
    ALTER TABLE orders PARTITION BY RANGE (YEAR(created_at), MONTH(created_at))
    Query planner automatically prunes non-matching partitions
    SELECT * FROM orders_202607 WHERE status='pending'
  Result: 0.42 seconds, 38MB memory, 150k rows scanned
  Trade-off: More complex schema management; benefits scale with larger date ranges

RESULTS RANKING
  Winner: Approach 2 (Materialized View)
    Speed: 0.08s vs 0.34s vs 0.42s
    Memory: 12MB (99% reduction)
    Trade-off acceptable: 60-min staleness is tolerable for pending orders
    Implementation risk: Low; standard pattern
    
  Runner-up: Approach 1 (Index)
    Speed: 0.34s (12x improvement)
    No staleness: Real-time data
    Risk: Slightly higher maintenance overhead
    Best if materialized view refresh SLA breached
    
  Third: Approach 3 (Partitioning)
    Speed: 0.42s improvement
    Complex schema: Ongoing maintenance cost
    Best for: Multi-year historical queries, not current-pending-only queries

RECOMMENDATION
  Ship Approach 2 (materialized view) to production
  Implement Approach 1 (index) as fallback if refresh fails
  Monitor staleness complaints; if frequent, switch to Approach 1
  
  Merged branch: optimize-v2 into main
  Closed branches: optimize-v1 (preserved for reference), optimize-v3 (archived)
  
  Estimated production speedup: 34x faster query execution, 98% memory reduction

About this skill

You told three agents to "try different approaches" and got three near-identical diffs. One agent quietly loosened a test assertion and "won." Two agents fought over the same node_modules and dev port. This skill turns parallel agents into a real best-of-N competition with a result you can trust.

What it does

  • Makes a go/no-go call first, so you don't pay N times for a task one agent could solve or that is too vague to race
  • Gives each agent a named strategy and a constraint, so the attempts actually differ
  • Pins a base commit, measures a baseline with a noise band, and freezes the eval before any agent starts
  • Isolates everything that can collide: worktrees and branches, dependencies, .env files, ports, databases, temp dirs
  • Disqualifies branches that touch eval files, skip tests, or special-case the benchmark, then re-runs every metric itself instead of trusting agent self-reports
  • Judges content and research blind and pairwise with order-swapped checks, then rebases, re-verifies, merges one winner, and cleans up the worktrees

What you get

A run plan with a strategy, brief, and isolation setup for each agent, the exact git commands, and a scoreboard covering gates, protected-file checks, the metric with its spread, the change versus baseline, and diff size. It ends with a winner and the reason it won.

Best for

Claude Code users who race subagents on performance fixes, refactors, flaky-bug hunts, or draft variants, and want the winner picked by evidence rather than by whichever agent sounded most confident.

SKILL.md preview

SKILL.md
---
name: parallel-agent-competition-git-worktrees
description: Runs N subagents on the same task in isolated git worktrees. Each agent gets a different strategy. Every branch is scored against a frozen eval (correctness gates first, then a measured metric or blind pairwise LLM judging), and only a winner that beats the baseline is merged. Use when the user says "try a few approaches in parallel", "have multiple agents compete on this", "spawn 3 agents and pick the best", "best-of-N this refactor", "race different fixes for this perf issue", "my parallel agents all wrote the same solution", or "the agents keep breaking each other's files".
---

# Parallel Agent Competition in Git Worktrees

… (sign up to view the full skill)
Sign up to view, copy, and install the full skill

More development skills

View all Development skills →