Skip to content
Workflow · AI agents

Parallel agents in git worktrees

Rules and two skills for running several coding agents at once, one task per git worktree: isolation, ports, dependencies, rebasing and clean-up.

Verified install Not agent-tested v1.0.0 MIT updated git
Equips
  • 1 1 Rules
  • 2 2 Skills
  • – 0 MCP

Running three or four agents in parallel is now routine, and the tools have caught up: Claude Code has --worktree and worktree-isolated subagents, Codex manages worktrees, and gh can create one per issue. What breaks is the etiquette: agents editing the main checkout, two dev servers on one port, a shared database migrated twice, or a worktree deleted with unpushed work. This loadout gives every agent the same rules and a start and land procedure.

What's in it

  • Isolation rules: own directory, own branch, no branch switching
  • Port and shared-resource conventions so agents do not collide
  • Start skill: worktree outside the repo, lockfile install, baseline test run
  • Land skill: rebase, checks, PR, safe clean-up with git branch -d
  • Notes for claude --worktree, isolation: worktree subagents, Codex managed worktrees and gh issue develop --worktree

You'll need

  • Tools: git
Level 1 · automated

Verification

Verified install

Checked at commit 316f4bc · 9 passed, 0 failed, 1 not applicable

CheckResultWhat we found
Listinglisting.yaml matches the schema and declares every file in the folder. Pass
Schema valid; 5 files declared, none missing or extra
  • tested.status: untested (agent tests are separate from Level 1)
Files parseJSON parses; SKILL.md and .mdc front matter is valid YAML with the fields each agent needs; code fences are closed. Pass All 5 files parse; front matter valid
AdaptersCLAUDE.md imports @AGENTS.md, GEMINI.md imports @./AGENTS.md, and both match the generator. Pass
CLAUDE.md and GEMINI.md import AGENTS.md and are up to date
  • CLAUDE.md: matches the generator
  • GEMINI.md: matches the generator
Install pathsEvery file lands where each agent documents it, with no collisions, and the laid-out project is re-discovered correctly. Pass
Correct paths for all 6 agents; layouts re-discovered
  • Claude Code: 4 files, 2 skills in .claude/skills/
  • Codex CLI: 3 files, 2 skills in .agents/skills/
  • Cursor: 3 files, 2 skills in .agents/skills/
  • Gemini CLI: 4 files, 2 skills in .agents/skills/
  • Antigravity CLI: 3 files, 2 skills in .agents/skills/
  • GitHub Copilot: 3 files, 2 skills in .agents/skills/
MCP configmcp.json is structurally valid, converts to each agent's format, declares no literal secrets, and referenced packages exist on npm/PyPI. Not applicable No MCP servers in this loadout
Safety scanThe intake scanner finds no credentials, risky shell, hidden Unicode or prompt-injection wording, and the listing's network flag is honest. Pass
Clean: no credentials, risky shell or hidden text
  • Scanner intake-precheck/1: verdict clean; network no (listing says no)
ReferencesLinks and file paths between the loadout's files resolve, including for each agent's installed layout. Pass 2 references between files resolve for every agent
Size limitsFile count and sizes are within the submission limits; SKILL.md bodies stay under 500 lines. Pass
5 files, 4.9 KB total; largest AGENTS.md 1.7 KB
  • Limits: 30 files, 32 KB per file, 128 KB total, 500 lines per skill or rule
LicenceA recognised SPDX licence, with the licence text available. Pass MIT, by Agent Loadout; text in the repository LICENSE
Starter buildA minimal fixture project with the loadout applied installs and builds or type-checks, and the loadout's own code examples compile. Pass
The worktree commands in the start-worktree and land-worktree skills run cleanly on a scratch repository: create, commit, rebase, refuse an unmerged delete, remove and prune
  • Applied 7 loadout files at every agent's paths
  • ✓ skills name the exact commands: bash -c s=.agents/skills; grep -q 'git worktree add ../' $s/start-worktree/SKILL.md && grep -q 'git worktree remove' $s/land-worktree/SKILL.md && grep -q 'git branch -d' $s/land-worktree/SKILL.md && grep -q 'force-with-lease' $s/land-worktree/SKILL.md && echo commands present
  • ✓ start, land and clean up a worktree: bash -c set -e; export GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@example.com GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@example.com; root=$(mktemp -d); git init -q -b main $root/origin.git --bare; git clone -q $root/origin.git $root/app 2>/dev/null; cd $root/app; echo a > a.txt; git add a.txt; git commit -qm init; git push -q origin main; git fetch -q origin; git worktree add -q ../app-task -b agent/task origin/main; cd ../app-task; test "$(git branch --show-cur
  • Covers: git worktree add outside the repository on a new agent/<task> branch from origin/main
  • Covers: Rebasing the worktree branch onto new upstream commits
  • Covers: git branch -d refuses an unmerged branch, as the land skill relies on
  • Covers: git worktree remove and prune leave only the main checkout

