
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.
- Installs
- 60
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/onsager-ai/dev-skills --skill parallel-worktrees- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads parallel-worktrees automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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 worktreefor 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
# 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
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
# 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:
# 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 viaghCLIreferences/agent-coordination.md— Patterns for coordinating output across parallel sessions: sequencing, handoffs, shared state via PRs
Setup & Activation
npx skills add -g onsager-ai/dev-skills --skill parallel-worktrees -a claude-code -y
Auto-activates when: user mentions "worktree", "parallel agents", "multiple agent sessions", or asks to work on several features simultaneously with AI.
FAQ
What does the parallel-worktrees 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.
How do I install parallel-worktrees?
Run npx skills add https://github.com/onsager-ai/dev-skills --skill parallel-worktrees in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/parallel-worktrees/ (personal) or .claude/skills/parallel-worktrees/ (project).
Which AI agents can use parallel-worktrees?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is parallel-worktrees safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains parallel-worktrees?
It is published by onsager-ai in onsager-ai/dev-skills. It has 60 recorded installs.
More from onsager-ai/dev-skills
codegraph
onsager-ai/dev-skills
Pre-indexed code knowledge graph (MCP, SQLite + tree-sitter) for faster, lower-token exploration of brownfield codebases. Use when starting work on a repo larger than 500 files or when the task involves cross-file traversal — "where is X used", "what calls Y", "what breaks if I change Z", "trace flow from A to B", "explain this subsystem". Skip for single-file edits or sessions shorter than the cold-start cost. Triggers include "codegraph", "code graph", "index this repo", "where is X defined", "find callers of", "callees of", "blast radius of changing X", "explore this codebase". Cuts the grep + Read loops needed to orient, via O(1) SQLite lookups and FTS5 search over 8 MCP tools — but it's an unsound tree-sitter approximation, so grep stays the completeness backstop for renames/exhaustive callers.
git-commit
onsager-ai/dev-skills
Best practices for creating clean, atomic git commits with good messages. Use when: (1) staging and committing changes, (2) writing commit messages, (3) deciding what to group in a single commit, (4) handling pre-commit hook failures, (5) choosing between amend and new commit. Triggers on "commit", "stage", "git add", "write a commit message", or "commit my changes".
plan-dag
onsager-ai/dev-skills
Open the skill to read its SKILL.md instructions.
rust-node-ci
onsager-ai/dev-skills
Open the skill to read its SKILL.md instructions.
rust-npm-publish
onsager-ai/dev-skills
Open the skill to read its SKILL.md instructions.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.