Skip to content

Commit 87fa2b4

Browse files
alexeyvclaude
andcommitted
refactor(code-review): harmonize step-01 intent cascade with quick-dev and checkpoint-preview
Replace keyword-matching entry point with 5-tier priority cascade: explicit argument → recent conversation → sprint tracking → git state → ask. Diff-mode keyword detection preserved as sub-check within tier 1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d51e215 commit 87fa2b4

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

src/bmm-skills/4-implementation/bmad-code-review/steps/step-01-gather-context.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,37 @@ story_key: '' # set at runtime when discovered from sprint status
1515

1616
## INSTRUCTIONS
1717

18-
1. **Detect review intent from invocation text.** Check the triggering prompt for phrases that map to a review mode:
19-
- "staged" / "staged changes" → Staged changes only
20-
- "uncommitted" / "working tree" / "all changes" → Uncommitted changes (staged + unstaged)
21-
- "branch diff" / "vs main" / "against main" / "compared to {branch}" → Branch diff (extract base branch if mentioned)
22-
- "commit range" / "last N commits" / "{sha}..{sha}" → Specific commit range
23-
- "this diff" / "provided diff" / "paste" → User-provided diff (do not match bare "diff" — it appears in other modes)
24-
- When multiple phrases match, prefer the most specific match (e.g., "branch diff" over bare "diff").
25-
- **If a clear match is found:** Announce the detected mode (e.g., "Detected intent: review staged changes only") and proceed directly to constructing `{diff_output}` using the corresponding sub-case from instruction 3. Skip to instruction 4 (spec question).
26-
- **If no match from invocation text, check sprint tracking.** Look for a sprint status file (`*sprint-status*`) in `{implementation_artifacts}` or `{planning_artifacts}`. If found, scan for any story with status `review`. Handle as follows:
27-
- **Exactly one `review` story:** Set `{story_key}` to the story's key (e.g., `1-2-user-auth`). Suggest it: "I found story {{story-id}} in `review` status. Would you like to review its changes? [Y] Yes / [N] No, let me choose". If confirmed, use the story context to determine the diff source (branch name derived from story slug, or uncommitted changes). If declined, clear `{story_key}` and fall through to instruction 2.
28-
- **Multiple `review` stories:** Present them as numbered options alongside a manual choice option. Wait for user selection. If the user selects a story, set `{story_key}` to the selected story's key and use the selected story's context to determine the diff source as in the single-story case above, and proceed to instruction 3. If the user selects the manual choice, clear `{story_key}` and fall through to instruction 2.
29-
- **If no match and no sprint tracking:** Fall through to instruction 2.
18+
1. **Find the review target.** The conversation context before this skill was triggered IS your starting point — not a blank slate. Check in this order — stop as soon as the review target is identified:
19+
20+
**Tier 1 — Explicit argument.**
21+
Did the user pass a PR, commit SHA, branch, spec file, or diff source this message?
22+
- PR reference → resolve to branch/commit via `gh pr view`. If resolution fails, ask for a SHA or branch.
23+
- Commit or branch → use directly.
24+
- Spec file → check its frontmatter for `baseline_commit`. If found, use as diff baseline. If not found, note the spec for instruction 4 and continue the cascade (a spec alone does not identify a diff source).
25+
- Also scan the argument for diff-mode keywords that narrow the scope:
26+
- "staged" / "staged changes" → Staged changes only
27+
- "uncommitted" / "working tree" / "all changes" → Uncommitted changes (staged + unstaged)
28+
- "branch diff" / "vs main" / "against main" / "compared to {branch}" → Branch diff (extract base branch if mentioned)
29+
- "commit range" / "last N commits" / "{sha}..{sha}" → Specific commit range
30+
- "this diff" / "provided diff" / "paste" → User-provided diff (do not match bare "diff" — it appears in other modes)
31+
- When multiple keywords match, prefer the most specific (e.g., "branch diff" over bare "diff").
32+
33+
**Tier 2 — Recent conversation.**
34+
Do the last few messages reveal what the user wants reviewed? Look for spec paths, commit refs, branches, PRs, or descriptions of a change. Apply the same diff-mode keyword scan and routing as Tier 1.
35+
36+
**Tier 3 — Sprint tracking.**
37+
Look for a sprint status file (`*sprint-status*`) in `{implementation_artifacts}` or `{planning_artifacts}`. If found, scan for stories with status `review`:
38+
- **Exactly one `review` story:** Set `{story_key}` to the story's key (e.g., `1-2-user-auth`). Suggest it: "I found story {{story-id}} in `review` status. Would you like to review its changes? [Y] Yes / [N] No, let me choose". If confirmed, use the story context to determine the diff source (branch name derived from story slug, or uncommitted changes). If declined, clear `{story_key}` and fall through.
39+
- **Multiple `review` stories:** Present them as numbered options alongside a manual choice option. Wait for user selection. If a story is selected, set `{story_key}` and use its context to determine the diff source. If manual choice is selected, clear `{story_key}` and fall through.
40+
- **None:** Fall through.
41+
42+
**Tier 4 — Current git state.**
43+
If version control is unavailable, skip to Tier 5. Otherwise, check the current branch and HEAD. If the branch is not `main` (or the default branch), confirm: "I see HEAD is `<short-sha>` on `<branch>` — do you want to review this branch's changes?" If confirmed, treat as a branch diff against `main`. If declined, fall through.
44+
45+
**Tier 5 — Ask.**
46+
Fall through to instruction 2.
47+
48+
Never ask extra questions beyond what the cascade prescribes. If a tier above already identified the target, skip the remaining tiers and proceed to instruction 3 (construct diff).
3049

3150
2. HALT. Ask the user: **What do you want to review?** Present these options:
3251
- **Uncommitted changes** (staged + unstaged)

0 commit comments

Comments
 (0)