git-worktree

Create, list, switch, and clean up git worktrees with automatic .env copying and dev tool trust.

3|Updated May 8, 2026
One-click install
npx skills add https://github.com/wan-huiyan/agent-traffic-control --skill git-worktree-wan-huiyan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: git-worktree
Source: https://github.com/wan-huiyan/agent-traffic-control/tree/main/plugins/agent-traffic-control/skills/git-worktree
Command: npx skills add https://github.com/wan-huiyan/agent-traffic-control --skill git-worktree-wan-huiyan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Working on multiple branches or reviewing pull requests normally requires stashing changes or cloning the repo again. This Skill manages git worktrees through a single script that creates isolated checkouts, copies environment files, and trusts mise/direnv configs so parallel work starts without manual setup. ## Core Features & Use Cases - Managed worktree lifecycle: Create worktrees from main (or any base branch), list them with status, switch between them, and interactively clean up inactive ones. - Automatic environment setup: Copies .env, .env.local, .env.test and similar files from the main repo into each new worktree, with backups when files already exist. - Branch-aware dev tool trust: Auto-trusts mise and direnv configs only when unchanged from a trusted baseline branch, flagging modified configs for manual review. - Use Case: While running two Claude Code sessions in parallel, create a worktree for a PR review in one session and a feature branch in another, each with its own .env files and trusted tool configs, then clean both up after merge. ## Quick Start Ask the agent to create a new git worktree named feature-login from main using the worktree manager script.

Frequently Asked Questions about git-worktree

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

FAQPage Schema
How do I create a git worktree for parallel development?▼

Run the worktree-manager.sh script with the create command and a branch name, for example create feature-login. It updates the base branch, runs git worktree add, copies .env files, and trusts dev tool configs in one step.

Why use a worktree manager script instead of git worktree add?▼

Raw git worktree add only creates the checkout. The script also copies .env files from the main repo, adds .worktrees to .gitignore, and trusts mise or direnv configs so hooks and scripts do not block on interactive trust prompts.

Does the script copy .env files into new worktrees?▼

Yes, it copies .env, .env.local, .env.test and similar files from the main repository root, skipping .env.example. Existing files in the worktree are backed up with a .backup suffix before being overwritten.

How does direnv and mise auto-trust work in worktrees?▼

Configs are auto-trusted only when identical to a trusted baseline branch such as main, develop, or release branches. Modified configs are flagged for manual review, and direnv auto-allow is skipped entirely on non-trusted base branches.

Why does cleanup refuse to remove a worktree?▼

The cleanup command skips the worktree you are currently inside, since git cannot remove the active checkout. Switch back to the main repository root first, then run cleanup again to remove it.