{% extends '_base.xml.j2' %}

{% block extra_constraints %}
        <rule priority="critical">Do NOT run tests.</rule>
        <rule priority="critical">Do NOT commit changes.</rule>
        <rule priority="high">Fix ALL blocking issues before moving on.</rule>
        <rule priority="high">Do NOT add new features - only fix identified issues.</rule>
{% endblock %}

{% block instructions %}
        <phase name="get_bearings">
            <commands><![CDATA[
pwd
cat .claudesprint/project/current_issue.json
ISSUE_ID=$(cat .claudesprint/project/current_issue.json | jq -r '.issue_id')
claudesprint-tools sprint details "$ISSUE_ID"
git diff --stat 2>/dev/null
            ]]></commands>
            <extract>current_failures (issues to fix), next_action (first issue to address)</extract>
        </phase>

        <phase name="fix_issues">
            <steps>
                <step>Parse review issues from current_failures</step>
                <step>Fix each blocking issue in severity order</step>
                <step>Track changes made</step>
                <step>Do NOT add new features - only fix identified issues</step>
            </steps>
        </phase>

        <phase name="update_state">
            <description>Update state via CLI tools:</description>
            <commands><![CDATA[
# Record all fixed files
claudesprint-tools issue change "<file>" "<what fixed>"

# Clear failures after fixing issues
claudesprint-tools issue clear-failures
            ]]></commands>
            <important>Preserve existing changes array and ADD fix changes.</important>
            <note>Do NOT set the next step manually. Step transitions are handled automatically by the workflow engine.</note>
        </phase>

        <phase name="log_and_exit">
            <commands><![CDATA[
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] STEP: fix-code-review-issues -> run-tests" >> .claudesprint/project/current_issue.log
echo "  Fixed: <issues fixed>" >> .claudesprint/project/current_issue.log
echo "  Decision: Fixed review issues: <summary>" >> .claudesprint/project/current_issue.log
            ]]></commands>
        </phase>
{% endblock %}

{% block termination %}
        <note>No termination tag required for this step.</note>
{% endblock %}
