git-worktrees

Create isolated git worktrees under .worktrees with sanitized branch names.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Isolate feature work in dedicated git worktrees to prevent contamination of the main workspace.

Core Features & Use Cases

  • Create worktrees under the project-local .worktrees/ directory and ensure it is ignored in .gitignore.
  • Use a branch-safe, sanitized directory name that matches the target branch.
  • Verify branch name validity before creation and auto-detect project setup commands.
  • Use cases include parallel feature development, quick experiment tracking, and safe context switching without touching main work.

Quick Start

Run the skill with your feature name to create a safe, isolated worktree under .worktrees/ using a sanitized branch name.

Frequently Asked Questions about git-worktrees

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

FAQPage Schema
How do I create isolated git worktrees for parallel feature development?

To create isolated git worktrees, this skill automatically sets up a dedicated directory under the project-local .worktrees/ path and updates .gitignore to prevent workspace contamination during parallel feature development.

What is the safest way to switch git branches without contaminating the main workspace?

The safest way to switch contexts is using git worktrees. This skill isolates feature work in a separate directory, ensuring your primary branch remains untouched and preventing accidental contamination of the main workspace.

How do I sanitize git branch names for worktree directory creation?

To sanitize git branch names, this skill validates the branch name before creation and automatically generates a branch-safe, sanitized directory name that matches the target branch for the worktree setup.

Does git worktree setup automatically update .gitignore for the new directory?

Yes, git worktree setup automatically updates .gitignore. When creating worktrees under the project-local .worktrees/ directory, the skill ensures the path is ignored to maintain a clean primary workspace.

Can I auto-detect project setup commands when creating a git worktree?

Yes, you can auto-detect project setup commands. The skill offers optional project setup and verification steps, automatically detecting the necessary commands to initialize the environment within the new isolated worktree.