--- name: code-review-and-quality description: Use when conducting comprehensive code reviews on pull requests, diffs, or newly implemented features to ensure architectural cleanliness, maintainability, performance, and best engineering practices. --- # Code Review & Software Quality Assurance ## Purpose Deliver senior-level code reviews that identify architectural debt, hidden regressions, performance bottlenecks, maintainability issues, and missing test coverage before merging. ## Review Dimensions ### 1. Architectural Alignment & Design - Does the change fit into the existing system architecture, or introduce conflicting abstractions? - Is there duplicate functionality that can be eliminated by reusing maintained libraries or existing codebase helpers? - Are boundaries and contracts between modules explicit and clean? ### 2. Correctness & Edge Cases - Are asynchronous operations, cancellations, and promise chains handled defensively (no unhandled rejections, race conditions, or leaking timers)? - How are empty inputs, `null`/`undefined`, zero-length collections, and large datasets handled? - Are error states surfaced with structured diagnostics instead of swallowed silently? ### 3. Maintainability & Code Hygiene - Are functions small, focused on a single responsibility, and easy to test? - Are types strict (no unwarranted `any`, `@ts-ignore`, or loose type assertions)? - Are names descriptive and self-documenting? ### 4. Performance & Efficiency - Are database queries, network calls, or expensive computations avoided inside loops (N+1 queries)? - Is memory allocated efficiently (no memory leaks from long-lived event listeners or unbounded caches)? ## Feedback Guidelines - Classify comments by importance: `[BLOCKER]`, `[IMPORTANT]`, `[NITPICK]`, `[QUESTION]`, or `[PRAISE]`. - Always provide actionable suggestions or code snippets showing the recommended improvement.