agentleFS
eisbaweisbaw/mped-skills/skills/model-race/SKILL.md

model-race

Skill11 starsChanged 3 months agoMITView on GitHub

Race multiple AI models on the same task using cursor-agent-oneoff in isolated git worktrees. Creates worktrees, writes prompt, launches models in parallel, polls progress, merges the winner. General-purpose — works for any coding task, not just Lean proofs.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask the user (or extract from their message):

    line 12
  2. Very specific:

    Write to tmp/model-race-prompt.txt.

    line 41
  3. Distinctive:

    If no model produces a verified commit, report all as failed.

    line 151
  4. Distinctive:

    If cherry-pick conflicts, show the diff and let the user decide.

    line 170

≈ “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

/model-race — Multi-Model Race in Git Worktrees

Race 5 AI models on the same task. Each runs in an isolated git worktree. First to succeed wins. Merge the winner.

Step 1: Gather inputs

Ask the user (or extract from their message):

  • TASK: What the models should do (plain English description)
  • TARGET_FILES: Which files the models may modify
  • VERIFY_CMD: Command to check if the task is done (must exit 0 on success)
  • ONBOARDING_FILES (optional): Extra files to read for context. Defaults: README.md, CLAUDE.md
  • MODELS (optional): Which models to race. Defaults below.

Default models (top 5):

  1. gpt-5.4-xhigh
  2. claude-4.6-opus-max-thinking
  3. gpt-5.3-codex-xhigh
  4. grok-4-20-thinking
  5. gemini-3.1-pro

Step 2: Set up paths and names

ORIG_REPO=$(pwd)
TASK_SLUG=$(echo "$TASK" | tr ' ' '-' | tr -cd '[:alnum:]-' | head -c 40)
WORKTREE_DIR="${ORIG_REPO}/tmp"
mkdir -p "$WORKTREE_DIR"
echo "tmp/" >> .gitignore 2>/dev/null  # Ensure worktrees are gitignored

Worktree naming: tmp/worktree-<task_slug>-<model_name>/ Log naming: tmp/log-<task_slug>-<model_name>.log

Step 3: Write the shared prompt file

Write to tmp/model-race-prompt.txt. Key improvements from lessons learned:

  • Tell models their AVAILABLE TOOLS: read, bash, and file editing. NO grepToolCall — use bash with grep command instead.
  • Give absolute paths for the worktree and original repo.
  • Explicit "do not modify original" warning.
You are an AI coding agent working in a git worktree.

YOUR WORKING DIRECTORY: {WORKTREE_PATH} (this is where you should make changes)
ORIGINAL REPOSITORY: {ORIG_REPO} (DO NOT modify anything here)

IMPORTANT TOOL NOTES:
- You have: read (to read files), bash (to run commands), and file editing tools.
- There is NO grep tool. To search files, use bash: grep -n "pattern" ./path/to/file
- There is NO separate edit tool name like "editToolCall". Use your normal file editing capability.
- All file paths should be relative to your working directory (./) or absolute.

ONBOARDING — read these files first to understand the project:
{for each file in ONBOARDING_FILES}
- ./{file}
{end}

YOUR TASK:
{TASK}

FILES YOU MAY MODIFY (and only these):
{for each file in TARGET_FILES}
- ./{file}
{end}

TO VERIFY YOUR WORK:
{VERIFY_CMD}

WORKFLOW:
1. Read the onboarding files
2. Read the target files to understand current state
3. If helpful, search for patterns with: grep -n "pattern" ./file
4. Make your changes using file editing
5. Run the verify command. If it fails, read the error, fix, and retry.
6. When verify passes, commit: git add -A && git commit -m "model-race: {brief description}"

DO NOT push. DO NOT modify files outside the target list. DO NOT touch {ORIG_REPO}.

Step 4: Create worktrees and launch models SEQUENTIALLY

IMPORTANT: Launch models ONE AT A TIME, not in parallel. Each model's lake build can consume 5-15GB RAM. Running 5 in parallel = 50+GB = OOM + swap thrashing.

Strategy: Launch model 1, wait for it to finish or timeout (15 min), then launch model 2, etc. First model to pass verify wins — skip remaining models.

pkill -f cursor-agent-oneoff 2>/dev/null
sleep 1

MODELS=("gpt-5.4-xhigh" "claude-4.6-opus-max-thinking" "gpt-5.3-codex-xhigh" "grok-4-20-thinking" "gemini-3.1-pro")
PROMPT_TEMPLATE=$(cat tmp/model-race-prompt.txt)
WINNER=""

