This skill should be used when the user asks to "fork", "race claude and codex", "dual implement", "run both models", "compare implementations", "implement with both", "fork it", or wants the same task implemented by both Claude Code and OpenAI Codex in parallel to pick the best result. Also triggered by the /fork command.
68
83%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Passed
No known issues
Implement the same task with both Claude Code and OpenAI Codex CLI in parallel git worktrees, then run the best-of skill to compare and select the superior implementation.
$ARGUMENTS
Verify both CLIs are available:
command -v claude || { echo "ERROR: claude CLI not found"; exit 1; }
CODEX=$(command -v codex || echo "$HOME/node_modules/.bin/codex")
test -x "$CODEX" || { echo "ERROR: codex CLI not found"; exit 1; }If either is missing, report the error and stop.
Record the current state:
REPO_ROOT=$(git rev-parse --show-toplevel)
BRANCH=$(git branch --show-current)
[ -z "$BRANCH" ] && { echo "ERROR: detached HEAD — checkout a branch first"; exit 1; }
SHORT_SHA=$(git rev-parse --short HEAD)Run git status --porcelain. If there are uncommitted changes, warn the user and ask whether to proceed — uncommitted changes will not be present in the worktrees — or abort.
Generate a short unique suffix:
SUFFIX=$(python3 -c "import time,hashlib; print(hashlib.sha256(str(time.time_ns()).encode()).hexdigest()[:8])")Create a temporary directory and two worktrees branching from the current HEAD:
FORK_DIR=$(mktemp -d "${TMPDIR:-/tmp}/fork-XXXXXX")
git worktree add "$FORK_DIR/claude-$SUFFIX" -b fork/claude-$SUFFIX HEAD
git worktree add "$FORK_DIR/codex-$SUFFIX" -b fork/codex-$SUFFIX HEADRecord the two worktree absolute paths and branch names — you will need them in every subsequent step.
Create a temp file for the implementation prompt:
PROMPT_FILE=$(mktemp /tmp/fork-prompt-XXXXXX)Write a self-contained implementation prompt to this file. The prompt must include:
$ARGUMENTS.Implement this change completely. Commit all your work with a clear commit message when done.This single prompt file is shared by both models so they receive identical instructions.
Launch both implementations simultaneously using two parallel Bash tool calls. Use a 600000 ms (10 minute) timeout on both.
Claude (in worktree 1):
cd <claude-worktree-path> && \
claude -p --dangerously-skip-permissions --verbose < "$PROMPT_FILE"Codex (in worktree 2):
cd <codex-worktree-path> && \
CODEX=$(command -v codex || echo "$HOME/node_modules/.bin/codex") && \
"$CODEX" exec --full-auto - < "$PROMPT_FILE"No -m or -c flags for Codex — the user's ~/.codex/config.toml supplies model and reasoning settings.
Both calls MUST be issued in the same message so they execute in parallel.
After both complete, check results:
A model "succeeded" if it exited zero AND produced at least one commit in its worktree (check with git log <original-branch>..HEAD --oneline in the worktree).
For each worktree, gather the implementation summary. Run these in parallel (two Bash calls):
cd <worktree-path> && \
echo "=== Commits ===" && \
git log --oneline <original-branch>..HEAD && \
echo "=== Stat ===" && \
git diff --stat <original-branch>..HEAD && \
echo "=== Diff ===" && \
git diff <original-branch>..HEADNote the results. Present a brief side-by-side summary to the user:
Invoke the /best-of skill, passing it:
$ARGUMENTS).The best-of skill will compare both implementations — correctness, code quality, test coverage, adherence to the prompt — and recommend which to adopt or how to combine the best parts.
Fallback — if the best-of skill is not installed or fails to load: perform an inline comparison yourself. Read the diffs from Step 7 and evaluate both implementations on:
Present the comparison under this structure:
## Claude's Implementation
<brief summary and assessment>
## Codex's Implementation
<brief summary and assessment>
## Verdict
<which is better and why, or how to combine>Then ask the user: "Which implementation would you like to adopt — Claude's, Codex's, a combination, or neither?"
Based on the best-of result or the user's choice:
Switch back to the original branch:
cd "$REPO_ROOT" && git switch <original-branch>Merge the winning branch:
git merge <winner-branch> --no-ff -m "Merge fork/<model>-$SUFFIX: <concise task summary>"If the user chose a hybrid (parts from each): cherry-pick or manually apply the recommended combination, then commit.
Always ask for user confirmation before merging.
Remove the temp prompt file:
rm -f "$PROMPT_FILE"Remove both worktrees:
git worktree remove "$FORK_DIR/claude-$SUFFIX" --force
git worktree remove "$FORK_DIR/codex-$SUFFIX" --force
git worktree prune
rm -rf "$FORK_DIR"Optionally delete the fork branches if the user no longer needs them:
git branch -D fork/claude-$SUFFIX fork/codex-$SUFFIXIf the user wants to keep a worktree for inspection, skip its removal and report the path.
8fe6eb4
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.