Safe Git Worktrees for Parallel Coding
Create, verify, and clean up Git worktrees for parallel coding while preserving local changes and avoiding busy branches.
Before & after
Same prompt, same agent — the only difference is the skill.
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?
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
---
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)More development skills
View all Development skills →Performance Bottleneck Profiling: Node, Python, Go
Classifies a slowdown, gives exact profiler commands, reads the output, and proves the fix with same-conditions p95/p99 numbers.
Feature Scaffolding with Working Tests
Turn a short feature spec into code, runnable tests, and integration wiring that match your existing project.
Feature Flag Rollouts and Kill Switches
Design staged flag rollouts, verify rollback paths, and audit flag debt with explicit defaults, gates, and retirement plans.
Microcontroller Firmware and RTOS Engineering
Build and debug MCU firmware with bounded ISR/RTOS timing, safe DMA ownership, and measured power budgets.