# Workflow Chains — Greeting Suggestion Data
# Source of truth: .claude/rules/workflow-execution.md
# Used by: Native agent greeting (STEP 3, step 5.5) to suggest next command
# Story: WIS-16

workflows:
  # 1. Story Development Cycle (SDC) — PRIMARY
  - id: sdc
    name: Story Development Cycle
    description: Full 4-phase workflow for all development work
    chain:
      - step: 1
        agent: "@sm"
        command: "*draft"
        task: create-next-story.md
        output: Story file (Draft)
        condition: Epic context available
      - step: 2
        agent: "@po"
        command: "*validate-story-draft {story-id}"
        task: validate-next-story.md
        output: GO/NO-GO decision
        condition: Story status is Draft
      - step: 3
        agent: "@dev"
        command: "*develop {story-id}"
        task: dev-develop-story.md
        output: Implementation complete
        condition: Story status is Approved
        alternatives:
          - agent: "@dev"
            command: "*develop-yolo {story-id}"
            condition: Simple story, autonomous mode preferred
      - step: 4
        agent: "@qa"
        command: "*review {story-id}"
        task: qa-gate.md
        output: PASS/CONCERNS/FAIL/WAIVED
        condition: Story status is Ready for Review
        alternatives:
          - agent: "@qa"
            command: "*gate {story-id}"
            condition: Quick gate decision needed
      - step: 5
        agent: "@devops"
        command: "*push"
        task: github-devops-pre-push-quality-gate.md
        output: Code pushed to remote
        condition: QA gate PASS

  # 2. QA Loop — ITERATIVE REVIEW
  - id: qa-loop
    name: QA Loop
    description: Automated review-fix cycle after initial QA gate
    max_iterations: 5
    chain:
      - step: 1
        agent: "@qa"
        command: "*review {story-id}"
        task: qa-review-story.md
        output: APPROVE/REJECT/BLOCKED verdict
        condition: Story has code changes to review
      - step: 2
        agent: "@dev"
        command: "*apply-qa-fixes"
        task: apply-qa-fixes.md
        output: Fixes applied
        condition: QA verdict is REJECT
        alternatives:
          - agent: "@dev"
            command: "*fix-qa-issues"
            condition: Structured fix from QA_FIX_REQUEST.md
      - step: 3
        agent: "@qa"
        command: "*review {story-id}"
        task: qa-review-story.md
        output: Re-review verdict
        condition: Fixes applied, re-review needed

  # 3. Spec Pipeline — PRE-IMPLEMENTATION
  - id: spec-pipeline
    name: Spec Pipeline
    description: Transform informal requirements into executable spec
    chain:
      - step: 1
        agent: "@pm"
        command: "*gather-requirements"
        task: spec-gather-requirements.md
        output: requirements.json
        condition: New feature or complex change
      - step: 2
        agent: "@architect"
        command: "*analyze-impact"
        task: architect-analyze-impact.md
        output: complexity.json
        condition: Complexity assessment needed (skip if SIMPLE)
      - step: 3
        agent: "@analyst"
        command: "*research {topic}"
        task: create-deep-research-prompt.md
        output: research.json
        condition: STANDARD or COMPLEX class (skip if SIMPLE)
      - step: 4
        agent: "@pm"
        command: "*write-spec"
        task: spec-write-spec.md
        output: spec.md
        condition: Requirements gathered
      - step: 5
        agent: "@qa"
        command: "*critique-spec {story-id}"
        task: spec-critique.md
        output: APPROVED/NEEDS_REVISION/BLOCKED
        condition: Spec written
      - step: 6
        agent: "@architect"
        command: "*plan"
        task: architect-analyze-impact.md
        output: implementation.yaml
        condition: Critique verdict is APPROVED

  # 4. Brownfield Discovery — LEGACY ASSESSMENT
  - id: brownfield
    name: Brownfield Discovery
    description: 10-phase technical debt assessment for existing codebases
    chain:
      - step: 1
        agent: "@architect"
        command: "*analyze-brownfield"
        task: analyze-brownfield.md
        output: system-architecture.md
        condition: Existing codebase to assess
      - step: 2
        agent: "@data-engineer"
        command: "*db-schema-audit"
        task: db-schema-audit.md
        output: SCHEMA.md + DB-AUDIT.md
        condition: Database exists in project
      - step: 3
        agent: "@ux-design-expert"
        command: "*audit-frontend"
        task: audit-codebase.md
        output: frontend-spec.md
        condition: Frontend exists in project
      - step: 4
        agent: "@qa"
        command: "*review"
        task: qa-review-story.md
        output: APPROVED/NEEDS WORK
        condition: All specialist reviews complete
      - step: 5
        agent: "@pm"
        command: "*create-epic"
        task: brownfield-create-epic.md
        output: Epic + stories ready for development
        condition: QA gate APPROVED

  # --- Cross-Agent Integration Chains (ADR-CROSS-AGENT-INTEGRATION) ---

  # Design-First Development (greenfield UI projects)
  - id: design-first-development
    name: Design-First Development
    domain: software-dev
    description: "Greenfield UI workflow starting with design intelligence"
    chain:
      - agent: ux-design-expert
        command: "*research"
        output: "user research insights"
      - agent: ux-design-expert
        command: "*style {domain}"
        output: "complete style baseline (palette, typography, spacing)"
      - agent: ux-design-expert
        command: "*wireframe"
        output: "visual wireframe in Paper (or markdown if Paper unavailable)"
      - agent: architect
        command: "*create-front-end-architecture"
        output: "frontend architecture doc"
      - agent: ux-design-expert
        command: "*setup"
        output: "design system structure initialized"
      - agent: dev
        command: "*develop"
        output: "implementation"

  # Design System Review Loop (post-migration quality)
  - id: design-system-review
    name: Design System Review Loop
    domain: software-dev
    description: "Quality review after design system migration or build"
    chain:
      - agent: ux-design-expert
        command: "*document"
        output: "pattern library documentation"
      - agent: ux-design-expert
        command: "*a11y-check"
        output: "WCAG compliance report"
      - agent: qa
        command: "*review"
        output: "quality gate verdict"
      - agent: smith
        command: "*verify"
        output: "adversarial review (optional)"
        optional: true

  # UX Handoff Suggestions (for SDC integration via handoff mechanism)
  - id: sdc-ux-handoff
    name: SDC UX Design Suggestion
    domain: software-dev
    description: "When PO validates a frontend story, suggest UX design prep before dev"
    trigger:
      from_agent: po
      last_command: "validate-story"
      condition: "story.tags includes frontend OR story.tags includes ui OR story.tags includes design"
    suggestions:
      - agent: ux-design-expert
        command: "*style {story.domain}"
        rationale: "Get design token baseline before implementation"
      - agent: ux-design-expert
        command: "*wireframe"
        rationale: "Create visual wireframe in Paper for story UI requirements"
      - agent: dev
        command: "*develop"
        rationale: "Proceed directly to development (skip UX prep)"

  # Design System Extraction → Migration (brownfield)
  - id: design-system-extraction-migration
    name: Design System Extraction to Migration
    domain: software-dev
    description: "Extract existing design system, then plan migration"
    chain:
      - agent: ux-design-expert
        command: "*extract-design-system {source}"
        output: "MASTER.md + tokens.css + tailwind.config.ts"
      - agent: ux-design-expert
        command: "*audit {path}"
        output: "pattern inventory and redundancies"
      - agent: ux-design-expert
        command: "*consolidate"
        output: "consolidated patterns"
      - agent: ux-design-expert
        command: "*tokenize"
        output: "design tokens extracted"
      - agent: ux-design-expert
        command: "*migrate"
        output: "4-phase migration strategy"