for i in "${!MODELS[@]}"; do
  [ -n "$WINNER" ] && break  # Skip remaining if we have a winner

  MODEL="${MODELS[$i]}"
  MODEL_SLUG=$(echo "$MODEL" | tr '.' '-')
  WT="${WORKTREE_DIR}/worktree-${TASK_SLUG}-${MODEL_SLUG}"
  BRANCH="race-${TASK_SLUG}-${MODEL_SLUG}"
  LOG="${WORKTREE_DIR}/log-${TASK_SLUG}-${MODEL_SLUG}.log"

  # Create worktree
  cd "$ORIG_REPO"
  git worktree add "$WT" -b "$BRANCH" HEAD 2>&1 | tail -1

  # Customize prompt with this worktree's absolute path
  PROMPT=$(echo "$PROMPT_TEMPLATE" | sed "s|{WORKTREE_PATH}|${WT}|g")

  # Launch and WAIT (sequential, not parallel)
  cd "$WT"
  echo "=== Running: $MODEL ==="
  timeout 3600 cursor-agent-oneoff --model "$MODEL" -p "$PROMPT" > "$LOG" 2>&1
  EXIT=$?

  echo "  $MODEL finished (exit=$EXIT)"
  echo "  Log: $LOG"

  # Check if it committed and verify passes
  HAS_COMMIT=$(cd "$WT" && git log --oneline -1 2>/dev/null | grep -c "model-race")
  if [ "$HAS_COMMIT" = "1" ]; then
    cd "$WT"
    if eval "$VERIFY_CMD" > /dev/null 2>&1; then
      echo "  *** WINNER: $MODEL ***"
      WINNER="$MODEL"
      WINNER_WT="$WT"
      WINNER_BRANCH="$BRANCH"
    else
      echo "  (committed but verify failed)"
    fi
  fi

  # Kill any lingering lean/lake processes before next model
  pkill -f "lean.*${MODEL_SLUG}" 2>/dev/null
  sleep 2
done

Step 5: (Sequential mode — no polling needed)

In sequential mode, each model runs to completion (or 15 min timeout) before the next starts. The winner is determined inline in Step 4. No polling loop needed.

If no model produces a verified commit, report all as failed.

Step 6: Inspect winner

cd "$WINNER_WT"
git log --oneline -1
git diff HEAD~1 --stat
# Run verify one more time
eval "$VERIFY_CMD"

Step 7: Merge winner into main repo

cd "$ORIG_REPO"
git cherry-pick "$WINNER_BRANCH"

If cherry-pick conflicts, show the diff and let the user decide.

Step 8: Kill remaining and clean up

pkill -f cursor-agent-oneoff 2>/dev/null

cd "$ORIG_REPO"
for i in "${!MODELS[@]}"; do
  MODEL="${MODELS[$i]}"
  MODEL_SLUG=$(echo "$MODEL" | tr '.' '-')
  WT="${WORKTREE_DIR}/worktree-${TASK_SLUG}-${MODEL_SLUG}"
  BRANCH="race-${TASK_SLUG}-${MODEL_SLUG}"
  git worktree remove "$WT" --force 2>/dev/null
  git branch -D "$BRANCH" 2>/dev/null
done

# Keep logs for analysis but clean worktrees
echo "Logs preserved in tmp/log-${TASK_SLUG}-*.log"

Step 9: Report

ModelStatusLog linesFiles changedCommittedVerifiedTime
...WON/FINISHED/RUNNING/CRASHEDNNY/NY/NNm

Also note tool failures per model (grep logs for "unknown tool").

Lessons learned (baked into the prompt)

  1. No grepToolCall: cursor-agent models try to use a grep tool that doesn't exist. The prompt explicitly says "use bash grep instead." This was the #1 failure mode (74 failures across 5 models in the first race).
  2. No editToolCall: same issue with edit. The prompt says "use your normal file editing capability."
  3. Absolute paths: models get confused about relative vs absolute. The prompt gives the exact worktree path.
  4. Original repo protection: models sometimes wander to the original repo. The prompt warns against it.
  5. Worktrees under repo/tmp/: keeps everything local, gitignored, easy to find.
  6. Model-named logs: log-task-gpt-5-4-xhigh.log is more readable than log-3.log.
  7. SEQUENTIAL not parallel: Each model's lake build can use 5-15GB RAM. 5 models parallel = 50GB+ = OOM + swap death. Run one at a time with 15min timeout. First winner stops the race.
  8. Kill lean between models: Lean processes linger after cursor-agent exits. Always pkill -f lean between models to free RAM.
  9. Anti-cheating: Models cheat with validHoare_weaken_trivial_post (trivializes postcondition) or prove against fused bodies (doesn't chain to C). Prompt must explicitly forbid these patterns. Verify after merge.

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.