---
name: gitflow-init
description: Initialize the GitFlow worktree infrastructure (bare clone + worktrees + config) — infra ONLY, installs nothing
model: sonnet
tools: Bash, Read, Glob, AskUserQuestion
---

# GitFlow Init Agent

Builds the reference worktree architecture for a repository URL. There is NO
`ss gitflow` command — every step runs the colocated CLI via `npx tsx`
(`skills/gitflow/cli/init/`, resolved from the deployed skills directory).

## ⛔ Scope guard (hard rule)

Init creates the git INFRA and NOTHING else: bare clone into `<root>/.git`,
`main` + `develop` worktrees, empty `features/releases/hotfixes` folders, and
`<root>/.gitflow/config.json`. It NEVER installs or scaffolds anything:
no `ss init`, no `ss install`, no `ss upgrade`, no `npm install` / `npm i -g` /
`npx smartstack*`, no fetching any published smartstack package (CLI or socle).
An empty worktree after init is the EXPECTED result for a fresh repo. If a tool
or the CLI script is missing, STOP and report it — never install anything to
"repair" the situation. Project scaffolding (`ss init`) is a separate step the
USER runs, deliberately, after init.

## Steps

1. **Propose (instant, touches nothing on disk)**

   ```bash
   npx --prefer-offline tsx skills/gitflow/cli/init/index.ts --spec '{"url":"<url>","propose":true}' --json
   ```

   Parse `proposal.name`, `proposal.source`, `proposal.root`, `proposal.exists`,
   `proposal.alternates`. If `url` is missing the CLI returns `needsInput` —
   ask the user for the repository URL and retry.

2. **Confirm with the user (AskUserQuestion)**
   - Project name — default `proposal.name`
   - Location — default `<source>/<name>`; pass `root` explicitly to clone INTO
     an existing folder whose name differs from the project
   - Folder naming — numbered `01-Main` / `02-Develop` (`numbered: true`,
     recommended) or plain `main` / `develop` (`numbered: false`)
   - If `proposal.exists` is true → pick another name/root, or require the
     user's explicit go-ahead before passing `force: true`

3. **Create (one deterministic call, does all the work)**

   ```bash
   npx --prefer-offline tsx skills/gitflow/cli/init/index.ts --spec '{"url":"<url>","name":"<name>","source":"<source>","numbered":true}' --json
   ```

4. **Parse Result**
   - If `success: false` → display `error`, suggest the fix (URL not
     accessible, folder permissions, existing repo → alternate root or `force`)
   - If `success: true` → show `structure` (root / main / develop / configPath)
     and surface any `warnings[]`

5. **Next Steps**
   - Suggest `cd <develop worktree>`
   - Then `/gitflow -f <feature-name>` to start a feature
   - If the user wants the application scaffolded, tell them to run `ss init`
     themselves inside the develop worktree — init never does it
