Skip to content

Commit 60cee23

Browse files
committed
Refactor code review prompt for improved execution steps and clarity
1 parent eb71123 commit 60cee23

1 file changed

Lines changed: 91 additions & 33 deletions

File tree

.github/prompts/code-review-local-changes.prompt.md

Lines changed: 91 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,55 @@ description: "Code Review Prompt for Terraform AzureRM Provider Local Changes"
3737
## **START HERE - MANDATORY EXECUTION STEPS**
3838

3939
**1. GET THE DIFF - Run git commands to find changes:**
40-
```powershell
41-
# STEP 1: Get file summary FIRST (to count all changed files)
42-
git --no-pager diff --stat --no-prefix
4340

44-
# STEP 2: Get detailed changes for review
45-
git --no-pager diff --no-prefix --unified=3
41+
**Use the `run_in_terminal` tool with these exact patterns:**
4642

47-
# FALLBACK: If no unstaged changes, check staged changes
48-
git --no-pager diff --stat --no-prefix --staged
49-
git --no-pager diff --no-prefix --unified=3 --staged
43+
```
44+
# STEP 1: Check git status for overall state (including untracked files)
45+
run_in_terminal:
46+
command: "git status --porcelain"
47+
explanation: "Check git status for overall state including untracked files"
48+
isBackground: false
49+
50+
# STEP 2: Get file summary for tracked files (to count changed files)
51+
run_in_terminal:
52+
command: "git --no-pager diff --stat --no-prefix"
53+
explanation: "Get file summary for tracked files to count changed files"
54+
isBackground: false
55+
56+
# STEP 3: Get detailed changes for tracked files
57+
run_in_terminal:
58+
command: "git --no-pager diff --no-prefix --unified=3"
59+
explanation: "Get detailed changes for tracked files"
60+
isBackground: false
61+
62+
# STEP 4: Check staged changes ONLY if no unstaged changes found in STEP 3
63+
run_in_terminal:
64+
command: "git --no-pager diff --stat --no-prefix --staged"
65+
explanation: "Check staged file summary ONLY if no unstaged changes found"
66+
isBackground: false
67+
68+
run_in_terminal:
69+
command: "git --no-pager diff --no-prefix --unified=3 --staged"
70+
explanation: "Get detailed staged changes ONLY if no unstaged changes found"
71+
isBackground: false
72+
73+
# STEP 5: Get current branch name
74+
run_in_terminal:
75+
command: "git branch --show-current"
76+
explanation: "Get current branch name"
77+
isBackground: false
78+
79+
# STEP 6: Handle untracked files (new files not in git yet)
80+
# If git status shows untracked files, examine them individually using read_file tool
5081
```
5182

52-
**⚠️ IMPORTANT**: If BOTH the stat and diff commands show no changes, abandon the code review and display:
53-
**"☠️ **Argh! There be no changes here!** ☠️"**
83+
**⚠️ IMPORTANT**:
84+
- If git status shows NO changes (tracked, staged, or untracked), abandon review and display: **"☠️ **Argh! There be no changes here!** ☠️"**
85+
- If ONLY untracked files exist, review them as new file additions
86+
- Untracked files are often the most critical changes to review (new features, scripts, etc.)
87+
- **TOOL USAGE**: Always use the `run_in_terminal` tool with all three required parameters: `command`, `explanation`, and `isBackground`
88+
- **EFFICIENCY RULE**: Never repeat the same git command - trust your initial results and move forward decisively
5489

5590
**📋 FOR LARGE MULTI-FILE CHANGES**: If the combined diff is too large or complex, examine each file individually using:
5691
```powershell
@@ -61,21 +96,35 @@ git --no-pager diff --no-prefix filename2
6196

6297
**2. RECURSION PREVENTION CHECK** - Applied automatically (see top of file)
6398

64-
**🚨 CRITICAL ACCURACY REQUIREMENT**:
99+
**🎯 EXECUTION EFFICIENCY RULE**:
100+
- **NEVER repeat git commands** - Each command should only be run ONCE during the review
101+
- **Trust initial results** - Don't second-guess or re-verify git output
102+
- **Efficient sequence**: status → stat → diff → branch → examine untracked files (if any)
103+
- **Avoid redundancy**: If you already have the diff, don't run it again
104+
- **Move forward decisively** with the information gathered from the first execution of each command
105+
106+
**🚨 CRITICAL ACCURACY REQUIREMENT**:
65107
The git stat output MUST be parsed correctly to count new/modified/deleted files accurately. Misclassifying deleted files as modified files is a critical error that undermines review credibility.
66108

