Git Worktree Setup

VerifiedCaution

Set up a new git worktree for parallel development: creates the worktree, copies .env files, installs dependencies, and generates the Prisma client.

Sby Skills Guide Bot
DevelopmentIntermediate
8/29/2026
Claude Code
#git-worktree#parallel-development#environment-setup#prisma#autogpt

Recommended for

Automated summary

Sets up a dedicated git worktree for a branch or PR by creating the worktree, copying environment variables, installing dependencies, and generating the Prisma client.

Strengths

  • Automates the full environment bootstrap for a new worktree.
  • Keeps the main working tree clean for parallel tasks.
  • Handles .env fallback and repo-specific dependency installation.
  • Includes cleanup command and optional startup helpers.

Limitations

  • Tailored to the AutoGPT repository layout (autogpt_platform paths).
  • Requires poetry, pnpm, and the correct port availability.
  • The CoPilot testing note only applies to Claude Code; SDK mode cannot run there.
When to use it

Use when you need an isolated environment to work on a branch or PR without affecting your current checkout.

When not to use it

Do not use if you're outside the AutoGPT monorepo or need a fully containerized setup instead of a worktree.

Security analysis

Caution
Quality score82/100

The skill performs legitimate development environment setup but involves powerful shell operations such as process termination and dependency installation, warranting caution.

Findings
  • •Uses shell commands to install dependencies (poetry install, pnpm install), which execute package scripts and could introduce supply chain risk.
  • •Uses `kill -9` on ports 8001-8008 without confirmation, which could terminate unrelated processes.
  • •Copies .env files, which may contain secrets, to a new worktree within the same repository.
How this analysis is made

Examples

Create worktree named AutoGPT7
Set up a new worktree called AutoGPT7 from the dev branch
Default worktree setup
I need to work on this branch in isolation — set up a worktree for it.
Remove worktree
Remove the AutoGPT7 worktree and clean up.

name: worktree description: Set up a new git worktree for parallel development. Creates the worktree, copies .env files, installs dependencies, and generates Prisma client. TRIGGER when user asks to set up a worktree, work on a branch in isolation, or needs a separate environment for a branch or PR. user-invocable: true args: "[name] — optional worktree name (e.g., 'AutoGPT7'). If omitted, uses next available AutoGPT<N>." metadata: author: autogpt-team version: "3.0.0"

Worktree Setup

Create the worktree

Derive paths from the git toplevel. If a name is provided as argument, use it. Otherwise, check git worktree list and pick the next AutoGPT<N>.

ROOT=$(git rev-parse --show-toplevel)
PARENT=$(dirname "$ROOT")

# From an existing branch
git worktree add "$PARENT/<NAME>" <branch-name>

# From a new branch off dev
git worktree add -b <new-branch> "$PARENT/<NAME>" dev

Copy environment files

Copy .env from the root worktree. Falls back to .env.default if .env doesn't exist.

ROOT=$(git rev-parse --show-toplevel)
TARGET="$(dirname "$ROOT")/<NAME>"

for envpath in autogpt_platform/backend autogpt_platform/frontend autogpt_platform; do
  if [ -f "$ROOT/$envpath/.env" ]; then
    cp "$ROOT/$envpath/.env" "$TARGET/$envpath/.env"
  elif [ -f "$ROOT/$envpath/.env.default" ]; then
    cp "$ROOT/$envpath/.env.default" "$TARGET/$envpath/.env"
  fi
done

Install dependencies

TARGET="$(dirname "$(git rev-parse --show-toplevel)")/<NAME>"
cd "$TARGET/autogpt_platform/autogpt_libs" && poetry install
cd "$TARGET/autogpt_platform/backend" && poetry install && poetry run prisma generate
cd "$TARGET/autogpt_platform/frontend" && pnpm install

Replace <NAME> with the actual worktree name (e.g., AutoGPT7).

Running the app (optional)

Backend uses ports: 8001, 8002, 8003, 8005, 8006, 8007, 8008. Free them first if needed:

TARGET="$(dirname "$(git rev-parse --show-toplevel)")/<NAME>"
for port in 8001 8002 8003 8005 8006 8007 8008; do
  lsof -ti :$port | xargs kill -9 2>/dev/null || true
done
cd "$TARGET/autogpt_platform/backend" && poetry run app

CoPilot testing

SDK mode spawns a Claude subprocess — won't work inside Claude Code. Set CHAT_USE_CLAUDE_AGENT_SDK=false in backend/.env to use baseline mode.

Cleanup

# Replace <NAME> with the actual worktree name (e.g., AutoGPT7)
git worktree remove "$(dirname "$(git rev-parse --show-toplevel)")/<NAME>"

Alternative: Branchlet (optional)

If branchlet is installed:

branchlet create -n <name> -s <source-branch> -b <new-branch>

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/git-worktree-setup-mte1lgg0/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/git-worktree-setup-mte1lgg0' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/git-worktree-setup-mte1lgg0/download' --output '.skill-downloads/git-worktree-setup-mte1lgg0/SKILL.md.part' && mv '.skill-downloads/git-worktree-setup-mte1lgg0/SKILL.md.part' '.skill-downloads/git-worktree-setup-mte1lgg0/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/git-worktree-setup-mte1lgg0/SKILL.md' && test -s '.skill-downloads/git-worktree-setup-mte1lgg0/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/worktree' && cp -R '.skill-downloads/git-worktree-setup-mte1lgg0' '.claude/skills/worktree'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/git-worktree-setup-mte1lgg0'

openskills read 'git-worktree-setup-mte1lgg0'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/git-worktree-setup-mte1lgg0/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills