# Set Up Worktree Repo

Create main, review and numbered work worktrees with dependencies installed.

- Repository: https://github.com/Significant-Gravitas/AutoGPT (187858 stars)
- Category: DevOps
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add Significant-Gravitas/AutoGPT --skill setup-repo -g -a claude-code -y`
Codex: `npx skills add Significant-Gravitas/AutoGPT --skill setup-repo -g -a codex -y`
Cursor: `npx skills add Significant-Gravitas/AutoGPT --skill setup-repo -g -a cursor -y`
Gemini CLI: `npx skills add Significant-Gravitas/AutoGPT --skill setup-repo -g -a gemini-cli -y`

## Description

Initialize a worktree-based repo layout for parallel development. Creates a main worktree, a reviews worktree for PR reviews, and N numbered work branches. Handles .env creation, dependency installation, and branchlet config. TRIGGER when user asks to set up the repo from scratch, initialize worktrees, bootstrap their dev environment, "setup repo", "setup worktrees", "initialize dev environment", "set up branches", or when a freshly cloned repo has no sibling worktrees.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Repository Setup

This skill sets up a worktree-based development layout from a freshly cloned repo. It creates:
- A **main** worktree (the primary checkout)
- A **reviews** worktree (for PR reviews)
- **N work branches** (branch1..branchN) for parallel development

## Step 1: Identify the repo

Determine the repo root and parent directory:

```bash
ROOT=$(git rev-parse --show-toplevel)
REPO_NAME=$(basename "$ROOT")
PARENT=$(dirname "$ROOT")
```

Detect if the repo is already inside a worktree layout by counting sibling worktrees (not just checking the directory name, which could be anything):

```bash
# Count worktrees that are siblings (live under $PARENT but aren't $ROOT itself)
SIBLING_COUNT=$(git worktree list --porcelain 2>/dev/null | grep "^worktree " | grep -c "$PARENT/" || true)
if [ "$SIBLING_COUNT" -gt 1 ]; then
  echo "INFO: Existing worktree layout detected at $PARENT ($SIBLING_COUNT worktrees)"
  # Use $ROOT as-is; skip renaming/restructuring
else
  echo "INFO: Fresh clone detected, proceeding with setup"
fi
```

## Step 2: Ask the user questions

Use AskUserQuestion to gather setup preferences:

1. **How many parallel work branches do you need?** (Options: 4, 8, 16, or custom)
   - These become `branch1` through `branchN`
2. **Which branch should be the base?** (Options: origin/master, origin/dev, or custom)
   - All work branches and reviews will start from this

## Step 3: Fetch and set up branches

```bash
cd "$ROOT"
git fetch origin

# Create the reviews branch from base (skip if already exists)
if git show-ref --verify --quiet refs/heads/reviews; then
  echo "INFO: Branch 'reviews' already exists, skipping"
else
  git branch reviews <base-branch>
fi

# Create numbered work branches from base (skip if already exists)
for i in $(seq 1 "$COUNT"); do
  if git show-ref --verify --quiet "refs/heads/branch$i"; then
    echo "INFO: Branch 'branch$i' already exists, skipping"
  else
    git branch "branch$i" <base-branch>
  fi
done
```

The rest: https://github.com/Significant-Gravitas/AutoGPT/blob/HEAD/.claude/skills/setup-repo/SKILL.md
