git-worktrees
Git Worktrees
Part of Agent Skills™ by googleadsagent.ai™
Description
Git Worktrees enables parallel development by maintaining multiple checked-out branches simultaneously in separate directories. Instead of stashing changes and switching branches, the agent creates isolated worktrees for each task, providing clean test baselines and eliminating context-switching overhead. Each worktree is a fully independent workspace tied to its own branch.
This skill is essential for subagent-driven development, where multiple agents work on different tasks concurrently. Without worktrees, agents would clobber each other's uncommitted changes. With worktrees, each agent operates in its own directory with its own branch, and the orchestrator merges completed work back into the main line.
Worktrees also provide clean baselines for testing. When you need to verify that tests pass on a clean checkout—without build artifacts, local config, or uncommitted changes—a fresh worktree gives you exactly that. The worktree lifecycle is managed explicitly: create when a task starts, verify when it completes, and prune when it merges.
Use When
- Multiple tasks must be developed in parallel without interference
- Subagents need isolated filesystems for concurrent work
- You need a clean checkout to run tests without local artifacts
- Hotfix work must happen while a feature branch is in progress
- Best-of-N implementations need separate workspaces