---
name: discovery-init
description: Use when the user wants to initialize a machine-discovery F1 workspace by project slug. Creates docs/discovery/<project-slug>/, ensures the shared docs/inputs/<project-slug>/ intake exists, and copies an existing machine-business proposal when available. Triggers on "/machine-discovery:discovery-init <project-slug>", "/discovery-init <project-slug>", and requests to set up Discovery F1.
---

# Discovery Init

Create the standard F1 Discovery folder structure for one project.

## Folder contract

```text
docs/inputs/<project-slug>/
  raw/
  transcriptions/
  index.json

docs/business/<project-slug>/
  proposal.md

docs/discovery/<project-slug>/
  inputs/
    business-proposal.md
  requirements/
    index.json
    requirements.md
    items/
  hla/
  planning/
  draft-prds/
    index.json
    items/
  project-doc/
  commercial-offer/
```

`docs/inputs/<project-slug>/` is the shared project intake. It stores audio, text, transcripts, and the common `index.json`.

`docs/discovery/<project-slug>/inputs/business-proposal.md` is the Discovery-specific input. It MUST contain the business proposal that starts F1. It MAY be copied from `docs/business/<project-slug>/proposal.md` or placed manually by the user.

## Index contracts

The scaffolding script creates these three indices only when missing:

- `docs/inputs/<project-slug>/index.json` → `{ "project": "<project-slug>", "inputs": [] }`
- `docs/discovery/<project-slug>/requirements/index.json` → `{ "project": "<project-slug>", "requirements": [] }`
- `docs/discovery/<project-slug>/draft-prds/index.json` → `{ "project": "<project-slug>", "prds": [] }`

## Operating protocol

1. Resolve the workspace root as the current working directory.
2. Read the project slug from `$ARGUMENTS`.
   - If missing, stop with `NEEDS INPUT: indica el project slug, por ejemplo /machine-discovery:discovery-init acme-demo`.
   - The slug MUST be kebab-case ASCII: lowercase letters, numbers, and single hyphens. If invalid, ask for a corrected slug.
3. Validate pre-existing index files BEFORE running the script. For each of `docs/inputs/<project-slug>/index.json`, `docs/discovery/<project-slug>/requirements/index.json`, and `docs/discovery/<project-slug>/draft-prds/index.json` that already exists: it MUST be valid JSON and its `project` MUST equal `<project-slug>`. If not, stop and report the exact file and mismatch. Do not migrate it silently and do not run the script.
4. Run the scaffolding script. Prefer `$CLAUDE_PLUGIN_ROOT` when installed:

   ```bash
   bash "$CLAUDE_PLUGIN_ROOT/scripts/discovery-init.sh" "<project-slug>"
   ```

   In a local checkout, call:

   ```bash
   bash plugins/machine-discovery/scripts/discovery-init.sh "<project-slug>"
   ```

   The script creates all directories, creates the three index files only when missing, copies the business proposal when applicable, self-verifies, and prints a `NEXT_COMMAND=...` line.
5. If the script exits non-zero, report its output verbatim and stop. Do not hand-create folders or indices as a workaround.
6. Report the initialized structure in the current user interaction language, then print exactly ONE next-step command and nothing more: the value of the `NEXT_COMMAND=` line emitted by the script (already fully namespaced with `/machine-discovery:`).
   - MUST NOT list the rest of the flow (`/machine-discovery:hla`, `/machine-discovery:planning`, `/machine-discovery:draft-prds`, `/machine-discovery:project-doc`, `/machine-discovery:commercial-offer`). Suggest only the immediate next command.

## Hard rules

- **Scaffolding is script-owned.** Folders and the three `index.json` files MUST be created by `scripts/discovery-init.sh`, never hand-created step by step.
- **Project slug required.** Never initialize global `docs/inputs/raw/` or `docs/discovery/inputs/` folders.
- **Shared inputs stay shared.** Audio, text, transcriptions, and input index MUST stay under `docs/inputs/<project-slug>/`.
- **Discovery input is proposal only.** Do not create `docs/discovery/<project-slug>/inputs/raw/` or `docs/discovery/<project-slug>/inputs/transcriptions/`.
- **No destructive actions.** Never delete, move, rename, migrate, or overwrite existing files.
- **Index creation only when missing.** Existing JSON files MUST be validated and then left untouched.
- **No auto-chaining.** Suggest only the single immediate next command, but do not run it. Never list the full downstream flow.
- **Namespaced next step.** Every user-facing command suggestion MUST carry the `/machine-discovery:` prefix. Bare slash commands (`/requirements`, `/process-input`, ...) do not resolve and MUST NOT be printed.