What this means: a script checked the files themselves: they parse, they install where each agent looks, any MCP config is sound, the safety scan is clean, references between files resolve, and, where a free and repeatable fixture exists, a small starter project builds with the loadout applied. No AI agent was run. Per-agent results ("tested with agent") are separate and stay untested until an agent actually runs.

Install

Choose your agent. Run the commands from your project root, or download a zip already laid out in the right folders.

Claude Code reads CLAUDE.md (imports AGENTS.md with @AGENTS.md) and skills from .claude/skills/.

Download zip
curl -fsSL --create-dirs -o AGENTS.md https://loadout.jnw-it.com/raw/parallel-agents-worktrees/1.0.0/AGENTS.md
curl -fsSL --create-dirs -o CLAUDE.md https://loadout.jnw-it.com/raw/parallel-agents-worktrees/1.0.0/CLAUDE.md
curl -fsSL --create-dirs -o .claude/skills/start-worktree/SKILL.md https://loadout.jnw-it.com/raw/parallel-agents-worktrees/1.0.0/skills/start-worktree/SKILL.md
curl -fsSL --create-dirs -o .claude/skills/land-worktree/SKILL.md https://loadout.jnw-it.com/raw/parallel-agents-worktrees/1.0.0/skills/land-worktree/SKILL.md
FileGoes to
AGENTS.mdAGENTS.md
CLAUDE.mdCLAUDE.md
skills/start-worktree/SKILL.md.claude/skills/start-worktree/SKILL.md
skills/land-worktree/SKILL.md.claude/skills/land-worktree/SKILL.md

Already have an AGENTS.md or CLAUDE.md? The commands above overwrite it — download the file instead and merge the sections you want.

Files

Rules AGENTS.md Rules for agents working in parallel worktrees. 25 lines
Download Raw
# AGENTS.md: parallel agents in git worktrees

Several agents may work on this repository at once, each in its own git worktree on its own branch.
These rules keep them from colliding.

## Inside a worktree
- Work only inside your worktree directory. Never edit, check out or reset files in the main checkout or another worktree.
- One task per worktree, one branch per task: `agent/<short-task-name>`.
- Never switch branches inside a worktree; finish or abandon the task instead.
- Commit small and often. Uncommitted work in a worktree is easy to lose.
- Each worktree has its own `node_modules`, `.venv` and build output. Install dependencies in the worktree.
- Dev servers: use the port the human assigned, or `3000 + N` where N is your worktree number. Never kill a process you did not start.
- Shared resources (one local database, one emulator) are single-writer. Ask before migrating or seeding a shared database.
- Secrets: do not copy `.env` files between worktrees yourself. Ask the human to provide them.

## Starting and finishing
- Start with the `start-worktree` skill. Finish with the `land-worktree` skill.
- Do not delete a worktree or its branch until its pull request is merged, or the human says to drop it.

## Tool-specific notes
- Claude Code: `claude --worktree <name>` starts a session in a new worktree. A subagent with `isolation: worktree` gets a
  temporary worktree branched from the default branch, not from your current HEAD; commit and push what it needs first.
- Codex: the app and CLI can create managed worktrees (Codex 0.162+). Treat them the same way.
- GitHub CLI: `gh issue develop <number> --worktree` creates a linked branch and a worktree for an issue (gh 2.99+).
Adapter CLAUDE.md Imports AGENTS.md for Claude Code. 10 lines
Download Raw
# CLAUDE.md

@AGENTS.md

## Claude Code notes
- Skills from this loadout live in `.claude/skills/`: `start-worktree`, `land-worktree`. Use them when their description matches the task.
- Follow AGENTS.md above; where this file and AGENTS.md disagree, AGENTS.md wins.

<!-- From the Agent Loadout "Parallel agents in git worktrees" v1.0.0 — https://loadout.jnw-it.com/loadouts/parallel-agents-worktrees/ -->
Adapter GEMINI.md Imports AGENTS.md for Gemini CLI. 10 lines
Download Raw
# GEMINI.md

@./AGENTS.md

## Gemini CLI notes
- Skills from this loadout live in `.agents/skills/`: `start-worktree`, `land-worktree`. Use them when their description matches the task.
- Follow AGENTS.md above; where this file and AGENTS.md disagree, AGENTS.md wins.

<!-- From the Agent Loadout "Parallel agents in git worktrees" v1.0.0 — https://loadout.jnw-it.com/loadouts/parallel-agents-worktrees/ -->
Skill skills/start-worktree/SKILL.md Create a worktree for one task with deps, port and baseline tests. 21 lines
Download Raw
---
name: start-worktree
description: Create a git worktree and branch for one task, install dependencies and pick a free port. Use before starting a task that will run alongside other agents.
---

# Start a worktree

