
Git worktree
Create, list, switch and clean up git worktrees with env and dev-tool setup
Git worktree is an open-source agent skill for developer tools. It is available on Claude Code.
- Scripts
- shell
- Platforms
- Claude Code
- GitHub stars
- 5
- Last commit
- License
- MIT
- Listing updated
Similar skills
About Git worktree
This skill gives the agent a bash manager script for working in a second, isolated checkout of a repository, useful for parallel feature work or reviewing a pull request without disturbing the current branch. The script creates worktrees under a .worktrees directory from a base branch, lists them, switches between them and interactively removes inactive ones.
Beyond plain git commands, the script copies common environment files such as .env and .env.local from the main repo into new worktrees, keeps the worktree directory listed in .gitignore, and trusts mise or direnv configs using branch-aware rules. Trusted base branches are compared against themselves, other branches against the default branch, and direnv auto-allow is skipped on non-trusted bases.
The skill is meant to replace direct git worktree add calls. It also includes a section on checking for duplicate clones and worktrees with unpushed commits, stashes or unmerged branches before deleting one. It expects bash and git, and it is shipped as part of a Claude Code plugin.
When your agent uses it
Create, list, switch and clean up git worktrees — a second isolated checkout for parallel work or a pull request review. Runs the bundled `skills/git-worktree/scripts/worktree-manager.sh`, which also copies `.env` in, gitignores the dir and trusts mise or direnv. Not a bare `git worktree add`.
From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.
What it can access
- Runs shell scripts(see the files on GitHub)
- No network calls found in its scripts(see the files on GitHub)
- License: MIT(see the files on GitHub)
From a static check of its 2 files (28 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.
Check another skill before you install it.
Install
This skill ships in the agent-traffic-control plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):
/plugin marketplace add wan-huiyan/agent-traffic-control
/plugin install agent-traffic-control@wan-huiyan-agent-traffic-controlOr copy only this skill to ~/.claude/skills/git-worktree:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/git-worktree &&
cp -R "$tmp/plugins/agent-traffic-control/skills/git-worktree" ~/.claude/skills/git-worktree &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/git-worktree inside it instead.
Copy the skill folder to ~/.agents/skills/git-worktree to use it in every repository:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/git-worktree &&
cp -R "$tmp/plugins/agent-traffic-control/skills/git-worktree" ~/.agents/skills/git-worktree &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/git-worktree inside it instead.
Copy the skill folder to ~/.cursor/skills/git-worktree to use it in every project:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/git-worktree &&
cp -R "$tmp/plugins/agent-traffic-control/skills/git-worktree" ~/.cursor/skills/git-worktree &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/git-worktree inside it instead.
Run in a terminal (add --scope workspace to install it for the current workspace only):
gemini skills install https://github.com/wan-huiyan/agent-traffic-control.git --path plugins/agent-traffic-control/skills/git-worktreeOr copy the folder to ~/.gemini/skills/git-worktree yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/git-worktree:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/git-worktree &&
cp -R "$tmp/plugins/agent-traffic-control/skills/git-worktree" ~/.copilot/skills/git-worktree &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/git-worktree inside it instead.
Get the folder:
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.gitThen copy agent-traffic-control/plugins/agent-traffic-control/skills/git-worktree into your agent's skills folder as git-worktree. Agents that support SKILL.md read one folder per skill.
What it does
- Create isolated worktrees
- Builds a new branch and worktree from a base branch, refreshing the base from the remote first.
- Env file copying
- Copies .env, .env.local and similar files from the main repo into each new worktree.
- Dev tool trust handling
- Trusts mise or direnv configs with safety rules that depend on the branch being checked out.
- List and switch
- Shows existing worktrees with their branches and moves into a chosen one.
- Interactive cleanup
- Asks for confirmation before removing inactive worktrees and empty directories.
- Duplicate checkout audit
- Lists checks to confirm a worktree or clone holds no uncommitted, stashed or unpushed work before removal.
Good for
- Set up a separate worktree to review a pull request without switching branches
- Start a parallel feature branch in its own checkout
- List which worktrees exist and which branch each one uses
- Clean up finished worktrees after a review or merge
- Copy missing .env files into a worktree created with raw git
Git worktree FAQ
Does it replace git worktree add?
The skill says to use its manager script instead of calling git worktree add directly, because the script also copies env files, updates .gitignore and handles dev tool trust.
Which commands does Git worktree provide?
create, list (or ls), switch (or go), cleanup (or clean) and copy-env, all run through the bundled worktree-manager.sh script.
What does cleanup remove?
It lists inactive worktrees, asks for confirmation, removes the selected ones and cleans up empty directories. It will not remove the current worktree.
Which base branches are trusted for direnv?
The content names main, develop, dev, trunk, staging and release/* as trusted bases, where direnv auto-allow applies.
How do I install Git worktree in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/git-worktree to use it in all your projects, or to .claude/skills/git-worktree in one project. Or install the agent-traffic-control plugin, which includes it: /plugin marketplace add wan-huiyan/agent-traffic-control, then /plugin install agent-traffic-control@wan-huiyan-agent-traffic-control.
Does Git worktree run scripts?
Yes. It runs shell scripts. No network calls were found in its scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.
Which AI agents can use Git worktree?
Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.
What are the best alternatives to Git worktree?
The closest alternatives to Git worktree are Worktrees, Harness read write base repo path in worktree stale tree, Git clean worktrees, Create worktree and Wt.
Where this comes from
- Description: from the skill's own SKILL.md.
More from wan-huiyan/agent-traffic-control

Teaches agents to refuse a flawed instruction only with measured evidence attached
- Open source
- 5 GitHub stars
- Developer tools

Catches silent deletions when a subagent edits large files with repeated blocks
- Open source
- 5 GitHub stars
- Developer tools

Holds a pull request from merging by stopping its agent, disarming auto-merge, then
- Open source
- 5 GitHub stars
- Developer tools

Checks that a batch of pull requests does not cite file paths that will never exist
- Open source
- 5 GitHub stars
- Developer tools

Checks whether a pull request truly landed by comparing file content, not commit subjects
- Open source
- 5 GitHub stars
- Developer tools

Checks a branch for stale-base changes that would silently undo newer main work
- Open source
- 5 GitHub stars
- Developer tools




