Comprehensive code quality and security audit for financial systems. Use when asked to "review code", "code review", "security audit", "check for issues", "審核程式碼", "檢查安全性", or before merging changes. Focuses on DDD compliance, financial precision (no floats for money), security vulnerabilities, and test coverage.
💡 Recommended Agent:
code-reviewer-agent(Senior Code Quality Auditor)
- CLI: Input
/agentand selectcode-reviewer-agent- VS Code: Use
@workspace #code-reviewer-agentin Chat⚠️ CLI Note: Use natural language like "review 我的 code". VS Code users can use
/code-reviewshortcut.
Use this skill when:
Required:
git statusRecommended:
04-plan.md to verify all tasks completed# Check git status
git status
# View staged/unstaged changes
git diff
# Or compare branch
git diff main...feature-branch
Check for Critical Security Issues:
| Issue | How to Detect | Fix |
|---|---|---|
| Secrets in code | Search for API keys, passwords, tokens | Move to environment variables |
| SQL injection | Raw SQL with string concatenation | Use parameterized queries |
| XSS vulnerabilities | Unescaped user input in HTML | Sanitize inputs, escape outputs |
| Auth bypass | Missing authorization checks | Add RBAC/ABAC checks |
| Insecure dependencies | npm audit / pip-audit | Update vulnerable packages |
Financial Systems Specific:
decimal (NOT float/double)DDD Compliance:
SOLID Principles:
Naming Conventions (C#):
IMethodName_Condition_ExpectedResult# Run tests with coverage
npm test -- --coverage
# Or
dotnet test /p:CollectCoverage=true
Coverage Requirements:
Test Quality:
Create changes/<YYYY-MM-DD>-<slug>/05-review.md:
Template:
# Code Review: {Feature Name}
**Date**: {YYYY-MM-DD}
**Reviewer**: {Name or "AI Agent"}
**Status**: 🔴 Needs Work / 🟡 Minor Issues / 🟢 Approved
---
## Summary
{Brief overview of changes and overall assessment}
**Files Changed**: {X files}
**Lines Added**: {+Y}
**Lines Removed**: {-Z}
---
## Critical Issues 🔴 (Must Fix Before Merge)
### Issue 1: {Title}
**Severity**: Critical
**File**: `{path/to/file.ts}:{line}`
**Problem**: {Description of the issue}
**Risk**: {What could go wrong}
**Fix**: {How to resolve}
**Code**:
```typescript
// ❌ BAD
double price = 19.99; // Floating point for money
Recommended:
// ✅ GOOD
decimal price = 19.99M; // Decimal for money
{Repeat structure}
Severity: High
File: {path/to/file.ts}:{line}
Problem: {Description}
Fix: {Solution}
Severity: Medium
File: {path/to/file.ts}:{line}
Problem: {Description}
Fix: {Solution}
decimal or integer minor unitsOverall Coverage: {X%}
| Module | Coverage | Status |
|---|---|---|
lib/transactions.ts | 95% | ✅ Pass |
api/v1/transactions | 82% | ✅ Pass |
lib/notifications.ts | 75% | ⚠️ Below 80% |
Missing Coverage:
File: {path}:{line}
Problem: {Description}
Impact: {Performance degradation}
Fix: {Use join or eager loading}
⚠️ API Breaking Change Detected
Endpoint: POST /api/v1/users
Change: Response schema adds notificationPreferences field
Impact: External clients with strict schema validation may break
Recommendation:
/api/v2/usersReviewer Decision: {Choose one}
Next Steps:
03-spec.md04-plan.md05-test-plan.md (if exists)feature/{branch-name}
---
## Review Checklist Template
Use this checklist during review:
```markdown
## Code Review Checklist
### Security ✅
- [ ] No secrets/credentials in code
- [ ] SQL injection prevented
- [ ] XSS prevented (input sanitization)
- [ ] Authorization checks present
- [ ] Dependencies secure (npm audit / pip-audit)
### Financial Precision ✅
- [ ] Money uses decimal (NOT float/double)
- [ ] Currency stored explicitly
- [ ] Idempotency for transactions
- [ ] Audit logging present
- [ ] Timezone handling correct (UTC storage)
### Code Quality ✅
- [ ] DDD: Domain logic in domain layer
- [ ] SOLID principles followed
- [ ] Clear naming conventions
- [ ] No code duplication (DRY)
- [ ] Error handling complete
### Testing ✅
- [ ] Test coverage ≥80%
- [ ] Edge cases tested
- [ ] Integration tests for critical paths
- [ ] Tests verify behavior (not implementation)
### Performance ✅
- [ ] No N+1 query problems
- [ ] Database indexes appropriate
- [ ] Caching where beneficial
- [ ] No memory leaks
### Breaking Changes ✅
- [ ] API changes documented
- [ ] Migration guide provided (if needed)
- [ ] Deprecation warnings added
- [ ] Versioning strategy followed
// ❌ BAD
double totalPrice = orderItems.Sum(x => x.Price * x.Quantity);
// ✅ GOOD
decimal totalPrice = orderItems.Sum(x => x.Price * x.Quantity);
// ❌ BAD
[HttpPost("transactions")]
public async Task<IActionResult> CreateTransaction([FromBody] TransactionDto dto)
{
var transaction = await _service.CreateAsync(dto);
return Ok(transaction);
}
// ✅ GOOD
[HttpPost("transactions")]
public async Task<IActionResult> CreateTransaction(
[FromBody] TransactionDto dto,
[FromHeader(Name = "Idempotency-Key")] string idempotencyKey)
{
if (string.IsNullOrEmpty(idempotencyKey))
return BadRequest("Idempotency-Key required");
var transaction = await _service.CreateOrGetAsync(dto, idempotencyKey);
return Ok(transaction);
}
// ❌ BAD (Anemic)
public class Order
{
public decimal Total { get; set; }
public OrderStatus Status { get; set; }
}
// Service does all the logic
public class OrderService
{
public void CompleteOrder(Order order)
{
order.Status = OrderStatus.Completed;
order.Total = CalculateTotal(order);
}
}
// ✅ GOOD (Rich domain model)
public class Order
{
public decimal Total { get; private set; }
public OrderStatus Status { get; private set; }
public void Complete()
{
if (Status == OrderStatus.Cancelled)
throw new InvalidOperationException("Cannot complete cancelled order");
Status = OrderStatus.Completed;
Total = CalculateTotalInternal();
}
private decimal CalculateTotalInternal() { /* domain logic */ }
}
After review completion:
If issues found:
Fix critical issues → Re-run tests → Request re-review
If approved:
CLI:
Input: "archive 這個 change package"
[System loads work-archiving skill]
→ Generate 99-archive.md and WORK_LOG entry
VS Code:
Input: /archive
Or: "finalize and archive"
Or use workflow orchestrator:
Input: "what's next?"
[System detects review complete, recommends archive stage]
Solution: Fix critical (🔴) first, then high (🟡). Medium (🟢) can be separate PR.
Solution:
Solution: Focus on:
💡 Tip: A good review finds issues before they reach production. Be thorough but pragmatic—perfection is the enemy of shipping.