💻 Template 3: Code Review/Debug
Dùng cho: Review code, tìm bugs, security audit, refactoring suggestions...
<role>
Senior [Language] Developer với expertise về [framework/domain]
</role>
<context>
[Paste code here - có thể hàng vạn dòng]
</context>
<task>
Review code trên và:
1. Tìm bugs/security issues
2. Đề xuất improvements (performance, readability, maintainability)
3. Refactor nếu cần
</task>
<instructions>
- Thinking level: HIGH
- Quét toàn bộ code systematically
- Mỗi issue phải có: file, line number, severity
- Đưa ra code fix cụ thể (không chỉ lý thuyết)
</instructions>
<constraints>
- Tuân thủ [coding standard: PEP8/Airbnb style...]
- Không thay đổi business logic
- Backward compatible
</constraints>
<output_format>
## Summary
- Total issues: X
- Critical: Y | High: Z | Medium: ...
## Detailed Findings
### Issue #1: [Title] - [Severity]
**Location**: [File:Line]
**Current code**:
`[snippet]`
**Problem**: [Explanation]
**Fixed code**:
`[solution]`
**Impact**: [Why this matters]
</output_format> Ví dụ sử dụng
<role>
Senior Python Developer với expertise về Django và security
</role>
<context>
[Paste toàn bộ Django app code - 5000 dòng]
</context>
<task>
Security audit cho authentication system:
1. Tìm SQL injection, XSS, CSRF vulnerabilities
2. Kiểm tra password handling
3. Review session management
4. Đề xuất improvements
</task>
<instructions>
- Thinking level: HIGH
- Focus vào OWASP Top 10
- Mỗi vulnerability phải có PoC (proof of concept)
</instructions>
<constraints>
- Tuân thủ Django best practices
- Compatible với Django 4.x
- Không break existing tests
</constraints> 🧠 Template 4: Problem Solving với Chain-of-Thought
Dùng cho: Bài toán phức tạp, quyết định chiến lược, thiết kế hệ thống...
<role>
[Expert trong lĩnh vực liên quan]
</role>
<context>
[Background information]
</context>
<problem>
[Mô tả vấn đề cần giải quyết]
</problem>
<instructions>
Sử dụng structured thinking:
**Step 1 - Understand**:
- Restate vấn đề bằng từ ngữ của bạn
- Xác định knowns và unknowns
- Liệt kê assumptions
**Step 2 - Plan**:
- Break down thành sub-problems
- Xác định approach (có thể nhiều cách)
- Chọn approach tối ưu (giải thích tại sao)
**Step 3 - Execute**:
- Giải quyết từng sub-problem
- Show your work (không nhảy bước)
**Step 4 - Verify**:
- Kiểm tra logic
- Edge cases?
- Alternative solutions?
**Step 5 - Reflect**:
- Confidence level?
- Limitations của solution?
- Next steps để improve?
</instructions>
<constraints>
- Thinking level: HIGH
- Phải explain reasoning at each step
- Nếu không chắc, nói rõ và đưa ra assumptions
</constraints> Ví dụ sử dụng
<role>
System Architect với 10 năm kinh nghiệm distributed systems
</role>
<context>
Current system:
- Monolithic Django app
- PostgreSQL database
- 50,000 daily active users
- Average response time: 800ms
- Peak traffic: 3x normal
Pain points:
- Scaling khó khăn khi traffic spike
- Deploy mất 30 phút, downtime 5 phút
- Database bottleneck với read-heavy queries
</context>
<problem>
Thiết kế architecture mới để:
1. Handle 500,000 DAU
2. Response time < 200ms
3. Zero-downtime deployment
4. Cost-effective (budget: $10k/month)
</problem>
<constraints>
- Team hiện tại: 5 developers (2 senior, 3 junior)
- Timeline: 6 tháng migration
- Không thể rewrite toàn bộ từ đầu
</constraints> 💡 Pro tip
Template Problem Solving với 5 Steps cực kỳ mạnh khi kết hợp với Thinking Mode HIGH. Gemini sẽ tự challenge các assumptions và đưa ra solution robust hơn!
📥 Download Templates
Bạn có thể copy tất cả 4 templates từ bài học này và bài trước vào một file để sử dụng nhanh. Gợi ý: Lưu trong Notion hoặc Obsidian với tags để dễ tìm kiếm!
✅ 4 Templates đã học
- Template 1: Content Creation
- Template 2: Data Analysis
- Template 3: Code Review/Debug
- Template 4: Problem Solving (CoT)