# Phase 1 — Render DOCX

## Inputs

- One user-provided Markdown path.
- Bundled script: `scripts/render-docx.sh`.
- Bundled style template: `templates/reference.docx`.

## What to do

### Step 1: Validate the user request

Accept exactly one path. If the argument is empty, contains flags, or includes multiple files, stop and ask for one `.md` or `.markdown` path.

### Step 2: Validate proposal Markdown shape when applicable

If the input path matches `docs/business/<project-slug>/proposal.md` or `docs/business/<project-slug>/proposal.markdown`, validate that it was assembled by `business-proposal` before rendering:

- It MUST start with frontmatter containing `subtitle:`, `source: business-proposal`, `proposal_date:`, `slug:`, `based_on:`, and `language: es` or `language: en`.
- If `language: es`, it MUST contain `title: "PROPUESTA DE NEGOCIO"`.
- If `language: en`, it MUST contain `title: "BUSINESS PROPOSAL"`.
- It MUST contain `::: {custom-style="Internal Title"}` and `::: {custom-style="Internal Subtitle"}`.
- If `language: es`, it MUST contain `# 1. Mercado Objetivo y Cliente Ideal`, `# 2. Definición del Problema`, `# 3. Componentes Clave de la Solución`, `# 4. Enfoque de Ejecución del Proyecto`, and `## Factores clave de éxito`.
- If `language: en`, it MUST contain `# 1. Target Market and Ideal Client`, `# 2. Problem Definition`, `# 3. Key Solution Components`, `# 4. Project Execution Approach`, and `## Key success factors`.
- It MUST NOT contain `project_slug:`, `client_contact:`, `discovery_hours_estimate:`, `# Propuesta de negocio`, `# Business Proposal`, `Próximo paso`, `Next step`, `Puntos a resolver`, `Open points`, `Puntos a confirmar`, or `Points to confirm`.

If any validation fails, STOP. Do not render. Tell the user to regenerate the proposal with `/machine-business:business-proposal <project-slug>` because the Markdown was not assembled from the proposal template.

### Step 3: Run the renderer

Use the skill's script. Prefer `$CLAUDE_PLUGIN_ROOT` when the skill is installed:

```bash
bash "$CLAUDE_PLUGIN_ROOT/skills/render-docx/scripts/render-docx.sh" "<path.md>"
```

In a local checkout, call the repo path directly. On Windows, if `bash` resolves to a broken WSL install, use Git Bash directly.

### Step 4: Verify the result

Confirm the generated `.docx` exists, is non-empty, and lives beside the Markdown with the same basename. If the script reports an error, pass that error back without inventing a workaround.

### Step 5: Hand to user

Report exactly:

```markdown
**DOCX rendered.**

Output: `<path-to-output.docx>`
```

## Anti-patterns (forbidden)

- Adding flags or optional arguments to the command.
- Overwriting an existing `.docx`.
- Rendering PDF or HTML.
- Editing the Markdown content before render.
- Running Pandoc without `templates/reference.docx`.
- Rendering a business proposal Markdown that was not assembled from the business-proposal template.
