|
| 1 | +--- |
| 2 | +name: mgw:review |
| 3 | +description: Review and classify new comments on a GitHub issue since last triage |
| 4 | +argument-hint: "<issue-number>" |
| 5 | +allowed-tools: |
| 6 | + - Bash |
| 7 | + - Read |
| 8 | + - Write |
| 9 | + - Edit |
| 10 | + - Task |
| 11 | + - AskUserQuestion |
| 12 | +--- |
| 13 | + |
| 14 | +<objective> |
| 15 | +Standalone comment review for a triaged issue. Fetches new comments posted since |
| 16 | +triage, classifies them (material/informational/blocking), and updates the state |
| 17 | +file accordingly. |
| 18 | + |
| 19 | +Use this when you want to check for stakeholder feedback before running the pipeline, |
| 20 | +or to review comments on a blocked issue before unblocking it. |
| 21 | +</objective> |
| 22 | + |
| 23 | +<execution_context> |
| 24 | +@~/.claude/commands/mgw/workflows/state.md |
| 25 | +@~/.claude/commands/mgw/workflows/github.md |
| 26 | +@~/.claude/commands/mgw/workflows/gsd.md |
| 27 | +@~/.claude/commands/mgw/workflows/validation.md |
| 28 | +</execution_context> |
| 29 | + |
| 30 | +<context> |
| 31 | +Issue number: $ARGUMENTS |
| 32 | + |
| 33 | +State: .mgw/active/ (must exist — issue must be triaged first) |
| 34 | +</context> |
| 35 | + |
| 36 | +<process> |
| 37 | + |
| 38 | +<step name="validate_and_load"> |
| 39 | +**Validate input and load state:** |
| 40 | + |
| 41 | +```bash |
| 42 | +REPO_ROOT=$(git rev-parse --show-toplevel) |
| 43 | +``` |
| 44 | + |
| 45 | +Parse $ARGUMENTS for issue number. If missing: |
| 46 | +``` |
| 47 | +AskUserQuestion( |
| 48 | + header: "Issue Number Required", |
| 49 | + question: "Which issue number do you want to review comments for?", |
| 50 | + followUp: "Enter the GitHub issue number (e.g., 42)" |
| 51 | +) |
| 52 | +``` |
| 53 | + |
| 54 | +Load state file: `${REPO_ROOT}/.mgw/active/${ISSUE_NUMBER}-*.json` |
| 55 | + |
| 56 | +If no state file exists: |
| 57 | +``` |
| 58 | +Issue #${ISSUE_NUMBER} hasn't been triaged yet. |
| 59 | +Run /mgw:issue ${ISSUE_NUMBER} first, then review comments. |
| 60 | +``` |
| 61 | +</step> |
| 62 | + |
| 63 | +<step name="fetch_comments"> |
| 64 | +**Fetch current comment state from GitHub:** |
| 65 | + |
| 66 | +```bash |
| 67 | +CURRENT_COMMENTS=$(gh issue view $ISSUE_NUMBER --json comments --jq '.comments | length' 2>/dev/null || echo "0") |
| 68 | +STORED_COMMENTS="${triage.last_comment_count}" |
| 69 | + |
| 70 | +if [ -z "$STORED_COMMENTS" ] || [ "$STORED_COMMENTS" = "null" ]; then |
| 71 | + STORED_COMMENTS=0 |
| 72 | +fi |
| 73 | + |
| 74 | +NEW_COUNT=$(($CURRENT_COMMENTS - $STORED_COMMENTS)) |
| 75 | +``` |
| 76 | + |
| 77 | +If no new comments (`NEW_COUNT <= 0`): |
| 78 | +``` |
| 79 | +No new comments on #${ISSUE_NUMBER} since triage (${STORED_COMMENTS} comments at triage, ${CURRENT_COMMENTS} now). |
| 80 | +``` |
| 81 | +Stop. |
| 82 | + |
| 83 | +If new comments exist, fetch them: |
| 84 | +```bash |
| 85 | +NEW_COMMENTS=$(gh issue view $ISSUE_NUMBER --json comments \ |
| 86 | + --jq "[.comments[-${NEW_COUNT}:]] | .[] | {author: .author.login, body: .body, createdAt: .createdAt}" 2>/dev/null) |
| 87 | +``` |
| 88 | +</step> |
| 89 | + |
| 90 | +<step name="classify_comments"> |
| 91 | +**Spawn classification agent:** |
| 92 | + |
| 93 | +``` |
| 94 | +Task( |
| 95 | + prompt=" |
| 96 | +<files_to_read> |
| 97 | +- ./CLAUDE.md (Project instructions — if exists, follow all guidelines) |
| 98 | +</files_to_read> |
| 99 | +
|
| 100 | +Classify new comments on GitHub issue #${ISSUE_NUMBER}. |
| 101 | +
|
| 102 | +<issue_context> |
| 103 | +Title: ${issue_title} |
| 104 | +Current pipeline stage: ${pipeline_stage} |
| 105 | +GSD Route: ${gsd_route} |
| 106 | +Triage scope: ${triage.scope} |
| 107 | +</issue_context> |
| 108 | +
|
| 109 | +<new_comments> |
| 110 | +${NEW_COMMENTS} |
| 111 | +</new_comments> |
| 112 | +
|
| 113 | +<classification_rules> |
| 114 | +Classify each comment (and the overall batch) into ONE of: |
| 115 | +
|
| 116 | +- **material** — Comment changes scope, requirements, acceptance criteria, or design. |
| 117 | + Examples: 'Actually we also need to handle X', 'Changed the requirement to Y', |
| 118 | + 'Don't forget about edge case Z'. |
| 119 | +
|
| 120 | +- **informational** — Status update, acknowledgment, question that doesn't change scope, +1. |
| 121 | + Examples: 'Looks good', 'Thanks for picking this up', 'What's the ETA?', '+1'. |
| 122 | +
|
| 123 | +- **blocking** — Explicit instruction to stop or wait. Must contain clear hold language. |
| 124 | + Examples: 'Don't work on this yet', 'Hold off', 'Blocked by external dependency', |
| 125 | + 'Wait for design review'. |
| 126 | +
|
| 127 | +If ANY comment in the batch is blocking, overall classification is blocking. |
| 128 | +If ANY comment is material (and none blocking), overall classification is material. |
| 129 | +Otherwise, informational. |
| 130 | +</classification_rules> |
| 131 | +
|
| 132 | +<output_format> |
| 133 | +Return ONLY valid JSON: |
| 134 | +{ |
| 135 | + \"classification\": \"material|informational|blocking\", |
| 136 | + \"reasoning\": \"Brief explanation of why this classification was chosen\", |
| 137 | + \"per_comment\": [ |
| 138 | + { |
| 139 | + \"author\": \"username\", |
| 140 | + \"snippet\": \"first 100 chars of comment\", |
| 141 | + \"classification\": \"material|informational|blocking\" |
| 142 | + } |
| 143 | + ], |
| 144 | + \"new_requirements\": [\"list of new requirements if material, empty array otherwise\"], |
| 145 | + \"blocking_reason\": \"reason if blocking, empty string otherwise\" |
| 146 | +} |
| 147 | +</output_format> |
| 148 | +", |
| 149 | + subagent_type="general-purpose", |
| 150 | + description="Classify comments on #${ISSUE_NUMBER}" |
| 151 | +) |
| 152 | +``` |
| 153 | +</step> |
| 154 | + |
| 155 | +<step name="present_and_act"> |
| 156 | +**Present classification and offer actions:** |
| 157 | + |
| 158 | +Display the classification result: |
| 159 | + |
| 160 | +``` |
| 161 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 162 | + MGW ► COMMENT REVIEW — #${ISSUE_NUMBER} |
| 163 | +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ |
| 164 | +
|
| 165 | +New comments: ${NEW_COUNT} since triage |
| 166 | +Classification: ${classification} |
| 167 | +Reasoning: ${reasoning} |
| 168 | +
|
| 169 | +${per_comment_table} |
| 170 | +
|
| 171 | +${if material: 'New requirements detected:\n' + new_requirements} |
| 172 | +${if blocking: 'Blocking reason: ' + blocking_reason} |
| 173 | +``` |
| 174 | + |
| 175 | +Offer actions based on classification: |
| 176 | + |
| 177 | +**If informational:** |
| 178 | +``` |
| 179 | +AskUserQuestion( |
| 180 | + header: "Informational Comments", |
| 181 | + question: "Mark comments as reviewed and update state?", |
| 182 | + options: [ |
| 183 | + { label: "Yes", description: "Update last_comment_count, continue" }, |
| 184 | + { label: "No", description: "Keep current state, don't update count" } |
| 185 | + ] |
| 186 | +) |
| 187 | +``` |
| 188 | +If yes: update `triage.last_comment_count` to $CURRENT_COMMENTS in state file. |
| 189 | + |
| 190 | +**If material:** |
| 191 | +``` |
| 192 | +AskUserQuestion( |
| 193 | + header: "Material Comments Detected", |
| 194 | + question: "How should MGW handle the scope change?", |
| 195 | + options: [ |
| 196 | + { label: "Acknowledge and continue", description: "Update state with new requirements, keep current route" }, |
| 197 | + { label: "Re-triage", description: "Run /mgw:issue to re-analyze with new context" }, |
| 198 | + { label: "Ignore", description: "Don't update state" } |
| 199 | + ] |
| 200 | +) |
| 201 | +``` |
| 202 | +If acknowledge: update `triage.last_comment_count` and store new_requirements in state. |
| 203 | +If re-triage: suggest running `/mgw:issue ${ISSUE_NUMBER}` to re-triage. |
| 204 | + |
| 205 | +**If blocking:** |
| 206 | +``` |
| 207 | +AskUserQuestion( |
| 208 | + header: "Blocking Comment Detected", |
| 209 | + question: "Block the pipeline for this issue?", |
| 210 | + options: [ |
| 211 | + { label: "Block", description: "Set pipeline_stage to 'blocked'" }, |
| 212 | + { label: "Override", description: "Ignore blocker, keep current stage" }, |
| 213 | + { label: "Review", description: "I'll review the comments manually" } |
| 214 | + ] |
| 215 | +) |
| 216 | +``` |
| 217 | +If block: update `pipeline_stage = "blocked"` and `triage.last_comment_count` in state. |
| 218 | +If override: update `triage.last_comment_count` only, keep pipeline_stage. |
| 219 | +</step> |
| 220 | + |
| 221 | +</process> |
| 222 | + |
| 223 | +<success_criteria> |
| 224 | +- [ ] Issue state loaded from .mgw/active/ |
| 225 | +- [ ] Current comment count fetched from GitHub |
| 226 | +- [ ] New comments identified (delta from stored count) |
| 227 | +- [ ] Classification agent spawned and returned structured result |
| 228 | +- [ ] Classification presented to user with per-comment breakdown |
| 229 | +- [ ] User chose action (acknowledge/re-triage/block/ignore) |
| 230 | +- [ ] State file updated according to user choice |
| 231 | +</success_criteria> |
0 commit comments