Inputs: a short task name (kebab-case) and the base branch (default `main`; use the repo's default branch).

1. From the main checkout, update the base: `git fetch origin`.
2. Create the worktree next to the repository, never inside it:
   `git worktree add ../$(basename "$PWD")-<task> -b agent/<task> origin/<base>`
   If the branch exists already, stop and ask; another agent may own it.
3. `cd` into the new directory. Confirm with `git status` and `git branch --show-current`.
4. Install dependencies with the project's lockfile command (`npm ci`, `pnpm install --frozen-lockfile`, `uv sync`, …).
5. Environment files: list which ones the project needs (`ls ../<main-checkout>/.env*` names only) and ask the human to copy them.
6. Pick a port: `git worktree list` gives N; use `3000 + N` unless the human assigned one. Record it in your first report.
7. Run the test command once, before changing anything, so later failures are known to be yours.

Report: worktree path, branch, port, baseline test result.
Skill skills/land-worktree/SKILL.md Rebase, check, open a PR and clean up after merge. 19 lines
Download Raw
---
name: land-worktree
description: Rebase a finished worktree branch, run checks, open a pull request and clean up after merge. Use when a task in a worktree is done.
---

# Land a worktree

1. Commit everything. `git status` must be clean.
2. `git fetch origin && git rebase origin/<base>`. On conflicts in files you did not change, stop and ask; another agent's work may be landing.
3. Run the full check command (tests, lint, type-check). Fix failures you caused; report others.
4. Push the branch: `git push -u origin agent/<task>`. Never push to `<base>` directly, never force-push a shared branch.
   After a rebase of your own unshared branch, `git push --force-with-lease` is the only acceptable force.
5. Open a pull request (`gh pr create --fill` then edit the body): what changed, how it was tested, anything left.
6. Stop any dev server you started in this worktree.
7. After the human merges, clean up from the main checkout:
   `git worktree remove ../<repo>-<task>` then `git branch -d agent/<task>` and `git worktree prune`.
   `git branch -d` refuses unmerged branches. After a squash or rebase merge on GitHub it refuses too, because the
   commits differ: confirm with `gh pr view --json state` that the PR is merged, then ask the human before using `-D`.

All files: source zip · Licence MIT · By Agent Loadout · First listed

Credits

Public work that inspired this loadout. The wording here is our own; follow the links for the originals.

Installing and testing

How do I install Parallel agents in git worktrees in Claude Code?

From your project root, put AGENTS.md, CLAUDE.md, skills/start-worktree/SKILL.md at .claude/skills/start-worktree/SKILL.md, skills/land-worktree/SKILL.md at .claude/skills/land-worktree/SKILL.md. The "Claude Code" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/parallel-agents-worktrees/claude-code.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Parallel agents in git worktrees in Codex CLI?

From your project root, put AGENTS.md, skills/start-worktree/SKILL.md at .agents/skills/start-worktree/SKILL.md, skills/land-worktree/SKILL.md at .agents/skills/land-worktree/SKILL.md. The "Codex CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/parallel-agents-worktrees/codex.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Parallel agents in git worktrees in Cursor?

From your project root, put AGENTS.md, skills/start-worktree/SKILL.md at .agents/skills/start-worktree/SKILL.md, skills/land-worktree/SKILL.md at .agents/skills/land-worktree/SKILL.md. The "Cursor" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/parallel-agents-worktrees/cursor.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Parallel agents in git worktrees in Gemini CLI?

From your project root, put AGENTS.md, GEMINI.md, skills/start-worktree/SKILL.md at .agents/skills/start-worktree/SKILL.md, skills/land-worktree/SKILL.md at .agents/skills/land-worktree/SKILL.md. The "Gemini CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/parallel-agents-worktrees/gemini-cli.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Parallel agents in git worktrees in Antigravity CLI?

From your project root, put AGENTS.md, skills/start-worktree/SKILL.md at .agents/skills/start-worktree/SKILL.md, skills/land-worktree/SKILL.md at .agents/skills/land-worktree/SKILL.md. The "Antigravity CLI" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/parallel-agents-worktrees/antigravity-cli.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

How do I install Parallel agents in git worktrees in GitHub Copilot?

From your project root, put AGENTS.md, skills/start-worktree/SKILL.md at .agents/skills/start-worktree/SKILL.md, skills/land-worktree/SKILL.md at .agents/skills/land-worktree/SKILL.md. The "GitHub Copilot" tab on this page has the curl commands, or download https://loadout.jnw-it.com/download/parallel-agents-worktrees/copilot.zip, which is already laid out. Do not overwrite an existing AGENTS.md or CLAUDE.md; merge it.

Has Parallel agents in git worktrees been tested?

It passed the Level 1 automated install checks on 2026-10-17: the files parse, install to each agent's documented paths, and pass the safety scan. No AI agent has run it yet, so no agent pass or fail is claimed.

More for Claude Code, Codex, Cursor, Gemini CLI, Antigravity CLI and GitHub Copilot.