---
description: "First-run setup wizard: keychain token discovery, Git Identity onboarding, and pipeline preparation. Use when the pipeline is being set up for the first time, or tokens and git identity need onboarding."
description-tr: "İlk kurulum sihirbazı: keychain token keşfi, Git Identity kaydı ve pipeline hazırlığı."
argument-hint: "[jira-keys | hosts | accounts]  -  optional; no argument runs the whole onboarding"
parameters: [{"name":"section","kind":"enum","enum":["jira-keys","hosts","accounts"]}]
gui: form
destructive: false
confirm: none
allowed-tools: Bash, Read, Write, AskUserQuestion, WebFetch
---

## Gotchas

- A token is read and written only through `~/.claude/lib/credential-store.sh`. Never echo it, never pass it on argv, never paste it back to the user.
- A mapping in `keychainMapping` with no value in the store is not onboarded: offer the Token Save Flow, do not ask for the secret in chat.
- Hosts are stored without a scheme (`jira.example.com`); the callers add `https://`.
- Publishing tokens differ by registry: npmjs takes an npm token, GitHub Packages a classic PAT with `write:packages` from the account that owns the scope.

## Step 0 - What is actually wrong

Run `node "$HOME/.claude/scripts/doctor.mjs"` before the first question (never ask for a token that is already mapped and answering) and again at the end: its exit code, not the word "complete", decides how setup ends. Report both in `outputLanguage`; a remaining BLOCK is said plainly.

## Sections

`/multi-agent:setup hosts`: the Step 3.5 host prompt per mapped hosted service, then Token Save Flow Step 3.7 per mapped GitHub/Bitbucket token. `accounts`: Step 3.6. `jira-keys`: the Jira key mapping. Tokens are left alone.

## Setup (Credential Store + Git Identity Onboarding)

### Step 0  -  Language Selection

Ask BEFORE anything else: one question, `outputLanguage` (`en` / `tr`); already set: skip silently. `promptLanguage` is fixed to `"en"` and never offered. From here on `question`, `label` and `description` render in `outputLanguage`; `header` stays English. Read `$HOME/.claude/multi-agent-refs/setup/language.md` before Step 0.

### Step 0.5  -  Dependency check

Run `~/.claude/lib/credential-store.sh doctor` and `command -v pdftotext`. `Backend: ✓`: continue. Platform `unknown` or `ERR: macOS only`: **halt**. `pdftotext` missing: advise `brew install poppler`, continue.

### Credential Key Naming Rule

- **New token** (Step 3): ALWAYS the standard key name (`${USER}_Jira_Access_Token`, etc.).
- **Existing token** (Step 1): NEVER rename or migrate; map the discovered name as-is into `keychainMapping`.

### Step 1  -  Dynamic Credential Discovery

Read `$HOME/.claude/multi-agent-refs/setup/discovery.md` for Step 1.

### Step 2  -  Show Discovery Summary + Save Mapping

Show one line per service with its key or `MISSING`, then the counts (`$HOME/.claude/multi-agent-refs/setup/summaries.md`). Save every service ID to `prefs.global.keychainMapping`, the discovered key name verbatim or `null` (key list: `$HOME/.claude/multi-agent-refs/keychain.md`). Phases read this mapping, never hardcoded key names.

### Step 2.7  -  Operational reporting

Ask whether the user has an operational-reporting token; proceed only on an explicit yes. On paste, store it in the credential store ONLY (never a file, prefs value, git or synced tree): `pbpaste | ~/.claude/lib/credential-store.sh set "${USER}_Usage_Ingest_Token" -` then `pbcopy < /dev/null`. Pasted or skipped, run `node "$HOME/.claude/scripts/usage-register.mjs" --json`. Ask only when that JSON line carries `"needsPersonalAccount":true`, nothing else; it is false whenever the account is already known (a provable gh, credential-helper or SSH account, a stored `declaredLogin`, a pinned `registeredAs`). Then ask once for a GitHub username (Skip leaves reporting off) and re-run with `--login <name>`, then say in one line that the site owner approves the name and that logs start after approval. Under `MULTI_AGENT_UNATTENDED=1` never ask (the flag is false there; `deferred` means the accounts were not visible and the next normal run registers). A `refusal` (`not_collaborator` or `proof_required`) only prints its status line: the site answers a declared name the same way whether or not it is a collaborator. Show `account.temporaryPassword` exactly once (username, password, `account.loginUrl`, change it at first login), then never repeat, store or pass it on. `failingSince` gets one line: usage registration failing since <date>: <detail>; `pendingApproval` one line: the site holds records until its owner approves. What is sent: `$HOME/.claude/multi-agent-refs/features/usage-reporting.md`.

The Jira project key and git identity are learned from use, never asked (`$HOME/.claude/multi-agent-refs/setup/accounts.md` "Auto-learned fields").

### Step 3  -  Interactive token onboarding (for missing tokens)

Identities are learned in the Token Save Flow (Step C), never asked separately.

