Create Git Worktree
Description
Create a new git worktree for an agent to work in isolation.
Installation
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open the source below and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
Repository README
This is the README for disler/nano-agent, shared by 3 entries
in this directory. It describes the repository, not this entry specifically.
Create Git Worktree
Create a new git worktree for an agent to work in isolation.
Variables
worktree_name: $ARGUMENTS (IMPORTANT: first argument) WORKTREE_PATH: trees
Instructions
Execute ALL the following steps in sequence WITHOUT using a todo list:
- Parse the variables - extract the worktree_name from the first argument
- List existing worktrees to check for name conflicts
- Create a new git worktree in the
trees/directory - Base the worktree on the main branch
- Copy the
.envfile from the root directory to the worktree (if it exists) - Create an initial commit in the worktree to establish the branch
- Report the successful creation of the worktree
Git Worktree Setup
Execute these steps in order:
**List existing worktrees to avoid collisions**:
git worktree list**WARNING**: DO NOT use any of the existing worktree names shown above! Each worktree must have a unique name.
- Check if the proposed
appears in the list - If it does, STOP and report: "Worktree name '
' is already in use. Please choose a different name."
- Check if the proposed
**Create the trees directory** if it doesn't exist:
mkdir -p trees**Check if worktree directory already exists**:
- If
trees/already exists, report that it exists and stop - Otherwise, proceed with creation
- If
**Create the git worktree**:
git worktree add trees/-b **Copy environment file** (if exists):
if [ -f .env ]; then cp .env trees//.env echo "Copied .env file" else echo ".env file not found in root, skipping" fi **Create initial commit with no changes**:
git -C trees/commit --allow-empty -m "Initial worktree setup for "
Error Handling
- If the worktree name is already in use, report this immediately and exit: "Worktree name '
' is already in use. Please choose a different name." - If the worktree directory already exists, report this and exit gracefully
- If git worktree creation fails, report the error
- If .env doesn't exist in root, continue without error (it's optional)
Verification
After setup, verify the worktree was created:
ls -la trees/ # Should show full repository contents
git -C trees/ branch # Should show the new branch
Report
Report one of the following:
- Success: "Worktree '
' created successfully at trees/ " - Already exists: "Worktree '
' already exists at trees/ " - Error: "Failed to create worktree: "
Notes
- Git worktrees provide branch isolation with separate working directories
- Each worktree has its own branch and can be worked on independently
- The worktree is created in the
trees/directory to keep them org
Related Skills
Epic Sync
Sync epic issue bodies, labels, and local coordination snapshots from GitHub.
Git 使用 Git Worktrees
创建孤立的 Git worktrees,带有智能目录选择与安全验证。
Git Claude skills github
[Building agent skills blog](https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-ag
Git #148
, [#161](https://github.com/affaan-m/everything-claude-code/pull/161))
Git GitHub MCP
| Token | Repos, issues, PRs, workflows |
Git GitHub MCP Server
Official first-party server to read repos, manage issues/PRs, and automate workflows.
Git