# code-review Workflow Rule

This rule defines the code-review workflow.

## Workflow Description

Perform a Senior Developer code review on a completed story flagged Ready for Review, leveraging story-context, epic tech-spec, repo docs, MCP servers for latest best-practices, and web search as fallback. Appends structured review notes to the story.

## Workflow Definition

# Review Story Workflow
name: code-review
description: "Perform a Senior Developer code review on a completed story flagged Ready for Review, leveraging story-context, epic tech-spec, repo docs, MCP servers for latest best-practices, and web search as fallback. Appends structured review notes to the story."
author: "BMad"

# Critical variables from config
config_source: "{project-root}/.bmad/bmm/config.yaml"
output_folder: "{config_source}:output_folder"
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
sprint_artifacts: "{config_source}:sprint_artifacts"
sprint_status: "{sprint_artifacts}/sprint-status.yaml || {output_folder}/sprint-status.yaml"

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

variables:
  story_dir: "{sprint_artifacts}"
  tech_spec_search_dir: "{output_folder}"
  tech_spec_glob_template: "tech-spec-epic-{{epic_num}}*.md"
  arch_docs_search_dirs: |
    - "{output_folder}"
  arch_docs_file_names: |
    - architecture.md
  backlog_file: "{output_folder}/backlog.md"
  update_epic_followups: true
  epic_followups_section_title: "Post-Review Follow-ups"

# 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: "{output_folder}/*architecture*.md"
    sharded: "{output_folder}/*architecture*/*.md"
    load_strategy: "FULL_LOAD"
  ux_design:
    description: "UX design specification (if UI review)"
    whole: "{output_folder}/*ux*.md"
    sharded: "{output_folder}/*ux*/*.md"
    load_strategy: "FULL_LOAD"
  epics:
    description: "Epic containing story being reviewed"
    whole: "{output_folder}/*epic*.md"
    sharded_index: "{output_folder}/*epic*/index.md"
    sharded_single: "{output_folder}/*epic*/epic-{{epic_num}}.md"
    load_strategy: "SELECTIVE_LOAD"
  document_project:
    description: "Brownfield project documentation (optional)"
    sharded: "{output_folder}/index.md"
    load_strategy: "INDEX_GUIDED"

standalone: true

## Usage

Reference this workflow with `@workflow-code-review` to execute the guided workflow.

## Module

Part of the BMAD BMM module.
