parallel-worktrees
Run multiple AI coding agent sessions in parallel using git worktrees — each agent isolated in its own worktree, working on a separate branch. Use this skill whenever the user wants to: run two or more AI agents simultaneously on different features or bugs, set up isolated agent workspaces in the same repo, push parallel branches to GitHub and open/update PRs, coordinate between concurrent agent sessions, or clean up after merging. Triggers on: "parallel agents", "multiple agent sessions", "git worktree", "run agents in parallel", "work on two things at once", "isolated agent workspace", "spin up another agent", or any request involving simultaneous AI-assisted development streams.
Best use case
parallel-worktrees is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Run multiple AI coding agent sessions in parallel using git worktrees — each agent isolated in its own worktree, working on a separate branch. Use this skill whenever the user wants to: run two or more AI agents simultaneously on different features or bugs, set up isolated agent workspaces in the same repo, push parallel branches to GitHub and open/update PRs, coordinate between concurrent agent sessions, or clean up after merging. Triggers on: "parallel agents", "multiple agent sessions", "git worktree", "run agents in parallel", "work on two things at once", "isolated agent workspace", "spin up another agent", or any request involving simultaneous AI-assisted development streams.
Teams using parallel-worktrees should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/parallel-worktrees/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How parallel-worktrees Compares
| Feature / Agent | parallel-worktrees | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Run multiple AI coding agent sessions in parallel using git worktrees — each agent isolated in its own worktree, working on a separate branch. Use this skill whenever the user wants to: run two or more AI agents simultaneously on different features or bugs, set up isolated agent workspaces in the same repo, push parallel branches to GitHub and open/update PRs, coordinate between concurrent agent sessions, or clean up after merging. Triggers on: "parallel agents", "multiple agent sessions", "git worktree", "run agents in parallel", "work on two things at once", "isolated agent workspace", "spin up another agent", or any request involving simultaneous AI-assisted development streams.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# Parallel Worktrees
Run multiple AI coding sessions in parallel — each isolated in its own git
worktree, pushing to its own branch, opening its own PR.
## When to Use This Skill
Activate when:
- User wants to run two or more AI agents on different features/bugs at once
- User asks about `git worktree` for agent sessions
- User wants parallel PRs from a single repo without multiple clones
- User needs to set up, coordinate, or clean up concurrent agent workspaces
## Decision Tree
```
What does the user need?
Start a new parallel session?
→ Create a worktree + branch (Lifecycle §1–2)
→ Open a terminal/agent session pointed at the worktree path
→ Brief the agent: "Work only in <worktree-path>. Branch: <branch-name>."
Push and open a PR?
→ git push -u origin <branch>
→ gh pr create (GitHub PR Sync reference)
→ Note related PRs in the description
Sync a worktree with the latest main?
→ Inside the worktree: git fetch origin && git rebase origin/main
→ Never merge across worktrees directly
Merge and clean up?
→ Merge PR on GitHub
→ git worktree remove <path> && git branch -d <branch>
→ git worktree prune
Hit an error?
→ "already checked out" → branch open elsewhere; use a new branch name
→ ".git/index.lock" → two processes on same worktree; one agent per worktree
→ Detached HEAD → git switch -c <new-branch> inside the worktree
→ Stale entry after dir deleted → git worktree prune
```
## Core Concepts
**Worktree vs clone** — A worktree shares the same `.git` directory as the
main checkout. No double-fetch, no disk waste. Each worktree checks out a
*different* branch. Isolated at the filesystem level; same object store.
**One agent, one worktree, one branch** — This is the cardinal rule. Two
agents sharing a worktree will corrupt each other's index. Two agents on the
same branch will produce conflicting history.
**PRs as the coordination channel** — Agents communicate intent through PR
titles, descriptions, and comments — not through shared files or direct
worktree reads.
## Layout Convention
Keep worktrees as siblings of the repo root to avoid `.gitignore` noise:
```
~/projects/
myrepo/ ← main checkout (main branch)
myrepo-wt/ ← worktree root (sibling dir)
feat/auth/ ← worktree for branch feat/auth
fix/login-bug/ ← worktree for branch fix/login-bug
```
## Lifecycle
### 1. Create a worktree
```bash
# New branch (most common)
git worktree add ../myrepo-wt/feat/auth -b feat/auth
# From an existing remote branch
git worktree add ../myrepo-wt/fix/login-bug origin/fix/login-bug
```
### 2. Brief the agent
Give the agent its workspace clearly:
```
Working directory: /home/user/projects/myrepo-wt/feat/auth
Branch: feat/auth
Scope: implement JWT authentication — do not touch files outside this scope
```
The agent operates entirely within this directory. It should have no awareness
of other worktrees.
### 3. Work and commit
Normal git flow inside the worktree — the agent uses `git add`, `git commit`
as usual. The branch is isolated from main and all sibling worktrees.
### 4. Push and open PR
```bash
git push -u origin feat/auth
gh pr create \
--title "feat(auth): implement JWT login" \
--body "Parallel session. Related: #<pr-number> (if any)."
```
See `references/github-pr-sync.md` for draft PRs, PR templates, and linking.
### 5. Sync with main
```bash
# Inside the worktree
git fetch origin
git rebase origin/main # keep history linear
```
Run this before opening a PR and before the final merge.
### 6. Merge and clean up
After the PR merges on GitHub:
```bash
# From the main repo (not inside the worktree)
git worktree remove ../myrepo-wt/feat/auth
git branch -d feat/auth
git worktree prune # removes stale metadata entries
```
## Branch Naming
Use a consistent pattern so agents (and humans) can parse ownership at a
glance:
```
<type>/<scope>/<short-description>
feat/auth/jwt-login
fix/api/null-pointer
chore/deps/upgrade-pnpm
agent/experiment/refactor-parser ← for exploratory agent sessions
```
## Pitfalls
| Symptom | Cause | Fix |
|---------|-------|-----|
| `fatal: 'branch' is already checked out` | Branch open in another worktree | Use a new branch name |
| `.git/index.lock` errors | Two processes on same worktree | One agent per worktree |
| Detached HEAD | Created from a commit SHA, not a branch | `git switch -c <new-branch>` |
| Worktree path gone after reboot | Dir deleted externally | `git worktree prune`, then recreate |
| `git worktree list` shows stale entries | Dir removed without `git worktree remove` | `git worktree prune` |
| Agent edits files in main checkout | Agent not scoped to worktree path | Re-brief agent with explicit working directory |
## References
Read these when you need more depth:
- `references/worktree-lifecycle.md` — Full command reference, flags, edge cases (multiple worktrees, bare repos, moving worktrees)
- `references/github-pr-sync.md` — PR creation, draft PRs, linking, status checks, merge strategies via `gh` CLI
- `references/agent-coordination.md` — Patterns for coordinating output across parallel sessions: sequencing, handoffs, shared state via PRs
## Setup & Activation
```bash
npx skills add codervisor/forge@parallel-worktrees -g -y
```
Auto-activates when: user mentions "worktree", "parallel agents", "multiple
agent sessions", or asks to work on several features simultaneously with AI.Related Skills
leanspec
The spec-coding methodology for AI-assisted development. Use when planning features, creating/refining/implementing/verifying specs, or organising a project. Works with whatever spec backend your team already uses — local markdown, GitHub Issues, Azure DevOps, Jira — by delegating platform-specific details to a LeanSpec adapter.
watch-ci
Watch GitHub Actions CI status for the current commit until completion. Use after pushing changes to monitor build results.
leanspec-development
Development workflows, commands, publishing, CI/CD, changelog management, and contribution guidelines for LeanSpec. Use when contributing code, fixing bugs, setting up dev environment, running tests or linting, working with the monorepo structure, looking up build/dev/test/publish/format/lint commands, preparing releases, publishing to npm, bumping versions, syncing package versions, testing dev builds, troubleshooting npm distribution, updating changelogs, triggering CI/CD workflows, monitoring build status, debugging failed runs, managing artifacts, checking CI before releases, or researching AI agent runners. Triggers include any development, scripting, publishing, CI/CD, changelog, or runner research task in this project.
github-integration
Enable the GitHub CLI (`gh`) in Claude Code cloud sessions and GitHub Copilot coding agent environments. Use this skill when: (1) setting up a project so cloud AI agents can use `gh` for PRs, issues, and releases, (2) configuring setup scripts or SessionStart hooks for `gh` installation, (3) adding `copilot-setup-steps.yml` for GitHub Copilot agents, (4) troubleshooting `gh` auth failures in cloud sessions, or (5) configuring `GH_TOKEN` for headless environments. Triggers on: "enable gh", "github integration", "Claude Code cloud setup", "copilot setup steps", "gh auth in cloud", "gh not working in cloud", "setup script", or any request involving GitHub CLI access from cloud-based AI coding agents.
agent-browser
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.
dispatching-parallel-agents
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
using-git-worktrees
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
parallel-agents
Multi-agent orchestration patterns. Use when multiple independent tasks can run with different domain expertise or when comprehensive analysis requires multiple perspectives.
using-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
parallel-agents
Multi-agent orchestration patterns. Use when multiple independent tasks can run with different domain expertise or when comprehensive analysis requires multiple perspectives.
dispatching-parallel-agents
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
superpowers-parallel-agents
Use when facing 2 or more independent tasks that can be worked on without shared state - dispatches parallel subagents using sessions_spawn for concurrent investigation and execution, adapted for OpenClaw