using-git-worktrees

Create isolated git worktrees for feature development with safety verification.

Updated Aug 22, 2025
One-click install
npx skills add https://github.com/cdub615/dotfiles --skill using-git-worktrees-cdub615
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/cdub615/dotfiles/tree/main/opencode/.config/opencode/skill/using-git-worktrees
Command: npx skills add https://github.com/cdub615/dotfiles --skill using-git-worktrees-cdub615

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill solves the problem of starting feature work in isolation by creating and managing isolated git worktrees that share the same repository while preserving safety.

Core Features & Use Cases

  • Isolated workspaces via git worktrees that share the repository but keep branches separate
  • Smart directory selection and preference handling (prefers existing or CLAUDE.md guidance)
  • Safety verification to ensure ignored directories and clean baselines before worktree creation
  • Automatic project setup steps (detects project files like package.json, Cargo.toml, requirements.txt and runs appropriate install/build commands)

Quick Start

Use the following sequence to create a new isolated worktree for a feature branch:

  • git worktree add .worktrees/FEATURE -b FEATURE
  • cd .worktrees/FEATURE
  • If applicable, run project setup commands based on project files (e.g., npm install, cargo build, pip install)

Frequently Asked Questions about using-git-worktrees

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

FAQPage Schema
How do I create an isolated git worktree for feature development?

Git worktrees let you check out multiple branches simultaneously in separate directories while sharing one repository history. This keeps feature development isolated without cloning the entire project multiple times.

How does a git worktree setup handle project dependencies like package.json or Cargo.toml?

After creating a git worktree, this setup auto-detects project files like package.json, Cargo.toml, or requirements.txt and runs the appropriate install or build commands automatically within the new isolated directory.

What safety checks are needed before adding a git worktree?

Before adding a git worktree, you should verify that the target directory is properly ignored in gitignore and ensure your current working baseline is clean to prevent accidental file conflicts and lost changes.

Can I use git worktrees to isolate feature branches without cloning the repository again?

Yes, git worktrees allow you to isolate feature branches in separate directories while sharing the same underlying repository, avoiding the overhead of multiple full clones for parallel feature development.

What is the best way to manage directory selection when creating multiple git worktrees?

The best way to manage directory selection for git worktrees is using consistent preference-driven paths, such as a dedicated `.worktrees` folder. This skill checks existing configurations or CLAUDE.md guidance to choose the correct path.