67109
## 📝 **REVIEW OUTPUT FORMAT**
68110

69111
**Use this EXACT format for the review output:**
70112

71-
**3. ANALYZE THE FILE CHANGES** - Parse the git stat output to get accurate file counts
72-
- Count ALL files from the git stat command output
73-
- **CRITICAL**: Files showing only `------------------` (all minus signs) are DELETED files
74-
- **CRITICAL**: Files showing only `++++++++++++++++++` (all plus signs) are NEW files
75-
- **CRITICAL**: Files showing both `+` and `-` are MODIFIED files
76-
- **EXAMPLE**: `file.md | 505 -----------------` = DELETED file (1 deleted file)
77-
- **EXAMPLE**: `file.go | 25 +++++++++++++++++++++++++` = NEW file (1 new file)
78-
- **EXAMPLE**: `file.go | 10 +++++++---` = MODIFIED file (1 modified file)
113+
**3. ANALYZE THE FILE CHANGES** - Parse git status and diff output to get accurate file counts
114+
- Parse `git status --porcelain` for complete change overview:
115+
- `??` prefix = Untracked files (NEW files not in git)
116+
- `M ` prefix = Modified files (tracked and changed)
117+
- `A ` prefix = Added files (staged new files)
118+
- `D ` prefix = Deleted files (staged deletions)
119+
- `MM` prefix = Modified file with both staged and unstaged changes
120+
- Parse `git --no-pager diff --stat` for tracked file changes:
121+
- **CRITICAL**: Files showing only `------------------` (all minus signs) are DELETED files
122+
- **CRITICAL**: Files showing only `++++++++++++++++++` (all plus signs) are NEW tracked files
123+
- **CRITICAL**: Files showing both `+` and `-` are MODIFIED files
124+
- **EXAMPLE git status**: `?? file.go` = UNTRACKED file (1 new untracked file)
125+
- **EXAMPLE git stat**: `file.md | 505 -----------------` = DELETED file (1 deleted file)
126+
- **EXAMPLE git stat**: `file.go | 25 +++++++++++++++++++++++++` = NEW tracked file (1 new file)
127+
- **EXAMPLE git stat**: `file.go | 10 +++++++---` = MODIFIED file (1 modified file)
79128
- Use this accurate classification in the CHANGE SUMMARY section
80129

81130
**4. REVIEW THE CHANGES** - Apply expertise as principal Terraform provider engineer
@@ -152,14 +201,14 @@ As a principal Terraform provider engineer with expertise in Go development, Azu
152201

153202
**Before flagging ANY formatting/encoding issues:**
154203
1. **STOP** - Do not immediately flag suspicious formatting
155-
2. **VERIFY FIRST** - Use read_file to check actual content
204+
2. **VERIFY FIRST** - Use read_file to check actual content
156205
3. **ASSESS** - Console wrapping vs genuine issue
157206
4. **RESPOND** - Only flag if genuinely broken after verification
158207

159208
**Zero Tolerance for False Positives**: False positive encoding/formatting flags are review failures that erode trust.
160209

161210
**Additional scope for local changes:**
162-
- Spelling and grammar in visible text content
211+
- Spelling and grammar in visible text content
163212
- Command syntax accuracy and consistency
164213
- Professional standards in user-facing content
165214
- Context quality in surrounding diff lines
@@ -172,10 +221,10 @@ As a principal Terraform provider engineer with expertise in Go development, Azu
172221
# 📋 **Code Review**: ${change_description}
173222

174223
## 🔄 **CHANGE SUMMARY**
175-
- **Files Changed**: [number] files ([additions] new file(s), [modifications] modified file(s), [deletions] deleted file(s))
176-
- **Line Changes**: [insertions] insertions, [deletions] deletions
224+
- **Files Changed**: [number] files ([tracked_additions] new tracked, [untracked_files] untracked, [modifications] modified, [deletions] deleted)
225+
- **Line Changes**: [insertions] insertions, [deletions] deletions (tracked files only)
177226
- **Branch**: [current_branch_from_git_command]
178-
- **Type**: [local changes/staged changes]
227+
- **Type**: [local changes/staged changes/untracked files]
179228
- **Scope**: [Brief description of overall scope]
180229

181230
## 📁 **FILES CHANGED**
@@ -184,8 +233,12 @@ As a principal Terraform provider engineer with expertise in Go development, Azu
184233
- `path/to/modified/file1.go` (+X/-Y lines)
185234
- `path/to/modified/file2.md` (+X/-Y lines)
186235

