/worktree-init · Comandos slash para Claude Code | Prompt Studio
    1. Claude Code
    2. Comandos slash
    3. /worktree-init
    Claude Code · Comandos slashGit

    /worktree-init

    Crea worktrees en paralelo para trabajar varias tareas.

    por davila7/claude-code-templates

    git-workflow

    Licencia: MITVer original

    Instalación

    npx claude-code-templates@latest --command git-workflow/worktree-init

    Contenido

    Dónde va: .claude/commands/worktree-init.md

    ---
    allowed-tools: Bash(git:*), Bash(mkdir:*), Bash(ls:*), Bash(cat:*), Bash(basename:*), Bash(pwd:*), Bash(sed:*)
    argument-hint: task 1 | task 2 | task 3
    description: Create parallel worktrees for multi-task development with Ghostty panels
    ---
    
    # Worktree Parallel Init
    
    Create multiple git worktrees for parallel development: $ARGUMENTS
    
    ## Instructions
    
    You are setting up parallel worktrees so the user can work on multiple tasks simultaneously in separate Ghostty terminal panels, each running its own Claude instance.
    
    ### Step 1: Validate Environment
    
    1. Check this is a git repository: `git rev-parse --is-inside-work-tree`
    2. Get the repo name: `basename $(git rev-parse --show-toplevel)`
    3. Get the main branch name (check for `main` or `master`): `git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'` — if that fails, default to `main`
    4. Ensure working tree is clean: `git status --porcelain`. If dirty, warn the user and ask if they want to continue.
    5. Fetch latest: `git fetch origin`
    
    ### Step 2: Parse Tasks
    
    Parse tasks from `$ARGUMENTS`. Tasks are separated by `|` (pipe character).
    
    If `$ARGUMENTS` is empty, use AskUserQuestion to ask the user to describe their tasks (they can provide multiple separated by `|`).
    
    For each task description:
    - Trim whitespace
    - Generate a kebab-case branch name: `claude/<kebab-case-task>` (max 50 chars, alphanumeric and hyphens only)
    - Generate a worktree directory path: `../worktrees/<repo-name>/claude-<kebab-case-task>`
    
    ### Step 3: Create Worktrees
    
    For each task:
    
    1. Create the parent directory if needed: `mkdir -p ../worktrees/<repo-name>`
    2. Create the worktree:
       ```bash
       git worktree add -b claude/<name> ../worktrees/<repo-name>/claude-<name> origin/<main-branch>
       ```
    3. Write a `.worktree-task.md` file inside the new worktree with this content:
       ```markdown
       # Worktree Task
    
       **Branch:** claude/<name>
       **Task:** <original task description>
       **Created:** <ISO date>
       **Source repo:** <path to main repo>
       ```
    
    ### Step 4: Check for Dependencies
    
    If a `package.json` exists in the repo root, note that each worktree may need `npm install` (or the appropriate package manager).
    
    Check for:
    - `package-lock.json` → npm install
    - `yarn.lock` → yarn install
    - `pnpm-lock.yaml` → pnpm install
    - `bun.lockb` → bun install
    
    ### Step 5: Output Summary
    
    Display a clear summary table:
    
    ```
    | # | Task | Branch | Path |
    |---|------|--------|------|
    | 1 | ... | claude/... | ../worktrees/repo/claude-... |
    ```
    
    Then display ready-to-copy commands for Ghostty panels. For each worktree:
    
    ```
    # Panel <N>: <task description>
    cd <absolute-path-to-worktree> && claude
    ```
    
    If dependencies were detected, add a note:
    ```
    # Note: Run <package-manager> install in each worktree before starting
    ```
    
    Finally, remind the user:
    - Open a new Ghostty panel with `Cmd+D` (split right) or `Cmd+Shift+D` (split down)
    - When done with a task, use `/worktree-deliver` to commit, push, and create a PR
    - After merging all PRs, use `/worktree-cleanup --all` from the main repo
    

    Más en Comandos slash

    • /commit

      Redacta un commit con Conventional Commits a partir de los cambios en stage.

    • /review

      Revisa el diff actual buscando bugs, casos borde y problemas de seguridad.

    • /tests

      Escribe tests para el archivo o función que indiques.

    • /changelog

      Genera las notas de versión desde el último tag.

    • /explain

      Explica cómo funciona un archivo o módulo, con un diagrama del flujo.

    • /cleanup

      Elimina imports, variables y código muerto sin cambiar el comportamiento.

    Ver todo en Comandos slash (717) →

    Tu colección definitiva de prompts de IA. Inspírate, explora ejemplos y crea con IA.

    Hubs principales

    • Prompts
    • Imágenes
    • Videos
    • Generar Videos
    • Plantillas
    • Animaciones
    • Precios
    • Conoce
    • Afiliado

    Explorar por tipo

    • Kits de componentes
    • Etiquetas de imagen
    • Etiquetas de video
    • Webs

    Temas populares

    • Música
    • Portafolio
    • Gaming
    • Viajes
    • Nano Banana Pro

    Legal

    • Términos de uso
    • Política de privacidad
    • Política de cookies
    • Política de licencias
    • Política de reembolsos
    • Términos del programa de afiliados
    • Términos de Crowdfunding

    Magzin LLC, 800 Third Avenue Associates, New York, NY, 10022, United States

    © 2026 Prompt Studio by Magzin. Todos los derechos reservados.