# Generated Template

**Project**: {{ name }}
**Version**: {{ version }}
**Domain**: {{ domain }}
**Date**: {{ date }}

---

---
description: Execute the realization planning workflow using the plan template to generate design artifacts.
scripts:
  sh: scripts/bash/setup-plan.sh --json
  ps: scripts/powershell/setup-plan.ps1 -Json
---

## User Input

```text
$ARGUMENTS
```

You **MUST** consider the user input before proceeding (if not empty).

## Outline

1. **Setup**: Load context and realization plan template.

2. **Load context**: Read specification and `/memory/constitution.md`.

3. **Execute plan workflow**: Follow the structure in plan template to:
   - Fill Technical Context (mark unknowns as "NEEDS CLARIFICATION")
   - Fill Constitution Check section from constitution
   - Evaluate gates (ERROR if violations unjustified)
   - Phase 0: Generate research document (resolve all NEEDS CLARIFICATION)
   - Phase 1: Generate design artifacts (model, contracts, guide)
   - Re-evaluate Constitution Check post-design

4. **Stop and report**: Command ends after Phase 2 planning. Report plan path and generated artifacts.

## Phases

### Phase 0: Outline & Research

1. **Extract unknowns from Technical Context**:
   - For each NEEDS CLARIFICATION → research task
   - For each dependency → best practices task
   - For each integration → patterns task

2. **Generate and dispatch research**:
   ```text
   For each unknown in Technical Context:
     Task: "Research {unknown} for {context}"
   For each choice:
     Task: "Find best practices for {choice} in {domain}"
   ```

3. **Consolidate findings** in `research` document using format:
   - Decision: [what was chosen]
   - Rationale: [why chosen]
   - Alternatives considered: [what else evaluated]

**Output**: Research document with all NEEDS CLARIFICATION resolved

### Phase 1: Design & Contracts

**Prerequisites:** Research complete

1. **Extract components from specification** → model document:
   - Component name, attributes, relationships
   - Validation rules from requirements
   - State transitions if applicable

2. **Generate contracts** from functional requirements:
   - For each interaction → contract
   - Use standard patterns for domain
   - Output specifications to contracts directory

3. **Create realization guide**:
   - Quick reference for implementation
   - Key patterns and conventions
   - Integration points

**Output**: Model document, contracts, realization guide

## Key rules

- Use absolute paths
- ERROR on gate failures or unresolved clarifications