Walk the missing services ONE BY ONE, in this order: `jira`, `bitbucket_token` (then `bitbucket_user`), `github`, `confluence`, `figma` (PAT), `figma_mcp`, `fortify`, `graylog`, `firebase`, `jenkins`, App Store Connect (3b, iOS), Google Play (3d, Android), free-model keys `llm-<id>` (only after `route-on --free`: `$HOME/.claude/multi-agent-refs/setup/free-models.md`).

- **`figma_mcp`** is its own pass, opened by the Remote / Local question (`setup/figma.md`) whatever the PAT answer was. A connected claude.ai or remote Figma connector is not onboarded: ask while `keychainMapping.figma_mcp` has no stored value.
- **`firebase`** asks for the service-account JSON through the Save Flow, then offers Firebase MCP (`setup/firebase.md`). A probe answer of `no-credential` means nothing is stored, not a network failure: run this pass, never ask for a trace.

One prompt per service, never one yes/no or multi-select for all; each pass asks token, author, host, read binding; Skip is per-service and never aborts the loop. Read `$HOME/.claude/multi-agent-refs/setup/token-save-flow.md` before the loop and for every token prompt: the loop rules, Steps 3.5 / 3.7 and identity learning.

### Steps 3b-3d  -  Store and Firebase onboarding (optional)

Each key is validated BEFORE it is saved and lives only in the Keychain; Skip writes nothing. Read the matching file under `$HOME/.claude/multi-agent-refs/setup/` first: `app-store-connect.md` (3b, iOS, `.p8` included), `firebase.md` (3c: probe with `fetch-crashlytics.sh --probe` before asking; store the JSON as issued), `google-play.md` (3d, Android).

### Step 3.6  -  Per-account host overrides (optional)

Only when `~/.claude/lib/account-resolver.sh` returns more than one account and one has Jira or Bitbucket tokens. Read `accounts.md` "Per-account host overrides (Step 3.6)" (setup refs). Skipped on autopilot; `/multi-agent:setup accounts` opens it later.

### Step 4  -  Verify all

Re-run the Step 1 scan and show the final status (`summaries.md` "Step 4 final status"). Still missing: show which and let the user skip; Phase 0 re-asks.

### Steps 5-7  -  Repo discovery, groups, identity routing (optional)

Read the file under `$HOME/.claude/multi-agent-refs/setup/` for each step the user opts into: `repo-discovery.md` (5: local, Bitbucket, GitHub; a failing source skips only itself and is reported), `multi-repo-group.md` (6: only after 2+ repos), `identity-routing.md` (7).

### Credential store, token sources, Figma MCP

Always `~/.claude/lib/credential-store.sh` (macOS Keychain, macOS only, ADR-0012), never `security` directly; secrets from the clipboard or a file, never argv. Key names, token sources and store mechanics: `$HOME/.claude/multi-agent-refs/keychain.md`. Identities live in preferences. Figma MCP Remote / Local: `$HOME/.claude/multi-agent-refs/setup/figma.md`.

### Security Rules

- Never paste tokens into terminal or chat - use `pbpaste` for input
- Never hardcode tokens in source code
- Never commit tokens to git history
- Clear clipboard immediately: `pbcopy < /dev/null`
- `2>/dev/null` suppresses stderr (prevents metadata leakage)

From scratch: `npx @{npm-scope}/multi-agent-pipeline install`, `/multi-agent setup`, then a task (`summaries.md` "Setup from scratch").

### Step 8  -  Enforcement hooks (optional)

Claude Code: offer (picker, default Yes) to merge `$HOME/.claude/templates/claude-hooks.json` into `~/.claude/settings.json`; deep-merge EVERY event, never duplicate a matcher. First run `node "$HOME/.claude/lib/risky-settings.mjs" --json`; for each HIGH finding (bypass with a broad allow, a hook that runs fetched code, a literal secret) ask Keep / Fix it myself, naming the rule and place, never the value. Never edit the setting for the user; under autopilot only report. Read `$HOME/.claude/multi-agent-refs/setup/hooks-and-plugins.md` before Step 8. Codex: only the syntax gate, via `node "$HOME/.codex/scripts/host-hooks.mjs" install --host codex`. Copilot CLI: no hook.

### Step 9  -  Default stack plugin enablement

1. `bash "$HOME/.claude/scripts/plugin-refresh.sh" {owner} --add-only` (idempotent).
2. Ask the detector, then derive; no marker list here:

   ```bash
   eval "$(bash $HOME/.claude/lib/stack-detect.sh "$PROJECT_ROOT")"   # MA_STACKS, MA_STACK_WHY
   node -e 'import(process.env.HOME+"/.claude/scripts/_stack-routing.mjs").then(m=>
     console.log(m.pluginsForStacks(process.argv[1].split(" ").filter(Boolean)).plugins.join(" ")))' "$MA_STACKS"
   ```

3. Report `MA_STACK_WHY` and the enabled set (`hooks-and-plugins.md` "Step 9"); change later with `/multi-agent:stack <stack>`.
4. Show `node "$HOME/.claude/scripts/repo-recommend.mjs" --repo "$PROJECT_ROOT"` (read-only); apply an item only when the user picks it.
