
Git Worktree
Spin up isolated Git worktrees for parallel feature branches or PR review without stashing your main checkout.
Overview
Git Worktree is an agent skill most often used in Build (also Ship → review) that manages isolated Git worktrees via a mandatory manager script with env copy and dev-tool trust guardrails.
Install
npx skills add https://github.com/everyinc/compound-engineering-plugin --skill git-worktreeWhat is this skill?
- Unified worktree-manager.sh wrapper—never raw git worktree add
- Auto-copies .env, .env.local, .env.test from the main repo into new worktrees
- Branch-aware mise trust and direnv allow rules with review-safe guardrails
- Interactive create, list, switch, and cleanup with .worktrees gitignore handling
- 4 automated setup steps beyond raw git worktree add
- Copies .env, .env.local, .env.test and related env variants from main
Adoption & trust: 623 installs on skills.sh; 20.5k GitHub stars; 1/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need parallel branches or PR review sandboxes but ad-hoc worktrees leave missing env files, untrusted mise/direnv, and messy `.worktrees` gitignore state.
Who is it for?
Solo builders who juggle multiple branches, agent-driven PR review, or compound-engineering flows that require strict worktree hygiene.
Skip if: Single-branch hobby repos where you never parallelize work, or teams that forbid scripted env copy without manual security review.
When should I use this skill?
You need to create, list, switch, or clean up Git worktrees for parallel development or isolated review using the manager script only.
What do I get? / Deliverables
You get named, isolated worktrees with env files copied and dev-tool rules applied safely, ready for feature or review work without touching your main checkout.
- Named Git worktree with branch
- Synced env files in the worktree directory
- Updated .gitignore for .worktrees when needed
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Parallel branch work is a core Build-phase habit for solo builders shipping multiple streams from one repo. Git worktrees are repo-integration workflow tooling—not app UI—so they sit on Build → integrations alongside other dev-environment glue.
Where it fits
Open a second worktree for an agent feature while keeping shipping fixes on main.
Check out a contributor PR in an isolated tree with .env.test already present.
Run API experiments on a branch without stopping frontend work in the primary tree.
How it compares
Structured worktree lifecycle with env and trust setup—not a substitute for full CI review bots or hosted preview environments.
Common Questions / FAQ
Who is git-worktree for?
Indie and solo developers using agent-assisted Git workflows who need isolated trees for features or PR review without manual env and tooling fixes each time.
When should I use git-worktree?
During Build when starting parallel feature branches, during Ship when reviewing a PR in isolation, or whenever SKILL.md says to use worktree-manager.sh instead of raw git worktree commands.
Is git-worktree safe to install?
It automates env copy and selective mise/direnv trust—review those behaviors for your secrets policy and check the Security Audits panel on this Prism page before trusting in production repos.
SKILL.md
READMESKILL.md - Git Worktree
# Git Worktree Manager This skill provides a unified interface for managing Git worktrees across your development workflow. Whether you're reviewing PRs in isolation or working on features in parallel, this skill handles all the complexity. ## What This Skill Does - **Create worktrees** from main branch with clear branch names - **List worktrees** with current status - **Switch between worktrees** for parallel work - **Clean up completed worktrees** automatically - **Interactive confirmations** at each step - **Automatic .gitignore management** for worktree directory - **Automatic .env file copying** from main repo to new worktrees - **Automatic dev tool trusting** for mise and direnv configs with review-safe guardrails ## CRITICAL: Always Use the Manager Script **NEVER call `git worktree add` directly.** Always use the `worktree-manager.sh` script. The script handles critical setup that raw git commands don't: 1. Copies `.env`, `.env.local`, `.env.test`, etc. from main repo 2. Trusts dev tool configs with branch-aware safety rules: - mise: auto-trust only when unchanged from a trusted baseline branch - direnv: auto-allow only for trusted base branches; review worktrees stay manual 3. Ensures `.worktrees` is in `.gitignore` 4. Creates consistent directory structure ```bash # ✅ CORRECT - Always use the script bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-name # ❌ WRONG - Never do this directly git worktree add .worktrees/feature-name -b feature-name main ``` ## When to Use This Skill Use this skill in these scenarios: 1. **Code Review (`/ce:review`)**: If NOT already on the target branch (PR branch or requested branch), offer worktree for isolated review 2. **Feature Work (`/ce:work`)**: Always ask if user wants parallel worktree or live branch work 3. **Parallel Development**: When working on multiple features simultaneously 4. **Cleanup**: After completing work in a worktree ## How to Use ### In Claude Code Workflows The skill is automatically called from `/ce:review` and `/ce:work` commands: ``` # For review: offers worktree if not on PR branch # For work: always asks - new branch or worktree? ``` ### Manual Usage You can also invoke the skill directly from bash: ```bash # Create a new worktree (copies .env files automatically) bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-login # List all worktrees bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh list # Switch to a worktree bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh switch feature-login # Copy .env files to an existing worktree (if they weren't copied) bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh copy-env feature-login # Clean up completed worktrees bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh cleanup ``` ## Commands ### `create <branch-name> [from-branch]` Creates a new worktree with the given branch name. **Options:** - `branch-name` (required): The name for the new branch and worktree - `from-branch` (optional): Base branch to create from (defaults to `main`) **Example:** ```bash bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-login ``` **What happens:** 1. Checks if worktree already exists 2. Updates the base branch from remote 3. Creates new worktree and branch 4. **Copies all .env files from main repo** (.env, .env.local, .env.test, etc.) 5. **Trusts dev tool configs** with branch-aware safety rules: - trusted bases (`main`, `develop`, `dev`, `trunk`, `staging`, `release/*`) compare against themselves - other branches compare against the default bran