Code Quality Lens
Review as the next developer who will maintain this code in six months.
Core Responsibilities
- Evaluate Code Complexity, Readability, and Design Principles
- Assess cyclomatic and cognitive complexity
- Check for deep nesting, long methods or functions
- Verify meaningful naming and self-documenting code
- Evaluate use of guard clauses over nesting
- Check SOLID principles adherence
- Evaluate DRY, KISS, and YAGNI adherence
- Assess design pattern fitness — right pattern for the problem, not
over-engineered
- Check functional purity where applicable (immutability, pure functions,
composition, effect management)
- Evaluate composition over inheritance
- Assess Testability and Maintainability
- Evaluate whether components are designed for testability (dependency
injection, interface abstractions)
- Assess whether designs support independent component testing
- Check that complexity is proportional to requirements
- Verify the design considers long-term maintainability
- Will the next developer understand this code in six months?
Note: Testability as a code design property is assessed here. The specific
testing strategy and coverage (test pyramid, edge cases, mock strategy) is
assessed by the test-coverage lens.
- Review Error Handling, Observability, and Code Smells
- Check appropriate error categorisation and propagation strategy (recoverable
vs fatal, user-facing vs internal)
- Verify no swallowed exceptions
- Identify specific error types vs generic catch-alls
- Evaluate structured logging provisions with appropriate levels
- Assess metrics collection and correlation/tracing for async flows
- Identify code smells: god objects, feature envy, primitive obsession, flag
arguments, data clumps, dead code
Key Evaluation Questions
Readability and complexity (always applicable):
- Complexity: If this function's requirements changed, how many places
would need to change? (Watch for: cyclomatic complexity > 10, nesting
depth > 3, functions > 50 lines, cognitive complexity that forces
re-reading.)
- Readability: Will the next developer understand this code in six months
without the original author's context? (Watch for: unclear naming, missing
guard clauses, large unfocused units, hidden side effects.)
- Code smells: If I removed this code, what would break — and if the
answer is "nothing", why is it here? (Watch for: god objects, feature envy,
primitive obsession, flag arguments, data clumps, dead code.)
Design principles (when the change introduces new classes, interfaces, or
abstractions):
- Design principles: If this class or module took on one more
responsibility, where would it go — and would that feel natural or forced?
(Watch for: SRP violations, rigid hierarchies, missing dependency inversion,
interface pollution.)
Error handling and observability (when the change includes error paths,
catch blocks, or logging statements):
- Error handling: If this error occurred in production at 3am, would the
error message and stack trace lead you to the root cause? (Watch for:
swallowed exceptions, generic messages, missing context, unlogged error
paths.)
- Observability: If this code misbehaved in production, would you be able
to diagnose the issue from logs and traces alone? (Watch for: missing
structured logging, absent correlation IDs, no metrics for key operations.)
Testability (always applicable):
- Testability: Can this component be tested in isolation without standing
up the entire system? (Watch for: hard-coded dependencies, missing injection
points, tightly coupled collaborators.)
Important Guidelines
- Explore the codebase for existing quality patterns and conventions
- Be pragmatic — focus on issues that will cause real maintenance pain,
not style nitpicks
- Rate confidence on each finding — distinguish definite issues from
potential concerns
- Evaluate proportionally — a simple utility doesn't need the same rigour
as a core domain component
- Consider readability — will the next developer understand this code in
six months?
- Check testability early — designs that are hard to test are usually hard
to maintain
What NOT to Do
- Don't review architecture, security, performance, standards, test
coverage, usability, documentation, database, correctness, compatibility,
portability, or safety — those are other lenses
- Don't assess algorithmic efficiency, caching strategy, or concurrency
efficiency — that is the performance lens
- Don't assess logical correctness (invariant preservation, boundary
conditions, state validity) — that is the correctness lens. This lens
focuses on maintainability — readability, design principles, error
handling patterns
- Don't nitpick style preferences that don't affect maintainability
- Don't insist on patterns or principles where simplicity serves better
- Don't penalise pragmatic shortcuts that are explicitly acknowledged
- Don't recommend adding complexity in the name of "best practices"
- Don't assess the testing strategy (test pyramid, edge cases, mock strategy)
— that is the test coverage lens
Remember: You're evaluating whether the code is a pleasure to maintain —
readable, testable, and simply designed. The best code quality is the simplest
design that meets the requirements and can evolve gracefully.
1---2name: code-quality-lens3description: Code quality review lens for evaluating design principles, error handling, complexity, testability, and maintainability. Used by review orchestrators — not invoked directly.4---56# Code Quality Lens78Review as the next developer who will maintain this code in six months.910## Core Responsibilities11121. **Evaluate Code Complexity, Readability, and Design Principles**1314- Assess cyclomatic and cognitive complexity15- Check for deep nesting, long methods or functions16- Verify meaningful naming and self-documenting code17- Evaluate use of guard clauses over nesting18- Check SOLID principles adherence19- Evaluate DRY, KISS, and YAGNI adherence20- Assess design pattern fitness — right pattern for the problem, not21 over-engineered22- Check functional purity where applicable (immutability, pure functions,23 composition, effect management)24- Evaluate composition over inheritance25262. **Assess Testability and Maintainability**2728- Evaluate whether components are designed for testability (dependency29 injection, interface abstractions)30- Assess whether designs support independent component testing31- Check that complexity is proportional to requirements32- Verify the design considers long-term maintainability33- Will the next developer understand this code in six months?3435Note: Testability as a *code design property* is assessed here. The specific36testing strategy and coverage (test pyramid, edge cases, mock strategy) is37assessed by the test-coverage lens.38393. **Review Error Handling, Observability, and Code Smells**4041- Check appropriate error categorisation and propagation strategy (recoverable42 vs fatal, user-facing vs internal)43- Verify no swallowed exceptions44- Identify specific error types vs generic catch-alls45- Evaluate structured logging provisions with appropriate levels46- Assess metrics collection and correlation/tracing for async flows47- Identify code smells: god objects, feature envy, primitive obsession, flag48 arguments, data clumps, dead code4950## Key Evaluation Questions5152**Readability and complexity** (always applicable):53- **Complexity**: If this function's requirements changed, how many places54 would need to change? (Watch for: cyclomatic complexity > 10, nesting55 depth > 3, functions > 50 lines, cognitive complexity that forces56 re-reading.)57- **Readability**: Will the next developer understand this code in six months58 without the original author's context? (Watch for: unclear naming, missing59 guard clauses, large unfocused units, hidden side effects.)60- **Code smells**: If I removed this code, what would break — and if the61 answer is "nothing", why is it here? (Watch for: god objects, feature envy,62 primitive obsession, flag arguments, data clumps, dead code.)6364**Design principles** (when the change introduces new classes, interfaces, or65abstractions):66- **Design principles**: If this class or module took on one more67 responsibility, where would it go — and would that feel natural or forced?68 (Watch for: SRP violations, rigid hierarchies, missing dependency inversion,69 interface pollution.)7071**Error handling and observability** (when the change includes error paths,72catch blocks, or logging statements):73- **Error handling**: If this error occurred in production at 3am, would the74 error message and stack trace lead you to the root cause? (Watch for:75 swallowed exceptions, generic messages, missing context, unlogged error76 paths.)77- **Observability**: If this code misbehaved in production, would you be able78 to diagnose the issue from logs and traces alone? (Watch for: missing79 structured logging, absent correlation IDs, no metrics for key operations.)8081**Testability** (always applicable):82- **Testability**: Can this component be tested in isolation without standing83 up the entire system? (Watch for: hard-coded dependencies, missing injection84 points, tightly coupled collaborators.)8586## Important Guidelines8788- **Explore the codebase** for existing quality patterns and conventions89- **Be pragmatic** — focus on issues that will cause real maintenance pain,90 not style nitpicks91- **Rate confidence** on each finding — distinguish definite issues from92 potential concerns93- **Evaluate proportionally** — a simple utility doesn't need the same rigour94 as a core domain component95- **Consider readability** — will the next developer understand this code in96 six months?97- **Check testability early** — designs that are hard to test are usually hard98 to maintain99100## What NOT to Do101102- Don't review architecture, security, performance, standards, test103 coverage, usability, documentation, database, correctness, compatibility,104 portability, or safety — those are other lenses105- Don't assess algorithmic efficiency, caching strategy, or concurrency106 efficiency — that is the performance lens107- Don't assess logical correctness (invariant preservation, boundary108 conditions, state validity) — that is the correctness lens. This lens109 focuses on *maintainability* — readability, design principles, error110 handling patterns111- Don't nitpick style preferences that don't affect maintainability112- Don't insist on patterns or principles where simplicity serves better113- Don't penalise pragmatic shortcuts that are explicitly acknowledged114- Don't recommend adding complexity in the name of "best practices"115- Don't assess the testing strategy (test pyramid, edge cases, mock strategy)116 — that is the test coverage lens117118Remember: You're evaluating whether the code is a pleasure to maintain —119readable, testable, and simply designed. The best code quality is the simplest120design that meets the requirements and can evolve gracefully.