--- name: dev-review description: Code review with focus on quality, security, and best practices version: 1.4.1 --- # /dev-review - Code Review > **Skill Awareness**: See `skills/_registry.md` for all available skills. > - **Before**: After `/dev-coding` implementation and `/dev-test` passes > - **Reads**: `_quality-attributes.md` (ALL Levels - verification) > - **If issues**: Fix with `/dev-coding`, then review again > - **If major changes**: Create CR via `/debrief` Review code changes for quality, security, and adherence to standards. ## When to Use - After implementing a feature - Before merging a PR - To get feedback on approach - To catch issues before production ## Usage ``` /dev-review # Review uncommitted changes /dev-review --staged # Review staged changes only /dev-review src/auth/ # Review specific directory /dev-review UC-AUTH-001 # Review changes for specific UC ``` ## Input Reviews can be based on: 1. **Git diff** - Uncommitted or staged changes 2. **File list** - Specific files to review 3. **UC reference** - Files changed for a use case (from spec) ## Output ```markdown ## Review Summary **Verdict**: ✅ Approve | ⚠️ Request Changes | ❓ Needs Discussion **Stats**: X files, Y additions, Z deletions ### Issues Found #### 🔴 Critical (must fix) - [security] SQL injection risk in `src/api/users.ts:45` - [bug] Null pointer in `src/utils/parse.ts:23` #### 🟡 Important (should fix) - [performance] N+1 query in `src/api/posts.ts:67` - [error-handling] Unhandled promise rejection #### 🔵 Suggestions (nice to have) - [style] Consider extracting to helper function - [naming] `data` is too generic, suggest `userProfile` ### By File - `src/api/auth.ts` - 2 issues - `src/components/Form.tsx` - 1 suggestion ### Positives - Good error handling in login flow - Clean separation of concerns ``` ## Expected Outcome Review report with verdict and categorized issues. **Report includes:** - Verdict (Approve/Request Changes/Needs Discussion) - Issues found (by severity: critical/important/suggestion) - Issues by file - Positives (acknowledge good work) - Spec compliance (if UC provided) ## Review Workflow **1. Load Context (once):** - Read `plans/brd/tech-context.md` → Identify stack(s) - Load `knowledge/stacks/{stack}/_index.md` → Focus on "For /dev-review" section - Read `_quality-attributes.md` → Get all level checklists - Read spec (if UC provided) → Get requirements - Get git diff or file list → Understand what changed **2. Analyze Changes:** - Review each changed file - Apply: Security + Quality + Conventions + Stack-Specific checks - Note issues by severity (critical/important/suggestion) - Acknowledge good practices **3. Verify Spec Compliance (if UC provided):** - Check all requirements met - Identify missing items - Flag unauthorized additions **4. Generate Report:** - Verdict (Approve/Request Changes/Needs Discussion) - Issues by severity - Issues by file - Spec compliance status - Positives **5. Offer Fix (if issues found):** - Critical/Important → Suggest auto-fix via `/dev-coding` - Suggestions → User decides ## Success Criteria - Stack knowledge loaded and applied - Security risks identified - Quality issues found - Spec compliance verified - Conventions checked - Framework patterns verified (from stack knowledge) - Constructive feedback with suggested fixes - Clear verdict given ## Review Focus Areas ### Security - Input validation (sanitized, injection prevented, XSS prevented) - Authentication (required where needed, tokens validated, sessions secure) - Authorization (permissions checked, data access restricted, admin protected) - Data protection (passwords hashed, sensitive data not logged, no secrets in code) - API security (rate limiting, CORS, no sensitive data in URLs) ### Quality - Error handling (caught, user-friendly messages, logged, not swallowed) - Performance (no N+1 queries, pagination on lists, async heavy ops, no memory leaks) - Maintainability (readable, functions not too long, no magic values, DRY) - Testing (new code tested, edge cases covered, meaningful tests) ### Conventions - Naming (variables, files, components per scout) - Structure (correct location, follows patterns, organized imports) - Style (matches configs, consistent, no linting errors) - Git (proper commit format, no unrelated changes, no debug code) ### Spec Compliance - Requirements met (all implemented) - Requirements not met (missing items) - Not in spec (unauthorized additions) ### Stack-Specific **CRITICAL: Load framework-specific review checklists** After loading stack knowledge (from Context Sources → Step 1), apply framework-specific checks from the "For /dev-review" section: **React projects:** - Hooks follow Rules of Hooks (no conditional calls, correct order) - All dependencies included in useEffect/useCallback/useMemo - No infinite loops, no stale closures - State updates are immutable - Performance optimizations appropriate (memo, lazy) - Lists have stable keys **Vue 3 projects:** - Uses `