# Review Story Workflow
name: code-review
description: "Perform an ADVERSARIAL Senior Developer code review that finds 3-10 specific problems in every story. Challenges everything: code quality, test coverage, architecture compliance, security, performance. NEVER accepts `looks good` - must find minimum issues and can auto-fix with user approval."
author: "BMad"

# Critical variables from config
config_source: "{project-root}/_bmad/bmm/config.yaml"
user_name: "{config_source}:user_name"
communication_language: "{config_source}:communication_language"
user_skill_level: "{config_source}:user_skill_level"
document_output_language: "{config_source}:document_output_language"
date: system-generated
planning_artifacts: "{config_source}:planning_artifacts"
epics_artifacts: "{config_source}:epics_artifacts"
stories_artifacts: "{config_source}:stories_artifacts"
prd_artifacts: "{config_source}:prd_artifacts"
architecture_artifacts: "{config_source}:architecture_artifacts"
implementation_artifacts: "{config_source}:implementation_artifacts"
output_folder: "{implementation_artifacts}"
sprint_status: "{implementation_artifacts}/sprint-status.yaml"

# Workflow components
installed_path: "{project-root}/_bmad/bmm/workflows/4-implementation/code-review"
instructions: "{installed_path}/instructions.xml"
validation: "{installed_path}/checklist.md"
template: false

variables:
  # Project context
  project_context: "**/project-context.md"
  story_dir: "{stories_artifacts}"

# Smart input file references - handles both whole docs and sharded docs
# Priority: Whole document first, then sharded version
# Strategy: SELECTIVE LOAD - only load the specific epic needed for this story review
input_file_patterns:
  architecture:
    description: "System architecture for review context"
    whole: "{planning_artifacts}/*architecture*.md"
    sharded: "{architecture_artifacts}/*.md"
    sharded_index: "{architecture_artifacts}/index.md"
    load_strategy: "FULL_LOAD"
  ux_design:
    description: "UX design specification (if UI review)"
    whole: "{planning_artifacts}/*ux*.md"
    sharded: "{planning_artifacts}/*ux*/*.md"
    load_strategy: "FULL_LOAD"
  epics:
    description: "Epic containing story being reviewed"
    whole: "{epics_artifacts}/*epic*.md"
    sharded_root: "{planning_artifacts}/*epic*.md"
    sharded_index: "{epics_artifacts}/*epic*/index.md"
    sharded_single: "{epics_artifacts}/*epic*/epic-{{epic_num}}.md"
    load_strategy: "SELECTIVE_LOAD"

standalone: true