Using Git Worktrees

Create isolated Git worktrees with automated setup and safety checks.

41|27|Updated Oct 6, 2025
One-click install
npx skills add https://github.com/obra/clank --skill using-git-worktrees-obra
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Using Git Worktrees
Source: https://github.com/obra/clank/tree/main/skills/collaboration/using-git-worktrees
Command: npx skills add https://github.com/obra/clank --skill using-git-worktrees-obra

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers often need to work on multiple features or bug fixes concurrently without constantly switching branches or polluting their main workspace. This skill automates the creation of isolated Git worktrees, ensuring a clean and safe development environment for each task.

Core Features & Use Cases

  • Automated Worktree Creation: Quickly set up new worktrees with intelligent directory selection.
  • Safety Verification: Automatically checks .gitignore to prevent accidental commits of worktree contents.
  • Project Setup Automation: Detects and runs project-specific setup commands (e.g., npm install, cargo build).
  • Use Case: When starting a new feature, you'll use this skill to create a dedicated worktree, ensuring your changes are isolated, dependencies are installed, and tests pass before you even write a line of feature code.

Quick Start

Announce usage

"I'm using the Using Git Worktrees skill to set up an isolated workspace."

The skill will then guide you through directory selection and creation.

Example command (skill executes this internally):

git worktree add .worktrees/feature-branch -b feature-branch cd .worktrees/feature-branch npm install # or cargo build, etc. npm test

Frequently Asked Questions about Using Git Worktrees

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I work on multiple git branches simultaneously without switching workspaces?

Git worktrees enable concurrent development on different branches by creating isolated directory copies of your repository. Each worktree is a separate working environment linked to a specific branch, so you can develop multiple features in parallel without switching your main workspace or losing your place.

What's the best way to keep my main branch clean while developing new features?

Create a dedicated git worktree for each feature or task. This isolates your changes in a separate directory, prevents accidental commits to the main branch, and keeps your primary workspace pristine while you experiment or implement independently.

Can git worktrees automatically set up project dependencies like npm install?

Yes. Worktree creation detects project-specific setup commands and runs them automatically—such as npm install for Node projects or cargo build for Rust. This ensures dependencies are installed and baseline tests pass before you start development, creating a clean, reproducible environment.

How do I ensure a worktree won't accidentally commit ignored files to my repository?

The worktree creation process automatically verifies your .gitignore configuration in project-local worktrees. This safety check prevents accidental commits of worktree contents, dependencies, or build artifacts by confirming ignored patterns are properly configured before development begins.

When should I use worktrees instead of just switching branches in a single workspace?

Use worktrees when you need to work on multiple branches concurrently without losing your current work context, run tests in isolation, or maintain separate dependency states. Worktrees are essential for parallel development workflows where branch switching would disrupt ongoing tasks or require repeated setup.