187-
**Added Files:**
188-
- `path/to/new/file.go` (+X lines)
236+
**Added Files (Tracked):**
237+
- `path/to/new/tracked/file.go` (+X lines)
238+
239+
**Untracked Files (New):**
240+
- `path/to/untracked/file1.ps1` (new file, untracked)
241+
- `path/to/untracked/file2.md` (new file, untracked)
189242

190243
**Deleted Files:**
191244
- `path/to/removed/file.go` (-X lines)
@@ -199,6 +252,11 @@ As a principal Terraform provider engineer with expertise in Go development, Azu
199252
### 🔄 **RECURSION PREVENTION**
200253
- **File Skipped**: `.github/prompts/code-review-local-changes.prompt.md` - Cannot review code review prompt itself to prevent infinite loops
201254

255+
### 🔍 **STANDARDS CHECK**
256+
- **PowerShell**: Approved verbs (`Get-`, `Set-`, `New-`, `Test-`), PascalCase
257+
- **Go**: HashiCorp patterns, error handling, naming conventions
258+
- **Terraform**: Resource patterns, schema validation, documentation
259+
202260
### 🟢 **STRENGTHS**
203261
[List positive aspects and well-implemented features]
204262

@@ -228,7 +286,7 @@ As a principal Terraform provider engineer with expertise in Go development, Azu
228286
* **File**: ${relative/path/to/file}
229287
* **Details**: Clear explanation
230288
* **Azure Context** (if applicable): Service behavior reference
231-
* **Terraform Impact** (if applicable): Configuration/state effects
289+
* **Terraform Impact** (if applicable): Configuration/state effects
232290
* **Suggested Change** (if applicable): Code snippet
233291
```
234292

@@ -237,7 +295,7 @@ As a principal Terraform provider engineer with expertise in Go development, Azu
237295
**Review Type Emojis:**
238296
* 🔧 Change request - Issues requiring fixes before commit
239297
* ❓ Question - Clarification needed about approach
240-
* ⛏️ Nitpick - Minor style/consistency improvements
298+
* ⛏️ Nitpick - Minor style/consistency improvements
241299
* ♻️ Refactor - Structural improvements to consider
242300
* 🤔 Thought - Design concerns for discussion
243301
* 🚀 Positive - Well-implemented features worth noting
@@ -250,7 +308,7 @@ As a principal Terraform provider engineer with expertise in Go development, Azu
250308

251309
**In the provided git diff output:**
252310
- **Lines starting with `+`**: Added lines (new code)
253-
- **Lines starting with `-`**: Removed lines (deleted code)
311+
- **Lines starting with `-`**: Removed lines (deleted code)
254312
- **Lines starting with ` `** (space): Unchanged lines (context)
255313
- **Lines starting with `@@`**: Hunk headers showing line numbers and context
256314
- **Git stat symbols**:
@@ -271,7 +329,7 @@ file3.go | 15 +++++++++++++++ # NEW FILE
271329

272330
**Local changes review emphasizes:**
273331
- **Iterative feedback** for work-in-progress code
274-
- **Development guidance** before commit readiness
332+
- **Development guidance** before commit readiness
275333
- **Verification protocols** to prevent false positives from console display issues
276334
- **Comprehensive scope** including spelling/grammar in visible content
277335
- **Next steps clarity** for continued development
@@ -308,7 +366,7 @@ file3.go | 15 +++++++++++++++ # NEW FILE
308366

309367
### **GOLDEN RULE**: If actual file content is valid → acknowledge console wrapping → do NOT flag as corruption
310368

311-
**🚫 COMMON REVIEW FAILURE**:
369+
**🚫 COMMON REVIEW FAILURE**:
312370
Flagging console display artifacts as "Critical: Encoding Issue" when actual file content is clean. This exact scenario wastes developer time and erodes review credibility.
313371

314372
**✅ CORRECT APPROACH**:
@@ -320,13 +378,13 @@ Flagging console display artifacts as "Critical: Encoding Issue" when actual fil
320378

321379
**When to verify:**
322380
- Text breaks mid-word without logical reason
323-
- Missing quotes/brackets that don't make contextual sense
381+
- Missing quotes/brackets that don't make contextual sense
324382
- Emojis appear as `??`
325383
- JSON/YAML looks syntactically broken
326384

327385
**Verification format:**
328386
```markdown
329-
## ℹ️ **Console Display Verification**
387+
## ℹ️ **Console Display Verification**
330388
* **Priority**: ✅
331389
* **Details**: [What appeared wrong in git diff]
332390
* **Verification**: Used read_file to check actual content

0 commit comments

Comments
 (0)