# Example: Code Review Procedure (Pattern 1 - Step-Based Workflow)

Demonstrates Pattern 1 (Step-Based Workflow) with distinct constraints, outputs, and success criteria per step.

```xml
<procedure name="Code Review">
  
  <step_1>
    <name>Gather Context</name>
    <action>
      1. Read the pull request description
      2. Identify the feature/bug being addressed
      3. Review linked issues or requirements
    </action>
    <constraints>
      - BLOCKING: Do not start review without understanding the intent
      - CRITICAL: Check if there are related PRs that should be reviewed together
    </constraints>
    <success_criteria>
      - Intent of change is understood
      - Scope of change is identified
      - Related context is loaded
    </success_criteria>
    <output>Review context document with intent + scope</output>
  </step_1>

  <step_2>
    <name>Analyze Diff</name>
    <requires>Review context from step_1</requires>
    <action>
      1. Review each changed file
      2. Check for logic errors, security issues, performance problems
      3. Verify coding standards compliance
      4. Check test coverage for changes
    </action>
    <constraints>
      - BLOCKING: Security vulnerabilities must be flagged
      - CRITICAL: Do not approve if tests are missing for new logic
      - MANDATORY: Check for breaking changes in public APIs
    </constraints>
    <success_criteria>
      - All files reviewed
      - Issues categorized by severity
      - No blocking issues remain unaddressed
    </success_criteria>
    <output>List of review comments with severity levels</output>
  </step_2>

  <step_3>
    <name>Provide Feedback</name>
    <requires>Review comments from step_2</requires>
    <action>
      1. Group comments by file
      2. Prioritize blocking issues first
      3. Suggest specific fixes where possible
      4. Acknowledge good patterns
    </action>
    <constraints>
      - CRITICAL: Be constructive, not dismissive
      - MANDATORY: Explain why, not just what
    </constraints>
    <success_criteria>
      - All issues communicated clearly
      - Actionable suggestions provided
      - Overall assessment given (approve/request changes)
    </success_criteria>
    <output>Review submitted with decision</output>
  </step_3>

  <sub-agent-planning>
    <sub_agent_1>
      <sub_agent_definition>
        <role>Security Reviewer</role>
        <prompt>Review the code changes for security vulnerabilities including SQL injection, XSS, authentication bypasses, and data exposure risks. Return list of security issues with severity.</prompt>
      </sub_agent_definition>
      <workflow_step_reference>step_2</workflow_step_reference>
    </sub_agent_1>
  </sub-agent-planning>

</procedure>
```
