Safe Git Worktrees for Parallel Coding

Create, verify, and clean up Git worktrees for parallel coding while preserving local changes and avoiding busy branches.

Development / Engineeringgit-worktreesparallel-coding
by AgentVoltv1.0.0
Free to sign up · every skill included with AgentVolt Pro

Before & after

Same prompt, same agent — the only difference is the skill.

Prompt“Let me work on two branches in parallel without git conflicts”
Beforegeneric AI agent
You could create separate branches and switch between them, but that means your working directory changes each time. You might also use stashing to save your work temporarily. With git, you can usually handle multiple branches by committing your changes before switching. The downside is managing context in your head and avoiding mistakes. Would you want to use a separate clone of the repo to work in parallel?
Afterwith Safe Git Worktrees for Parallel Coding
GIT WORKTREES SETUP

COMMAND SEQUENCE
• git worktree add ../fix-auth-bug origin/main
• git worktree add ../dashboard-redesign origin/develop

RESULT: Two isolated directories, same repo
~/agentvolt (main)
~/agentvolt-fix-auth-bug (main base, clean)
~/agentvolt-dashboard-redesign (develop base, clean)

EACH WORKTREE
• Separate .git/index (no conflicts)
• Separate node_modules (can install different versions)
• Independent git status, commits, branches
• Share .git/objects (efficient storage)

WORKFLOW
1. Session A: cd ../fix-auth-bug; make changes; git add/commit
2. Session B: cd ../agentvolt-dashboard-redesign; parallel work
3. Push both to their branches independently
4. Cleanup after merge: git worktree remove ../fix-auth-bug

AVOID
• Don't check out same branch in two worktrees (git will error)
• Don't share unstaged changes between them

BENEFIT: Two full Claude Code sessions in parallel, true isolation, no context switching tax

About this skill

“I need to fix production, but my feature branch is halfway done.” Create a separate working directory without stashing or disturbing the current checkout. This workflow catches occupied branches, ambiguous starting points, shared runtime resources, and unfinished work before they become collisions or lost changes.

What it does

  • Maps existing worktrees to their paths, branches, and current commits before creating another checkout.
  • Creates a new task branch from an explicit base commit, or safely attaches an existing available branch.
  • Verifies the new checkout's branch, commit, clean state, and shared Git object store.
  • Identifies dependencies, environment files, ports, databases, and caches that Git worktrees do not isolate.
  • Produces a concise handoff with the exact working directory, branch, base, and validation results.
  • Removes completed worktrees after checking local files and commit preservation, with recovery steps for moved or missing directories.

What you get

An appropriately sized command sequence or completed setup with a verified handoff. Cleanup requests include a preservation check and readback of the remaining worktrees; commands that have not been executed are labeled clearly.

Best for

Developers running multiple Claude Code sessions, maintaining a feature while handling a hotfix, or comparing branches in separate working directories.

SKILL.md preview

SKILL.md
---
name: safe-git-worktrees-for-parallel-coding
description: Create, verify, hand off, and remove Git worktrees for parallel coding using explicit base commits, branch occupancy checks, runtime isolation, and preservation gates. Use when the user says "set up a worktree", "run two coding sessions on this repo", "fix a hotfix without stashing", "this branch is already checked out", "my agents keep changing each other's files", "compare these branches side by side", or "clean up my old worktrees".
---

# Safe Git Worktrees for Parallel Coding

… (sign up to view the full skill)
Sign up to view, copy, and install the full skill

More development skills

View all Development skills →