using-git-worktrees

Creates isolated git worktrees with automatic project setup and baseline test verification.

Updated Jun 11, 2026
One-click install
npx skills add https://github.com/marcocpt/trae_skills --skill using-git-worktrees-marcocpt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/marcocpt/trae_skills/tree/main/using-git-worktrees
Command: npx skills add https://github.com/marcocpt/trae_skills --skill using-git-worktrees-marcocpt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working on multiple branches simultaneously forces constant stashing, context switching, and risks contaminating your main working directory. This Skill creates isolated git worktrees outside your repository so you can develop features in parallel without interfering with your current workspace. ## Core Features & Use Cases - Smart Directory Selection: Computes the worktree path from the main repository root (not the current worktree), preventing nested worktree directories when invoked from inside an existing worktree. - Automatic Project Setup: Detects project type (Node.js, Rust, Python, Go) and runs the appropriate dependency installation command. - Baseline Verification: Runs the project's test suite before development begins to ensure a clean starting state, reporting failures before proceeding. - Use Case: You need to implement a new authentication feature while your main checkout stays on the release branch. The Skill creates ../myproject-worktrees/auth, installs dependencies, verifies all 47 tests pass, and reports the workspace is ready. ## Quick Start Use the using-git-worktrees skill to create an isolated worktree for the feature/auth branch and verify the test baseline passes.

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 a git worktree for a new feature branch?

Run git worktree add with a target path and the -b flag to create a new branch, for example git worktree add ../myproject-worktrees/auth -b feature/auth. This Skill automates that plus dependency installation and baseline testing.

Where should git worktrees be stored to avoid polluting the repository?

Store worktrees outside the repository in a sibling directory named <project-name>-worktrees. This keeps them untracked by git, so they never appear in git status or get accidentally committed.

Why does creating a worktree from inside another worktree cause nested directories?

Using git rev-parse --show-toplevel inside a worktree returns the worktree path, not the main repository, so the branch name gets mistaken for the project name. Use git rev-parse --git-common-dir to resolve the main repository root instead.

Should I run tests before starting work in a new worktree?

Yes, run the project's test suite immediately after setup to establish a clean baseline. If tests fail, report the failures and get explicit confirmation before continuing, otherwise you cannot distinguish new bugs from pre-existing issues.

Does this work with Node.js, Rust, Python, and Go projects?

Yes, the setup step auto-detects the project type from marker files: package.json triggers npm install, Cargo.toml triggers cargo build, requirements.txt or pyproject.toml trigger pip or poetry install, and go.mod triggers go mod download.