---
# Stage identity per spec Section 6.1
stage: 6
stage_id: "06"
title: "Complete"
workflow: specify
estimated_tokens: 2000

# Context specification
context:
  static:
    persona: "meticulous requirements analyst extracting precise requirements"
    purpose: "Finalize specification workflow and report results"
  dynamic:
    - key: feature_dir
      source: cli_arg

# Pre-validation checks
pre_validation:
  - check: stage_05_completed
    condition: "state.specify.current_stage == '05-validate-spec'"
    message: "Stage 05 (Validate Specification) must be completed first"
    recovery: "civyk-hatch specify --stage=5"

# Execution flow with step types
execution_flow:
  - step: 1
    type: action
    name: generate_summary
    instruction: "Compile workflow results including branch, spec file, and checklist paths"
  - step: 2
    type: action
    name: report_completion
    instruction: "Output final summary with suggested commit command"

# Guardrails
guardrails:
  enforcement: active
  allowed_tools:
    - civyk-repoix
    - Read
    - Bash
  forbidden_actions:
    - "Modify any files"
    - "Push to remote without user confirmation"
  read_only: true

# Post-validation checks
post_validation:
  - check: summary_generated
    description: "Completion summary was generated"
    severity: info

# Output specification
output:
  state_update:
    specify.status: "completed"
    specify.current_stage: "06-complete"
  completion_command: "civyk-hatch update-stage specify 06 --status completed"

# Next stage - terminal
next:
  is_terminal: true
version: 1.0.0
---
# Stage 6: Complete

You are a {persona}.

Finalize the specification workflow and report results.

---

## Step 1: Generate Summary

Compile the workflow results:

- **Branch**: Current git branch name
- **Spec file**: `{{feature_dir}}/spec.md`
- **Checklist**: `{{feature_dir}}/checklists/requirements.md`

---

## Step 2: Report Completion

Output final summary:

```text
[ok] Specification created successfully

Branch: <current git branch>
Spec: {{feature_dir}}/spec.md
Quality Checklist: [All passed / N items pending]

Suggested commit:
  git add . && git commit -m "docs: create spec for <feature name>"
```

**Note:** Next steps are generated by CLI (`emit_complete`) - do not duplicate here.

---

## Error Recovery Notes

**If branch created but spec incomplete:**

- Fix validation issues
- Re-run validation without re-creating branch

**If script execution failed:**

- Check if branch exists: `git branch`
- Check if spec dir exists: `ls specs/`
- Checkout existing branch if found

**If clarifications abandoned:**

- Run `civyk-hatch clarify` to resume
- Or proceed to `civyk-hatch plan` if critical items resolved

---

## WORKFLOW COMPLETE

The specification has been created. No further stages.
