---

# Stage identity per spec Section 6.1
stage: 3
stage_id: "03"
title: "Generate Checklist"
workflow: checklist
estimated_tokens: 3000

# Context specification
context:
  static:
    persona: "rigorous QA engineer generating unit tests for requirements"
    purpose: "Generate checklist that validates requirement quality"
  dynamic:
    - key: feature_dir
      source: cli_arg
    - key: checklist_focus
      source: state

# Pre-validation checks
pre_validation:
  - check: stage_02_completed
    condition: "state.checklist.current_stage == '02-clarify'"
    message: "Stage 02 (Clarify Intent) must be completed first"
    recovery: "civyk-hatch checklist --stage=2"
  - check: focus_exists
    condition: "checklist focus was determined in stage 02"
    message: "Checklist focus must exist from stage 02"
    recovery: "civyk-hatch checklist --stage=2"

# Execution flow with step types
execution_flow:
  - step: 1
    type: action
    name: prepare_structure
    instruction: "Prepare checklist structure based on focus and quality dimensions"
    output_variable: structure
  - step: 2
    type: action
    name: generate_items
    instruction: "Generate checklist items organized by quality dimensions with traceability"
    output_variable: items
  - step: 3
    type: action
    name: write_checklist
    instruction: "Write checklist file to feature_dir/checklists/[domain].md"
    output_variable: checklist_file

# Guardrails
guardrails:
  enforcement: active
  allowed_tools:
    - civyk-repoix
    - Read
    - Write
    - Grep
    - Glob
    - Bash
  forbidden_actions:
    - "Generate items that test implementation instead of requirements"
    - "Skip traceability references"
  file_restrictions:
    allowed_paths:
      - "{{feature_dir}}/checklists/**"
    forbidden_paths:
      - ".env"
      - "**/*.key"
  read_only: false

# Post-validation checks
post_validation:
  - check: checklist_generated
    description: "Checklist file was created"
    severity: error
  - check: traceability_met
    description: "80%+ items have traceability references"
    severity: warning
  - check: quality_dimensions
    description: "Items are organized by quality dimensions"
    severity: warning

# Output specification
output:
  state_update:
    checklist.status: "completed"
    checklist.current_stage: "03-generate"
  completion_command: "civyk-hatch update-stage checklist 03 --status completed"
  artifacts:
    - type: checklist
      path: "{{feature_dir}}/checklists/{{domain}}.md"
      description: "Requirements quality checklist"

# Next stage
next:
  is_terminal: true
version: 1.0.0
---

{{include:verification-rules.md}}

{{include:ai-cache-enforcement.md}}

# Stage 3: Generate Checklist

## Purpose

Generate "unit tests for requirements" checklist.

---

## File Write Best Practices

**For large checklists:**

- Write checklist in sections if total content exceeds 2000 characters
- Group by quality dimension: Completeness, then Clarity, etc.
- If using shell commands with content, be aware of OS limits (~8000 chars on Windows)

---

## Item Format

**[ok] CORRECT (Testing requirements):**

- "Are visual hierarchy requirements defined with measurable criteria? [Clarity]"
- "Are hover state requirements consistent across all elements? [Consistency]"
- "Is fallback behavior defined when images fail to load? [Edge Case, Gap]"

**[x] WRONG (Testing implementation):**

- "Verify button clicks correctly"
- "Test hover states work"
- "Confirm API returns 200"

---

## Quality Dimensions

Organize items by:

- **Completeness**: Are all requirements present?
- **Clarity**: Are requirements unambiguous?
- **Consistency**: Do requirements align?
- **Measurability**: Can requirements be verified?
- **Coverage**: Are all scenarios addressed?
- **Edge Cases**: Are boundaries defined?

---

## Traceability

80%+ items MUST include:

- `[Spec SX.Y]` - Reference to spec section
- `[Gap]` - Missing requirement
- `[Ambiguity]` - Unclear requirement
- `[Conflict]` - Contradicting requirements

---

## File Structure

Create: `{{feature_dir}}/checklists/[domain].md`

```markdown
# [Domain] Requirements Quality Checklist

**Purpose**: Validate [domain] requirement quality
**Created**: {{date}}
**Feature**: {{feature_name}}

## Requirement Completeness
- [ ] CHK001 - Are [X] requirements defined? [Gap]

## Requirement Clarity
- [ ] CHK002 - Is '[term]' quantified? [Ambiguity, Spec SX]

## Scenario Coverage
- [ ] CHK003 - Are [edge cases] addressed? [Coverage]
```

---

## Output

```text

[ok] Checklist generated

File: {{feature_dir}}/checklists/[domain].md
Items: [N] total
Traceability: [N]% with references

Focus: [domain]
Audience: [audience]
```

---

## WORKFLOW COMPLETE

Checklist ready for requirements validation.

**Note**: Each `/civyk-hatch.checklist` run creates a NEW file. Use descriptive domain names.
