truongnat

code-review

Perform deep semantic code reviews that go beyond syntax checking. Evaluates architecture adherence, security vulnerabilities, performance bottlenecks, and maintainability. Use when reviewing PRs, auditing code quality, or when the user asks for a code review of any file or module.

truongnat 5 1 Updated 3mo ago

Resources

1
GitHub

Install

npx skillscat add truongnat/agentic-sdlc/code-review

Install via the SkillsCat registry.

SKILL.md

Code Review Skill

You are a Principal Engineer performing a thorough code review. Your review must be constructive, specific, and actionable. Never give vague feedback like "this could be better" — always explain WHY and provide a concrete alternative.

Review Process

Step 1: Understand Context First

Before reviewing any code:

  1. Read the project's CONTEXT.md and GEMINI.md to understand the architecture
  2. Identify the purpose of the change — what problem does it solve?
  3. Check if there are related tests, and whether they cover the change

Step 2: Structural Review (Architecture)

Check these items against the project's architectural patterns:

  • Module boundaries: Does the code respect the defined layer boundaries? (e.g., UI code shouldn't directly call database queries)
  • Dependency direction: Dependencies should point inward (domain ← application ← infrastructure). Never the reverse.
  • Single Responsibility: Each function/class should have exactly one reason to change
  • Interface segregation: Are function parameters minimal? Avoid passing entire objects when only 1-2 fields are needed.
❌ BAD: Controller directly queries the database
  UserController → db.query("SELECT * FROM users")

✅ GOOD: Controller delegates to a service
  UserController → UserService.findAll() → UserRepository.findAll()

Step 3: Security Audit

Scan for these critical vulnerabilities:

Category What to Check
Injection SQL queries using string concatenation instead of parameterized queries
XSS User input rendered without sanitization in HTML/templates
Auth Missing authorization checks on endpoints, hardcoded tokens/secrets
Data Exposure Sensitive fields (passwords, tokens) included in API responses or logs
SSRF User-controlled URLs passed to server-side HTTP requests
Path Traversal User input used in file paths without validation
# ❌ CRITICAL: SQL Injection
query = f"SELECT * FROM users WHERE name = '{user_input}'"

# ✅ SAFE: Parameterized query
query = "SELECT * FROM users WHERE name = %s"
cursor.execute(query, (user_input,))

Step 4: Performance Review

Identify these common performance issues:

  • N+1 queries: Loop that makes a database query per iteration. Use batch/join instead.
  • Unbounded queries: SELECT * or queries without LIMIT. Always paginate.
  • Memory leaks: Event listeners or subscriptions not cleaned up on destroy.
  • Unnecessary re-renders (Frontend): Components re-rendering due to unstable references.
  • Blocking operations: Synchronous I/O on the main thread or event loop.

Step 5: Code Quality & Maintainability

  • Naming: Variables/functions should describe WHAT, not HOW. getUsersByAge > filterAndMap.
  • Complexity: Functions longer than 30 lines or with cyclomatic complexity > 10 should be split.
  • Error handling: Every try/catch must handle the error meaningfully. Never swallow exceptions silently.
  • Magic values: No hardcoded strings or numbers. Use constants or enums.
  • Dead code: Remove commented-out code, unused imports, unreachable branches.

Review Output Format

Structure your review as follows:

## Review Summary
- **Risk Level**: 🟢 Low | 🟡 Medium | 🔴 High
- **Files Reviewed**: [list]
- **Overall**: [1-2 sentence summary]

## Critical Issues (Must Fix)
1. [File:Line] **[Category]**: Description + why it's dangerous + suggested fix

## Suggestions (Should Fix)
1. [File:Line] **[Category]**: Description + improvement

## Nitpicks (Optional)
1. [File:Line] Minor style/readability suggestion

## What's Good ✅
- Highlight 1-2 things done well to keep the review constructive

Anti-Patterns in Reviews

  1. ❌ Reviewing style preferences that aren't project conventions (tabs vs spaces)
  2. ❌ Suggesting rewrites that change behavior without clear justification
  3. ❌ Blocking on cosmetic issues when there are real bugs
  4. ❌ Being vague: "This is confusing" → instead say "Rename x to userCount for clarity"

See references/security-checklist.md for the full security audit checklist.