init · git:20261022.cf63e43 · 2026-10-22 · sha256 dfb2a0bbf51d582d

init git:20261022.cf63e43A

Immutable. This exact content never changes and is served at /api/v1/blob/dfb2a0bbf51d582d.

---
name: init
description: Sets up Compound V in this project. Probes git, Python, Codex, a browser runner and Superpowers; picks the reviewer and test command; writes .claude/compound-v.json and the two native project settings Compound V relies on (worktree base and run-record protection). Every write is shown as a diff and applied only on the user's yes. Run once per project, and again after installing Codex or Playwright.
argument-hint: "[--check]"
---

# Init

Set up this project for the Compound V cycle (brainstorm → build, where one builder researches, plans and codes → verify). Probe everything first, then show the user **one** message with the findings and every proposed change, numbered, and apply only what they approve. With `--check`, probe and report, and write nothing.

**Commands.** Run each command as one plain command line with literal values (the run id, real paths): no shell variables you set yourself, no `;` or `&&` chains, no `$?`, and no pipes or redirects (`|`, `>`, `2>&1`): the one exception is the `<<'REQUEST'` heredoc that hands `run start` its request. The sandbox's auto-allow refuses compound commands, and `sandbox.excludedCommands` only matches a bare call.

## 1. Probes (write nothing)

Run these and keep the results:

```bash
git rev-parse --show-toplevel                                     # a git repo
git rev-parse --verify -q HEAD                                    # with a first commit
python3 -c 'import sys; print(sys.version_info >= (3, 9))'      # True
codex --version                                                   # reviewer candidate
npx --no-install playwright --version                             # Playwright Test in this project
claude mcp list                                                   # a playwright or chrome-devtools MCP?
claude plugin list --json                                         # is superpowers@claude-plugins-official enabled?
```

- **No first commit, or not a git repo**: stop and say so. The run record pins a base commit, so Compound V cannot run without one.
- **Python below 3.9**: stop, and name the interpreter found.
- **Test command**: detect one from `package.json` (`scripts.test` → `npm test`), `pyproject.toml` / `pytest.ini` (`python3 -m pytest`), a `Makefile` `test:` target (`make test`), `go.mod` (`go test ./...`) or `Cargo.toml` (`cargo test`). With none, propose none, and the plan will set one per run.
- **Browser runner**: Playwright Test in the project, or a Playwright / Chrome DevTools MCP in `claude mcp list`. With none, the offer is `claude mcp add playwright -- npx @playwright/mcp@0.0.83 --headless`, plus a note that each web plan adds Playwright Test (`@playwright/test`) as a dev dependency for its `live_cmd`. Without a browser, a web run ends incomplete unless the user waives the check.
- **Codex stop-review gate**: the codex plugin keeps a per-project `stopReviewGate` flag in its state file. With `<name>` the last part of the repo path and `<tmp>` the output of `python3 -c 'import tempfile; print(tempfile.gettempdir())'`, check it with
  `grep -ls '"stopReviewGate": *true' ~/.claude/plugins/data/codex-*/state/<name>-*/state.json <tmp>/codex-companion/<name>-*/state.json`.
  A hit means two Stop-time reviewers would both fire (Codex's gate and Compound V's refuse-once Stop hook). Warn, and suggest `/codex:setup --disable-review-gate` for this project.
- **Existing files**: read `.claude/compound-v.json` and `.claude/settings.json` if they exist. Every write below is a merge into them. Never truncate either file.

## 2. One message: findings and proposed changes

Report the probes in a few lines, then list each proposed change with its diff, numbered:

**① `.claude/compound-v.json`** (Compound V's own config):

```json
{"version": 4,
 "stance": "standard",
 "default_tier": "full",
 "reviewer": "claude",
 "test_cmd": "npm test",
 "is_web": true,
 "live_cmd": "npx playwright test",
 "budget_usd": 7,
 "models": {"build": "opus", "mechanical": "sonnet", "review": "opus"}}
```

- `reviewer`: `codex` when `codex --version` works and the user wants it, otherwise `claude`. The Claude reviewer is an Opus subagent, and its cost counts in the run's Claude budget. Codex runs outside it and is timed separately.
- `stance`: `standard`, or `cost-aware` (brainstorm depth defaults to quick, and the advisor is off or Opus, never Fable).
- `test_cmd`: the detected command, which the user confirms or corrects.
- `is_web` and `live_cmd`, for a web project only (a dev server in `package.json`, HTML templates, a `public/` folder): `live_cmd` is the Playwright Test command when the project has it (`npx playwright test`); otherwise ask the user for the command that checks the main page in a real browser. Light runs use it when their diff touches UI. Omit both for a project with no UI.
- `models`: the map the plan's task → model table draws from. This replaces v3's `/v:models`. Opus judges and builds, Sonnet takes mechanical work only.

**② `.claude/settings.json`** (the project's native settings, merged key by key):

```json
{"worktree": {"baseRef": "head"}}
```

- `worktree.baseRef: "head"` makes native `isolation: "worktree"` subagents branch from the current HEAD instead of the default branch, so parallel lanes see this run's work. It applies project-wide, to interactive `--worktree` sessions too. A plugin cannot ship this setting, which is why init writes it.
- Do **not** add a `permissions.deny` rule for `docs/compound-v/runs/`. An `Edit(...)` deny is also applied as a sandbox write deny, and then the CLI cannot write the run records itself (probed 2026-10-22: `PermissionError: Operation not permitted`). Run records are protected by the plugin's guard hook (Write/Edit/MultiEdit/NotebookEdit) and by the signed receipts.
- **When the project uses the Claude Code sandbox and is a web app**: the macOS sandbox denies Chromium's Mach port registration, so a real-browser test cannot start inside it. Offer to add `"sandbox": {"excludedCommands": ["npx playwright test *", "python3 * receipt live *"]}` plus matching `Bash(...)` allow rules. Say plainly that these two commands then run outside the sandbox. Skip it when the sandbox is off.

**③ Superpowers** (only when it is enabled): both brainstorm skills would fire on the same request. Offer to disable it for this project only, in `.claude/settings.json`:
`{"enabledPlugins": {"superpowers@claude-plugins-official": false}}`. Compound V neither calls Superpowers nor defers to it.

**④ Playwright MCP** (only when no browser runner was found): the `claude mcp add` command above.

**⑤ Warnings** with no write: the Codex stop-review gate, a missing test command, no browser.

End the message with one question: "Apply ①–④? Say which to skip or change." Then apply exactly what was approved, and nothing else.

## 3. Apply

- Write the JSON by reading the existing file, merging, and writing it back pretty-printed. Show the final diff afterwards (`git diff -- .claude/`).
- `.claude/` may be write-protected by the sandbox. The user's approval of the edit prompt is what lets the write through. Never route around it.
- Run nothing else. Installing Codex, Playwright browsers or project dependencies is the user's call: give the command and let them run it.

## 4. Report

In at most 8 lines: what was written, the reviewer, the test command, the browser state (Playwright Test / MCP / none, and what that means for web runs), any warning, and the next step: "Describe what you want built; Compound V starts with `compound-v:brainstorm`. Small changes go straight to `compound-v:verify`."