11# Rust Code Review
22
3- Review Rust code changes for correctness, safety, and idiomatic patterns.
3+ Review Rust code changes for correctness, safety, idiomatic patterns, regressions, and scope discipline. Automatically split oversized commits .
44
55## Steps
66
771 . Get the diff to review:
88 ``` bash
99 git diff origin/main...HEAD
1010 ```
11- If origin/main doesn't exist (new repo), use :
11+ If that's empty, try unstaged changes :
1212 ``` bash
13- git diff --cached HEAD
13+ git diff
1414 ```
15- If that's empty, diff all commits :
15+ If origin/main doesn't exist (new repo), use :
1616 ``` bash
17- git log --oneline --all
17+ git diff --cached HEAD
1818 ```
1919
20202 . Run ` cargo clippy ` for lint checks:
@@ -27,16 +27,61 @@ Review Rust code changes for correctness, safety, and idiomatic patterns.
2727 cd /Users/kshum/Documents/gitproj/semantic-diff && cargo build 2>&1
2828 ```
2929
30- 4 . Review the diff for:
30+ 4 . Run ` cargo test ` to catch regressions:
31+ ``` bash
32+ cd /Users/kshum/Documents/gitproj/semantic-diff && cargo test 2>&1
33+ ```
34+
35+ 5 . ** Regression analysis** — Review the diff for changes that may break existing behavior:
36+ - Changed function signatures (parameters added/removed/retyped)
37+ - Modified match arms or conditional branches that alter control flow
38+ - Removed or renamed public items (structs, enums, functions, methods)
39+ - Changed default values or config parsing logic
40+ - Modified serialization/deserialization formats
41+ - Altered event handling or key binding behavior
42+ Flag each potential regression with the affected area and severity.
43+
44+ 6 . ** Code quality review** — Check for:
3145 - Unsafe code without justification
3246 - Unwrap/expect on fallible operations in non-test code
3347 - Missing error handling
3448 - Unused dependencies
3549 - Dead code that should be cleaned up
3650
37- 5 . After review completes, write the state file to allow push:
51+ 7 . ** Scope analysis — Detect out-of-scope changes:**
52+ Classify every changed file into a logical concern (e.g., "config parsing", "diff engine", "UI rendering", "file tree sidebar", "grouper logic"). Then:
53+ - Identify the ** primary intent** of the changeset (the concern touching the most files/lines)
54+ - Flag files whose concern does ** not** match the primary intent as ** out-of-scope**
55+ - Flag unrelated formatting-only, refactor-only, or drive-by fixes as out-of-scope
56+ - Report a scope summary table:
57+ | Concern | Files | In-scope? |
58+ | ---------| -------| -----------|
59+
60+ 8 . ** Auto-split into smaller commits** if the changeset spans multiple concerns:
61+ - Group changed files by concern from step 7
62+ - For each concern group, stage only its files and create a focused commit
63+ - Use clear commit message prefixes: ` feat: ` , ` fix: ` , ` refactor: ` , ` chore: `
64+ - Commit order: foundational changes first (models/types → logic → UI → config)
65+ - If a single file contains changes for multiple concerns, use ` git add -p ` to stage only the relevant hunks
66+ - ** Ask the user for confirmation** before creating any commits, showing the proposed split plan:
67+ ```
68+ Proposed commit split:
69+ 1. feat(diff): add untracked file support — src/diff/mod.rs, src/diff/untracked.rs, src/diff/parser.rs
70+ 2. refactor(grouper): improve group filtering — src/grouper/mod.rs
71+ 3. feat(ui): enhance file tree with search and icons — src/ui/file_tree.rs, src/ui/diff_view.rs
72+ 4. fix(config): update default settings — src/config.rs, src/main.rs
73+ ```
74+ - Only proceed with committing after user approval
75+
76+ 9. After review and commits complete, write the state file to allow push:
3877 ```bash
3978 cd /Users/kshum/Documents/gitproj/semantic-diff && git rev-parse HEAD > "$(git rev-parse --git-dir)/.pre-push-reviewed"
4079 ```
4180
42- 6 . Report findings as a short summary.
81+ 10 . Report findings as a structured summary:
82+ - ** Build/Lint** : pass/fail
83+ - ** Tests** : pass/fail (number of tests)
84+ - ** Regressions** : list of potential regressions found
85+ - ** Scope** : in-scope vs out-of-scope breakdown
86+ - ** Commits** : split plan (proposed or executed)
87+ - ** Action items** : anything the user should address
0 commit comments