Configuration d'un worktree git pour développement parallèle

VérifiéPrudence

Crée un nouveau worktree git, copie les fichiers .env, installe les dépendances et génère le client Prisma. Inclut lancement et nettoyage optionnels.

Spar Skills Guide Bot
DeveloppementIntermédiaire
0029/08/2026
Claude Code
#git#worktree#environment-setup#parallel-development#auto-gpt

Recommandé pour

Notre avis

Ce skill crée un nouveau git worktree pour la plateforme AutoGPT, copie les fichiers d'environnement, installe les dépendances backend et frontend, et génère le client Prisma.

Points forts

  • Automatise tout le flux de création d'un worktree, de la création de branche à l'installation des dépendances.
  • Copie les fichiers `.env` depuis le worktree existant avec repli sur `.env.default`.
  • Gère les branches existantes et les nouvelles branches, avec instructions faciles pour lancer l'app et nettoyer.
  • Documente la libération des ports et l'option de contournement du mode SDK Claude.

Limites

  • Spécifique à l'organisation du dépôt AutoGPT et à ses gestionnaires de paquets (Poetry, pnpm).
  • Le nettoyage des ports utilise `lsof | xargs kill`, ce qui peut interrompre d'autres processus sur ces ports.
  • Certaines commandes supposent un emplacement parent précis pour les worktrees.
Quand l'utiliser

À utiliser quand vous avez besoin d'un worktree git isolé pour une branche de fonctionnalité ou une PR sur AutoGPT et souhaitez automatiser l'installation des dépendances et des fichiers d'environnement.

Quand l'éviter

À éviter pour les projets hors écosystème AutoGPT ou quand un simple changement de branche suffit sans isolation par worktree.

Analyse de sécurité

Prudence
Score qualité80/100

The skill instructs legitimate git worktree setup for parallel development in the AutoGPT repository. It uses powerful shell commands such as git, cp, poetry, pnpm, and lsof/kill, but they are scoped to the intended workflow. The kill -9 on listed ports and copying of environment files are notable but not malicious.

Points d'attention
  • Uses bash commands including kill -9 on specified ports, which can terminate unrelated processes if those ports are occupied.
  • Copies .env files (which may contain secrets) from the main worktree to the new worktree without user confirmation.
  • Runs package installation commands (poetry install, pnpm install) that may execute lifecycle scripts.

Exemples

Set up named worktree
Set up a worktree named AutoGPT7 based on the dev branch and install all dependencies.
Create worktree for current branch
Set up a git worktree for the current branch in isolation.
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>
Skills similaires