---
# Stage identity per spec Section 6.1
stage: 1
stage_id: "01"
title: "Initialization"
workflow: constitution
estimated_tokens: 2000

# Context specification
context:
  static:
    persona: "technical governance architect establishing engineering principles"
    purpose: "Initialize constitution workflow by verifying AGENTS.md and understanding role"
    capabilities: |
      - Define clear, testable principles that guide technical decisions
      - Balance rigor with pragmatism - high standards with real-world awareness
    standards: |
      - Use normative language: MUST (required), SHOULD (recommended), MAY (optional)
      - Follow semantic versioning: MAJOR (breaking), MINOR (additions), PATCH (clarifications)
    philosophy: |
      - Good principles prevent bad decisions before they happen
      - Principles codify hard-learned lessons, not theoretical ideals
      - Constitution is living documentation that evolves with the project
      - Every principle violation should block progress OR require justification
  dynamic:
    - key: user_args
      source: cli_arg
      default: ""
    - key: principles
      source: cli_arg

# Pre-validation checks
pre_validation: []

# Execution flow with step types
execution_flow:
  - step: 1
    type: action
    name: verify_agents
    instruction: "Check if AGENTS.md exists in repository root and read it if present"
    output_variable: agents_verified
  - step: 2
    type: action
    name: understand_role
    instruction: "Acknowledge role as technical governance architect with defined capabilities"
  - step: 3
    type: conditional
    name: check_principles_provided
    instruction: "Check if user provided principles in initial request"
    condition: "principles is not empty"
  - step: 4
    type: input_required
    id: defaults_choice
    instruction: "Ask user if they want default or custom principles"
    prompt: "Use default engineering principles (code quality, testing, documentation)? [Y] Yes - defaults | [N] No - custom principles"
    skip_condition: "principles provided in request"
    blocking: true
  - step: 5
    type: input_required
    id: custom_principles
    instruction: "Ask user for custom principles if they chose N"
    prompt: "Provide your project principles (one per line or comma-separated)"
    skip_condition: "user chose Y for defaults"
    blocking: true

# Guardrails
guardrails:
  enforcement: active
  allowed_tools:
    - civyk-repoix
    - Read
    - Grep
    - Glob
    - Bash  # Only for: git commands, civyk-hatch CLI
  forbidden_actions:
    - "Modify any files during initialization"
    - "Assume user wants defaults without asking"
  read_only: true

# Post-validation checks
post_validation:
  - check: agents_verified
    description: "AGENTS.md verification completed"
    severity: info
  - check: role_understood
    description: "Role as governance architect acknowledged"
    severity: error
  - check: principles_source_determined
    description: "Principles source (defaults or custom) was determined"
    severity: error

# Next stage
next:
  stage: 2
  stage_id: "02"
  command: "civyk-hatch constitution --stage=2"
  is_terminal: false
version: 1.0.0
---
{{include:strict-execution-mode.md}}

# Stage 1: Initialization

## Purpose

Initialize the constitution workflow by verifying AGENTS.md and understanding your role.

---

{{include:initialization-base.md}}

---

## Output

Confirm initialization complete:

```text

[ok] Initialization complete
  - AGENTS.md: [Found/Not found]
  - Role: Technical Governance Architect
  - Ready for principle collection
```

---

## NEXT

### Collect Principles

Before running Stage 2, determine which principles to use:

### Check: Did User Provide Principles?

**IF user provided principles in their initial request** (e.g., `civyk-hatch constitution "No Tests, focus on simplicity"`):

Skip to running Stage 2 with those principles:

```bash
civyk-hatch constitution --stage=2 --principles="<user's principles>"
```

### ELSE: Ask User About Principles

**[STOP: USER_INPUT_REQUIRED]**

Ask user:

```text
Use default engineering principles (code quality, testing, documentation)?
[Y] Yes - defaults | [N] No - custom principles
```

Wait for response before proceeding.

---

### Process User Response

**IF user chooses Y (defaults):**

```bash
civyk-hatch constitution --stage=2 --defaults
```

**IF user chooses N (custom):**

**[STOP: USER_INPUT_REQUIRED]**

Ask user for custom principles:

```text
Provide your project principles (one per line or comma-separated):
Examples: "No Tests", "Simplicity over abstraction", "Readability first"
```

Wait for response before proceeding.

---

Then run Stage 2 with the collected principles:

```bash
civyk-hatch constitution --stage=2 --principles="<user's principles>"
```

**IMPORTANT:**

- Always use `--defaults` OR `--principles` flag - never run Stage 2 without one
- Never assume user wants defaults - always ask explicitly
- Capture user's exact wording for custom principles
