You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: inject sorted git diff into broad review rule prompts
Rules with strategy all_changed_files or matches_together and a **/*
matcher now get git diff main..HEAD pre-fetched and injected into the
review instruction file. The diff is sorted by filepath to group files
by directory, reducing reviewer turn count. Diff is scoped to the
rule's source_dir so subdirectory .deepreview files get narrower diffs.
Also streamlines the /review skill to skip the get_configured_reviews
call and go straight to get_review_instructions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: plugins/claude/skills/review/SKILL.md
+4-8Lines changed: 4 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,16 +18,12 @@ Only proceed past this section if the user wants to **run** reviews.
18
18
19
19
## How to Run
20
20
21
-
1. First, call `mcp__deepwork__get_configured_reviews` to see what review rules are configured. This returns each rule's name, description, and which `.deepreview` file defines it. If reviewing specific files, pass `only_rules_matching_files` to see only the rules that apply. Share a brief summary of the active rules with the user before proceeding.
22
-
-**If no rules are configured**:
23
-
1. Use AskUserQuestion to tell the user there are no `.deepreview` rules set up yet and ask if they'd like the agent to auto-discover and suggest rules for this project.
24
-
2. If yes, invoke the `/deepwork` skill with the `deepwork_reviews` job's `discover_rules` workflow (which sets up native reviews, skill migration, documentation rules, and language-specific code review).
25
-
3. Stop here — do not proceed with running reviews if there are no rules.
26
-
2. Call the `mcp__deepwork__get_review_instructions` tool:
21
+
1. Call the `mcp__deepwork__get_review_instructions` tool directly:
27
22
-**No arguments** to review the current branch's changes (auto-detects via git diff against the main branch).
28
23
-**With `files`** to review only specific files: `mcp__deepwork__get_review_instructions(files=["src/app.py", "src/lib.py"])`. When provided, only reviews whose include/exclude patterns match the given files will be returned. Use this when the user asks to review a particular file or set of files rather than the whole branch.
29
-
3. The output will list review tasks to invoke in parallel. Each task has `name`, `description`, `subagent_type`, and `prompt` fields — these map directly to the Task tool parameters. Launch all of them as parallel Task agents.
30
-
4. Collect the results from all review agents.
24
+
-**If the result says no rules are configured**: Ask the user if they'd like to auto-discover and set up rules. If yes, invoke the `/deepwork` skill with the `deepwork_reviews` job's `discover_rules` workflow. Stop here — do not proceed with running reviews if there are no rules.
25
+
2. The output will list review tasks to invoke in parallel. Each task has `name`, `description`, `subagent_type`, and `prompt` fields — these map directly to the Task tool parameters. Launch all of them as parallel Task agents.
Copy file name to clipboardExpand all lines: specs/deepwork/review/REVIEW-REQ-004-rule-matching-and-strategies.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ After discovering review rules (REVIEW-REQ-002) and changed files (REVIEW-REQ-00
19
19
### REVIEW-REQ-004.2: Review Task Data Model
20
20
21
21
1. Each review task MUST be represented as a `ReviewTask` dataclass.
22
-
2. The `ReviewTask` MUST contain: `rule_name` (str), `files_to_review` (list[str] — paths relative to repo root), `instructions` (str), `agent_name` (str | None), `source_location` (str — formatted as `"path:line"`), `additional_files` (list[str] — unchanged matching files, relative to repo root), `all_changed_filenames` (list[str] | None).
22
+
2. The `ReviewTask` MUST contain: `rule_name` (str), `files_to_review` (list[str] — paths relative to repo root), `instructions` (str), `agent_name` (str | None), `source_location` (str — formatted as `"path:line"`), `additional_files` (list[str] — unchanged matching files, relative to repo root), `all_changed_filenames` (list[str] | None), `git_diff_output` (str | None — pre-fetched diff for broad rules, see REVIEW-REQ-004.11).
23
23
3.`files_to_review` MUST always contain at least one file path.
24
24
4.`source_location` MUST be formatted as `"{relative_path}:{line_number}"` where the path is relative to the project root (e.g., `"src/.deepreview:5"`).
25
25
@@ -71,3 +71,12 @@ After discovering review rules (REVIEW-REQ-002) and changed files (REVIEW-REQ-00
71
71
1. Rules with the same name defined in different `.deepreview` files MUST produce independent `ReviewTask` objects. The system MUST NOT merge or combine matched files across rules from different source directories.
72
72
2. When two `.deepreview` files in different directories define a rule with the same name and the same strategy, and changed files match both rules, the system MUST create separate `ReviewTask` objects — one per directory — each containing only the files that matched within its own `source_dir`.
73
73
3. This isolation is a consequence of REVIEW-REQ-004.1.2 (files outside `source_dir` do not match) but is stated explicitly because `.deepreview` files can be templated or symlinked across directories, making same-name rules a common scenario.
74
+
75
+
### REVIEW-REQ-004.11: Git Diff Injection for Broad Rules
76
+
77
+
1. When a rule has strategy `"all_changed_files"` or `"matches_together"` AND its `include` patterns contain `**/*`, the system MUST run `git diff <merge-base>..HEAD` and attach the output to the resulting `ReviewTask` as `git_diff_output`.
78
+
2. The git diff MUST be computed at most once per unique `source_dir` per `match_files_to_rules` invocation, even if multiple rules with the same `source_dir` qualify for injection.
79
+
3. If the git diff command fails or produces empty output, `git_diff_output` MUST be `None`.
80
+
4. Rules with strategy `"individual"` MUST NOT receive `git_diff_output`, regardless of their include patterns.
81
+
5. The `ReviewTask` dataclass MUST include a `git_diff_output: str | None` field defaulting to `None`.
82
+
6. When a rule's `source_dir` is a subdirectory of the project root, the git diff MUST be scoped to that subdirectory (via `-- <relpath>` pathspec). When `source_dir` equals the project root, the diff MUST cover the entire repository.
Copy file name to clipboardExpand all lines: specs/deepwork/review/REVIEW-REQ-005-instruction-generation.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,13 @@ For each `ReviewTask`, the system generates a self-contained markdown instructio
16
16
6. When the task has `additional_files` (unchanged matching files), the file MUST contain an "Unchanged Matching Files" section listing those file paths.
17
17
7. When the task has `all_changed_filenames`, the file MUST contain an "All Changed Files" section listing every changed filename for context.
18
18
19
+
### REVIEW-REQ-005.7: Git Diff Section
20
+
21
+
1. When a `ReviewTask` has a non-null `git_diff_output`, the instruction file MUST contain a section headed `## Output from \`git diff main..HEAD\` for you to review (sorted by filepath)`.
22
+
2. The diff output MUST be rendered inside a fenced code block with the `diff` language tag.
23
+
3. This section MUST appear after the "Files to Review" section and before the "All Changed Files" section.
24
+
4. When `git_diff_output` is `None`, this section MUST be omitted.
25
+
19
26
### REVIEW-REQ-005.2: File Path Formatting
20
27
21
28
1. File paths in the "Files to Review" section MUST be prefixed with `@` to trigger Claude Code's file-reading behavior (e.g., `@src/app.py`).
0 commit comments