--- name: code-review-checklist description: Systematic code review — correctness, security, performance, readability, test coverage. Use when reviewing pull requests or providing structured feedback on others' code. license: MIT --- ## What I do Conduct thorough code reviews using this checklist. Help authors improve while being constructive. ## Review Checklist ### Correctness - [ ] Does the code do what it's supposed to? - [ ] Edge cases handled? - [ ] Errors handled properly? - [ ] Null/undefined issues? - [ ] Boundary conditions correct? ### Logic - [ ] Logic sound? - [ ] Off-by-one errors? - [ ] Conditions correct (>, >=, <, <=)? - [ ] Algorithm makes sense? - [ ] Race conditions? ### Security - [ ] User input validated? - [ ] Secrets handled properly? - [ ] Output escaped? - [ ] Queries parameterized? - [ ] Files validated? ### Performance - [ ] Unnecessary loops? - [ ] Repeated computation? - [ ] Large data structures efficient? - [ ] DB queries optimized? - [ ] Memory leakage? ### Non-Pessimization (see /efficient-code skill) - [ ] Are there unnecessary copies of data? - [ ] Is data being converted between representations unnecessarily? - [ ] Can hot paths avoid allocations? - [ ] Is slow code isolated behind caches? - [ ] Is "optimization" actually measured or just assumed? ### Readability - [ ] Code self-documenting? - [ ] Names clear? - [ ] Unnecessary complexity? - [ ] Functions focused? - [ ] Consistent with codebase? ### Maintainability - [ ] DRY? - [ ] Code smells? - [ ] Testable? - [ ] Minimal dependencies? - [ ] Appropriate abstraction? ### Testing - [ ] Adequate tests? - [ ] Edge cases covered? - [ ] Tests independent? - [ ] AAA pattern? - [ ] Descriptive names? ### Documentation - [ ] Complex parts documented? - [ ] Public API documented? - [ ] Tricky parts explained? - [ ] README updated? ### Style - [ ] Follows conventions? - [ ] Formatting consistent? - [ ] No lint errors? - [ ] No debug code left? --- ## Review Categories ### Functional - Solves the problem? - Requirements met? - Edge cases, error paths? ### Architectural - Design appropriate? - Components separated? - Proper abstraction? - Dependencies reasonable? ### Security - Input validation - Authentication/Authorization - Secrets management - Injection prevention ### Performance - Algorithm complexity - Database queries - Memory usage - Network calls - Non-pessimization (see /efficient-code skill) --- ## Giving Feedback ### Be Constructive - Instead of "This is wrong": "Consider..." - Instead of "This is bad": "This might cause..." - Instead of "You should": "What about..." - Instead of "I would": "One approach could be..." ### Be Specific ``` ❌ "This code is confusing." ✅ "The `processUserData` function is 80 lines. Consider extracting validation into a separate `validateUserData` function." ``` ### Suggest Alternatives ``` ❌ "This loop is inefficient." ✅ "This O(n²) loop could become O(n) using a Map: const byId = new Map(users.map(u => [u.id, u])); const user = byId.get(userId); " ``` --- ## Types of Comments - 🔴 Must Fix: "This causes a crash when userId is null" - 🟠 Should Fix: "Consider adding input validation" - 🟡 Optional: "This could use optional chaining" - ❓ Question: "Why this approach? Curious about tradeoffs" - 🔵 Nitpick: "Minor style preference" --- ## Review Process ### 1. Preflight Before diving deep, run quick checks to catch obvious issues: - **Lint**: Run project's linter (detect language, try `npm run lint`, `cargo clippy`, `ruff check`, etc.) - **Format**: Run formatter if changes are substantial (`npm run format`, `cargo fmt`, etc.) - **Tests**: Run relevant tests if changes are significant - **Typecheck**: Run type checker if available (`npm run typecheck`, `cargo check`, etc.) If any preflight checks fail, report them first—they may mask deeper issues. ### 2. Understand - Read PR description, linked issues, context - Understand what the code is trying to accomplish - Check if there's a corresponding issue or RFC --- ## Self-Review Before Submitting - [ ] Preflight checks passed (lint, format, typecheck)? - [ ] Tested locally? - [ ] No console.logs/debug code? - [ ] Edge cases checked? - [ ] Commit messages clear? - [ ] Documentation updated? --- Use this checklist for thorough, constructive code reviews.