Skip to content

Commit d6622ed

Browse files
syntax fix of AI_CODE_REVIEW_PROMPT.md
1 parent 794a83d commit d6622ed

File tree

1 file changed

+311
-0
lines changed

1 file changed

+311
-0
lines changed

docs/ai/AI_CODE_REVIEW_PROMPT.md

Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
# 📘 AI Code Review Prompt & Repository Export Guide
2+
3+
This document provides a **standardized workflow** for having AI tools such as **ChatGPT, Claude, and Gemini**
4+
review a code repository accurately and thoroughly.
5+
6+
It includes:
7+
8+
- How to export a repo so AI can read it
9+
10+
- A universal prompt that works across AI models
11+
12+
- A structured review framework
13+
14+
- Best practices for infra / automation projects
15+
16+
* * * * *
17+
18+
## ✅ STEP 1: Export the Repository for AI Review
19+
20+
AI models **cannot read GitHub links directly**.\
21+
You must provide the code explicitly.
22+
23+
* * * * *
24+
25+
## 🔹 Option A --- Recommended: ZIP the Repository
26+
27+
From inside your repo:
28+
29+
`git archive --format=zip -o repo-review.zip HEAD`
30+
31+
Then upload:
32+
33+
`repo-review.zip`
34+
35+
This works reliably with:
36+
37+
- ChatGPT
38+
39+
- Claude
40+
41+
- Gemini
42+
43+
* * * * *
44+
45+
## 🔹 Option B --- Create a Single Review File (Best for Large Repos)
46+
47+
Use this script to generate a consolidated review bundle:
48+
49+
`#!/usr/bin/env bash
50+
set -euo pipefail
51+
52+
OUT="AI_REVIEW_BUNDLE.txt"
53+
: > "$OUT"
54+
55+
echo "## REPOSITORY TREE" >> "$OUT"
56+
git ls-files | sed 's/^/- /' >> "$OUT"
57+
echo >> "$OUT"
58+
59+
FILES=(
60+
"README.md"
61+
"QUICKSTART.md"
62+
".env.example"
63+
"scripts"
64+
)
65+
66+
for f in "${FILES[@]}"; do
67+
if [[ -e "$f" ]]; then
68+
echo "## FILE: $f" >> "$OUT"
69+
echo '```' >> "$OUT"
70+
if [[ -d "$f" ]]; then
71+
find "$f" -type f -exec sed -n '1,400p' {} \;
72+
else
73+
sed -n '1,400p' "$f"
74+
fi
75+
echo '```' >> "$OUT"
76+
echo >> "$OUT"
77+
fi
78+
done
79+
80+
echo "Review bundle created: $OUT"`
81+
82+
Upload:
83+
84+
`AI_REVIEW_BUNDLE.txt`
85+
86+
* * * * *
87+
88+
## ✅ STEP 2: AI REVIEW PROMPT (COPY & PASTE)
89+
90+
Paste **everything below** into ChatGPT, Claude, or Gemini after uploading the repo or bundle.
91+
92+
* * * * *
93+
94+
## 🔍 AI Code Review Request
95+
96+
You are reviewing a software repository provided as an uploaded archive or pasted content.
97+
98+
### 🎯 Objectives
99+
100+
Perform a **deep technical review** focused on:
101+
102+
- Correctness
103+
104+
- Security
105+
106+
- Idempotency
107+
108+
- Maintainability
109+
110+
- Documentation quality
111+
112+
- Production readiness
113+
114+
This repository is used for:
115+
116+
- Infrastructure automation
117+
118+
- Containerized deployments
119+
120+
- System-level configuration
121+
122+
- Long-running services
123+
124+
* * * * *
125+
126+
### 🧠 Tasks
127+
128+
#### 1️⃣ Code Structure Review
129+
130+
- Explain the purpose of each major file
131+
132+
- Identify duplication or unnecessary complexity
133+
134+
- Highlight unclear or fragile logic
135+
136+
#### 2️⃣ Shell / Script Quality
137+
138+
- Identify unsafe shell practices
139+
140+
- Check quoting and variable handling
141+
142+
- Review error handling and exit behavior
143+
144+
- Flag missing `set -euo pipefail`, traps, or logging
145+
146+
- Identify brittle command usage
147+
148+
#### 3️⃣ Idempotency Review (**Critical**)
149+
150+
For each of the following, determine whether re-running is safe:
151+
152+
- File creation
153+
154+
- Container creation
155+
156+
- Firewall rules
157+
158+
- Users
159+
160+
- Certificates
161+
162+
- Volumes
163+
164+
- Services
165+
166+
Answer:
167+
168+
- Is it safe to re-run?
169+
170+
- Does it detect existing state?
171+
172+
- Can it cause duplication or corruption?
173+
174+
#### 4️⃣ Security Review
175+
176+
Evaluate:
177+
178+
- Secret handling
179+
180+
- Environment variable usage
181+
182+
- File permissions
183+
184+
- TLS behavior
185+
186+
- Firewall exposure
187+
188+
- Privilege level (root vs rootless)
189+
190+
- SELinux considerations (if applicable)
191+
192+
#### 5️⃣ Container & Deployment Review
193+
194+
- Environment variable propagation
195+
196+
- Volume mounting
197+
198+
- Startup order
199+
200+
- Health checks
201+
202+
- Restart behavior
203+
204+
- Failure recovery
205+
206+
#### 6️⃣ Documentation Review
207+
208+
- Accuracy of README
209+
210+
- Redundant or outdated sections
211+
212+
- Missing explanations
213+
214+
- What should move to `docs/`
215+
216+
- What should be simplified
217+
218+
#### 7️⃣ Improvements & Refactors
219+
220+
For each issue:
221+
222+
- Explain the problem
223+
224+
- Suggest a fix
225+
226+
- Provide example code or diffs where appropriate
227+
228+
* * * * *
229+
230+
### 📤 Required Output Format
231+
232+
Please respond using the following structure:
233+
234+
```text
235+
## Summary
236+
237+
## Critical Issues
238+
239+
## Medium Priority Issues
240+
241+
## Minor Improvements
242+
243+
## Security Review
244+
245+
## Idempotency Review
246+
247+
## Documentation Feedback
248+
249+
## Suggested Refactors
250+
251+
## Final Recommendations
252+
```
253+
254+
* * * * *
255+
256+
## ✅ STEP 3: Recommended Workflow
257+
258+
1. Export repo (`zip` or `bundle`)
259+
260+
2. Upload to AI
261+
262+
3. Run this prompt
263+
264+
4. Apply fixes in Cursor
265+
266+
5. Re-run review
267+
268+
6. Finalize documentation
269+
270+
* * * * *
271+
272+
## 🧠 Best Tool Pairing
273+
274+
| Tool | Best Use |
275+
| --- | --- |
276+
| Claude | Architecture & reasoning |
277+
| ChatGPT | Refactoring & explanations |
278+
| Gemini | Code smell detection |
279+
| Cursor | Implementing fixes |
280+
281+
* * * * *
282+
283+
## ⚠️ Important Notes
284+
285+
- AI **cannot** browse GitHub
286+
287+
- Links alone are insufficient
288+
289+
- Files must be uploaded or pasted
290+
291+
- ZIP files work best
292+
293+
- Large repos should use the bundle method
294+
295+
* * * * *
296+
297+
## ✅ Optional Enhancements
298+
299+
If desired, this template can be adapted for:
300+
301+
- 🔐 Security audits
302+
303+
- 🧪 CI/CD validation
304+
305+
- 🧱 Infrastructure-as-Code review
306+
307+
- 📦 Container hardening
308+
309+
- 📚 Documentation audits
310+
311+
* * * * *

0 commit comments

Comments
 (0)