Code Quality Review
Use this skill for a strict review focused on implementation quality, maintainability, abstraction quality, pattern drift, and codebase health.
Above all, this skill should push the reviewer to be ambitious about code structure. Do not merely identify local cleanup opportunities. Actively search for "code judo" moves: restructurings that preserve behavior while making the implementation dramatically simpler, smaller, more direct, and more elegant.
Who runs it: a reviewer that did not write the code
This review is dispatched, never self-served. Run it in a fresh reviewer
context handed the diff and the changed files' contents: the
code-quality-reviewer agent, or the host's equivalent subagent mechanism.
The session that implemented the change is the one context that cannot perform
this review. It holds every justification that produced the code, so the
structure reads as inevitable rather than as a choice someone made, and the
code-judo move this rubric exists to find is precisely what that context is
blindest to. A self-served pass reliably returns "nothing blocking" on a diff a
fresh reviewer takes apart. Dispatching also keeps the full diff and file
contents out of the implementing session's window.
Where the host offers no subagent mechanism, the review still does not run
inside the implementing context: hand the diff to a fresh session and name that
route in the report. An author's pass over their own work is reported as what it
is and never as this gate.
Core Prompt
Start from this baseline:
Perform a deep code quality audit of the current branch's changes.
Rethink how to structure / implement the changes to meaningfully improve code quality without impacting behavior.
Work to improve abstractions, modularity, reduce Spaghetti code, improve succinctness and legibility.
Be ambitious, if there is a clear path to improving the implementation that involves restructuring some of the codebase, go for it.
Be extremely thorough and rigorous. Measure twice, cut once.
Scope Boundary: strict inside, follow-up outside
All the strictness below applies within the accepted work's boundary:
the ticket, plan, or agreed change under review. Findings outside it are
classified, not chased:
- In scope (blocking): demonstrated defects and material structural problems
in this change. Explain the consequence and fix before approval.
- In scope (advisory): supported improvements without a blocking consequence.
File length or an alternative design alone does not establish a blocker.
- Out of scope (follow-up): adjacent defects, pre-existing mess this
diff did not worsen, improvements beyond the accepted work: record them
in the existing scope record; external tickets require explicit existing
authorization and deduplication. Do not fold them into
this change. One exception: a finding that proves this change unsafe or
incorrect as shipped blocks regardless of where it lives.
- The review is a gate, not an implementation-discovery engine, and a
default-on gate: when a work-stream's implementation is complete, this
review runs whether or not anyone asked for it. Exactly two things stop it:
the user explicitly declining, or the repo's own process superseding
it. A small diff, a confident implementation, a clean-looking change, time
pressure, or the session's own sense that this one doesn't need it are not
among them. Run the initial review when implementation is believed complete,
before filing a PR or merging directly. Record the reviewed revision and
dispositions. Verify direct corrections without restarting the whole review.
Material changes to behavior, design, or risk get focused independent follow-up;
repeat a full review only if changes broadly invalidate the earlier review.
Non-Negotiable Additional Standards
Apply the baseline prompt above, plus these explicit review rules:
Be ambitious about structural simplification.
- Do not stop at "this could be a bit cleaner."
- Look for opportunities to reframe the change so that whole branches, helpers, modes, conditionals, or layers disappear entirely.
- Prefer the solution that makes the code feel inevitable in hindsight.
- Assume there is often a "code judo" move available: a re-organization that uses the existing architecture more effectively and makes the change dramatically simpler and more elegant.
- If you see a path to delete complexity rather than rearrange it, push hard for that path.
Inspect a PR that pushes a file from under 1k lines to over 1k lines for a concrete decomposition problem.
- Treat this as a strong code-quality smell by default.
- Prefer extracting helpers, subcomponents, modules, or local abstractions instead of letting a file sprawl past 1000 lines.
- If the diff crosses that threshold, explicitly ask whether the code should be decomposed first.
- Only waive this if there is a compelling structural reason and the resulting file is still clearly organized.
Do not allow random spaghetti growth in existing code.
- Be highly suspicious of new ad-hoc conditionals, scattered special cases, or one-off branches inserted into unrelated flows.
- If a change adds "weird if statements in random places", treat that as a design problem, not a stylistic nit.
- Prefer pushing the logic into a dedicated abstraction, helper, state machine, policy object, or separate module instead of tangling an existing path.
- Call out changes that make the surrounding code harder to reason about, even if they technically work.
Bias toward cleaning the design, not just accepting working code.
- If behavior can stay the same while the structure becomes meaningfully cleaner, push for the cleaner version.
- Do not rubber-stamp "it works" implementations that leave the codebase messier.
- Strongly prefer simplifications that remove moving pieces altogether over refactors that merely spread the same complexity around.
Prefer direct, boring, maintainable code over hacky or magical code.
- Treat brittle, ad-hoc, or "magic" behavior as a code-quality problem.
- Be skeptical of generic mechanisms that hide simple data-shape assumptions.
- Flag thin abstractions, identity wrappers, or pass-through helpers that add indirection without buying clarity.
Push hard on type and boundary cleanliness when they affect maintainability.
- Question unnecessary optionality,
unknown, any, or cast-heavy code when a clearer type boundary could exist.
- Prefer explicit typed models or shared contracts over loosely-shaped ad-hoc objects.
- If a branch relies on silent fallback to paper over an unclear invariant, ask whether the boundary should be made explicit instead.
Keep logic in the canonical layer and reuse existing helpers.
- Call out feature logic leaking into shared paths or implementation details leaking through APIs.
- Prefer existing canonical utilities/helpers over bespoke one-offs.
- Push code toward the right package, service, or module instead of normalizing architectural drift.
Treat unnecessary sequential orchestration and non-atomic updates as design smells when the cleaner structure is obvious.
- If independent work is serialized for no good reason, ask whether the flow should run in parallel instead.
- If related updates can leave state half-applied, push for a more atomic structure.
- Do not over-index on micro-optimizations, but do flag avoidable orchestration complexity that makes the implementation more brittle.
Primary Review Questions
For every meaningful change, ask:
- Is there a "code judo" move that would make this dramatically simpler?
- Can this change be reframed so fewer concepts, branches, or helper layers are needed?
- Does this improve or worsen the local architecture?
- Did the diff add branching complexity where a better abstraction should exist?
- Did a previously cohesive module become more coupled, more stateful, or harder to scan?
- Is this logic living in the right file and layer?
- Did this change enlarge a file or component past a healthy size boundary?
- Are there repeated conditionals that signal a missing model or missing helper?
- Is the implementation direct and legible, or does it rely on special cases and incidental control flow?
- Is this abstraction actually earning its keep, or is it just a wrapper?
- Did the diff introduce casts, optionality, or ad-hoc object shapes that obscure the real invariant?
- Is this logic living in the canonical layer, or did the diff leak details across a boundary?
- Is this orchestration more sequential or less atomic than it needs to be?
What to Flag Aggressively
Escalate findings when you see:
- A complicated implementation where a cleaner reframing could delete whole categories of complexity.
- Refactors that move code around but fail to reduce the number of concepts a reader must hold in their head.
- A file crossing 1000 lines due to the PR, especially if the new code could be split out.
- New conditionals bolted onto unrelated code paths.
- One-off booleans, nullable modes, or flags that complicate existing control flow.
- Feature-specific logic leaking into general-purpose modules.
- Generic "magic" handling that hides simple structure and makes the code harder to reason about.
- Thin wrappers or identity abstractions that add indirection without simplifying anything.
- Unnecessary casts,
any, unknown, or optional params that muddy the real contract.
- Copy-pasted logic instead of extracted helpers.
- Narrow edge-case handling implemented in the middle of an already busy function.
- Refactors that technically pass tests but make the code less modular or less readable.
- "Temporary" branching that is likely to become permanent debt.
- Bespoke helpers where the codebase already has a canonical utility for the job.
- Logic added in the wrong layer/package when it should live somewhere more central.
- Sequential async flow where obviously independent work could stay simpler and clearer with parallel execution.
- Partial-update logic that leaves state less atomic than necessary.
Preferred Remedies
When you identify a code-quality problem, prefer suggestions like:
- Delete a whole layer of indirection rather than polishing it.
- Reframe the state model so conditionals disappear instead of getting centralized.
- Change the ownership boundary so the feature becomes a natural extension of an existing abstraction.
- Turn special-case logic into a simpler default flow with fewer exceptions.
- Extract a helper or pure function.
- Split a large file into smaller focused modules.
- Move feature-specific logic behind a dedicated abstraction.
- Replace condition chains with a typed model or explicit dispatcher.
- Separate orchestration from business logic.
- Collapse duplicate branches into a single clearer flow.
- Delete wrappers that do not meaningfully clarify the API.
- Reuse the existing canonical helper instead of introducing a near-duplicate.
- Make type boundaries more explicit so the control flow gets simpler.
- Move the logic to the package/module/layer that already owns the concept.
- Parallelize independent work when that also simplifies the orchestration.
- Restructure related updates into a more atomic flow when partial state would be harder to reason about.
Do not be satisfied with "maybe rename this" feedback when the real issue is structural.
Do not be satisfied with a merely cleaner version of the same messy idea if there is a plausible path to a much simpler idea.
Review Tone
Be direct, serious, and demanding about quality.
Do not be rude, but do not soften major maintainability issues into mild suggestions.
If the code is making the codebase messier, say so clearly.
If the implementation missed an opportunity for a dramatic simplification, say that clearly too.
Good phrases:
this pushes the file past 1k lines. can we decompose this first?
this adds another special-case branch into an already busy flow. can we move this behind its own abstraction?
this works, but it makes the surrounding code more spaghetti. let's keep the behavior and restructure the implementation.
this feels like feature logic leaking into a shared path. can we isolate it?
this abstraction seems unnecessary. can we just keep the direct flow?
why does this need a cast / optional here? can we make the boundary more explicit instead?
this looks like a bespoke helper for something we already have elsewhere. can we reuse the canonical one?
i think there's a code-judo move here that makes this much simpler. can we reframe this so these branches disappear?
this refactor moves complexity around, but doesn't really delete it. is there a way to make the model itself simpler?
Output Expectations
Prioritize findings in this order:
- Structural code-quality regressions
- Missed opportunities for dramatic simplification / code-judo restructuring
- Spaghetti / branching complexity increases
- Boundary / abstraction / type-contract problems that make the code harder to reason about
- File-size and decomposition concerns
- Modularity and abstraction issues
- Legibility and maintainability concerns
Do not flood the review with low-value nits if there are larger structural issues.
Prefer a smaller number of high-conviction comments over a long list of cosmetic notes.
Label every finding in-scope (blocking), in-scope (advisory), or
out-of-scope (follow-up) per the scope boundary: an unlabeled finding reads as blocking.
Approval Bar
Do not approve merely because behavior seems correct.
The bar for approval is:
- no clear structural regression
- no unaddressed material structural problem where a demonstrated simplification resolves the consequence
- no unjustified file-size explosion
- no obvious spaghetti-growth from special-case branching
- no obviously hacky or magical abstraction that makes the code harder to reason about
- no unnecessary wrapper/cast/optionality churn obscuring the real design
- no clear architecture-boundary leak or avoidable canonical-helper duplication
- no missed opportunity for an obvious decomposition that would materially improve maintainability
Investigate these aggressively and require a clear structural justification.
They block when the review demonstrates a correctness or material maintainability
consequence; file length or an alternative design alone is not sufficient:
- the PR preserves a lot of incidental complexity when there is a plausible code-judo move that would delete it
- the PR pushes a file from below 1000 lines to above 1000 lines
- the PR adds ad-hoc branching that makes an existing flow more tangled
- the PR solves a local problem by scattering feature checks across shared code
- the PR adds an unnecessary abstraction, wrapper, or cast-heavy contract that makes the design more indirect
- the PR duplicates an existing helper or puts logic in the wrong layer when there is a clear canonical home
If those conditions are not met, leave explicit, actionable feedback and push for a cleaner decomposition.
1---2name: code-quality-review3description: Use for a strict or adversarial code quality review; required once a work-stream's implementation is complete, right before PR-or-merge, never mid-implementation.4---56# Code Quality Review78Use this skill for a strict review focused on implementation quality, maintainability, abstraction quality, pattern drift, and codebase health.910Above all, this skill should push the reviewer to be **ambitious** about code structure. Do not merely identify local cleanup opportunities. Actively search for "code judo" moves: restructurings that preserve behavior while making the implementation dramatically simpler, smaller, more direct, and more elegant.1112## Who runs it: a reviewer that did not write the code1314This review is **dispatched, never self-served.** Run it in a fresh reviewer15context handed the diff and the changed files' contents: the16`code-quality-reviewer` agent, or the host's equivalent subagent mechanism.1718The session that implemented the change is the one context that cannot perform19this review. It holds every justification that produced the code, so the20structure reads as inevitable rather than as a choice someone made, and the21code-judo move this rubric exists to find is precisely what that context is22blindest to. A self-served pass reliably returns "nothing blocking" on a diff a23fresh reviewer takes apart. Dispatching also keeps the full diff and file24contents out of the implementing session's window.2526Where the host offers no subagent mechanism, the review still does not run27inside the implementing context: hand the diff to a fresh session and name that28route in the report. An author's pass over their own work is reported as what it29is and never as this gate.3031## Core Prompt3233Start from this baseline:3435> Perform a deep code quality audit of the current branch's changes.36> Rethink how to structure / implement the changes to meaningfully improve code quality without impacting behavior.37> Work to improve abstractions, modularity, reduce Spaghetti code, improve succinctness and legibility.38> Be ambitious, if there is a clear path to improving the implementation that involves restructuring some of the codebase, go for it.39> Be extremely thorough and rigorous. Measure twice, cut once.4041## Scope Boundary: strict inside, follow-up outside4243All the strictness below applies **within the accepted work's boundary**:44the ticket, plan, or agreed change under review. Findings outside it are45classified, not chased:4647- **In scope (blocking):** demonstrated defects and material structural problems48 in this change. Explain the consequence and fix before approval.49- **In scope (advisory):** supported improvements without a blocking consequence.50 File length or an alternative design alone does not establish a blocker.51- **Out of scope (follow-up):** adjacent defects, pre-existing mess this52 diff did not worsen, improvements beyond the accepted work: record them53 in the existing scope record; external tickets require explicit existing54 authorization and deduplication. Do **not** fold them into55 this change. One exception: a finding that proves this change **unsafe or56 incorrect as shipped** blocks regardless of where it lives.57- The review is a **gate, not an implementation-discovery engine**, and a58 **default-on** gate: when a work-stream's implementation is complete, this59 review runs whether or not anyone asked for it. Exactly two things stop it:60 **the user explicitly declining**, or **the repo's own process superseding61 it**. A small diff, a confident implementation, a clean-looking change, time62 pressure, or the session's own sense that this one doesn't need it are not63 among them. Run the initial review when implementation is believed complete,64 before filing a PR or merging directly. Record the reviewed revision and65 dispositions. Verify direct corrections without restarting the whole review.66 Material changes to behavior, design, or risk get focused independent follow-up;67 repeat a full review only if changes broadly invalidate the earlier review.6869## Non-Negotiable Additional Standards7071Apply the baseline prompt above, plus these explicit review rules:72730. **Be ambitious about structural simplification.**74 - Do not stop at "this could be a bit cleaner."75 - Look for opportunities to reframe the change so that whole branches, helpers, modes, conditionals, or layers disappear entirely.76 - Prefer the solution that makes the code feel inevitable in hindsight.77 - Assume there is often a "code judo" move available: a re-organization that uses the existing architecture more effectively and makes the change dramatically simpler and more elegant.78 - If you see a path to delete complexity rather than rearrange it, push hard for that path.79801. **Inspect a PR that pushes a file from under 1k lines to over 1k lines for a concrete decomposition problem.**81 - Treat this as a strong code-quality smell by default.82 - Prefer extracting helpers, subcomponents, modules, or local abstractions instead of letting a file sprawl past 1000 lines.83 - If the diff crosses that threshold, explicitly ask whether the code should be decomposed first.84 - Only waive this if there is a compelling structural reason and the resulting file is still clearly organized.85862. **Do not allow random spaghetti growth in existing code.**87 - Be highly suspicious of new ad-hoc conditionals, scattered special cases, or one-off branches inserted into unrelated flows.88 - If a change adds "weird if statements in random places", treat that as a design problem, not a stylistic nit.89 - Prefer pushing the logic into a dedicated abstraction, helper, state machine, policy object, or separate module instead of tangling an existing path.90 - Call out changes that make the surrounding code harder to reason about, even if they technically work.91923. **Bias toward cleaning the design, not just accepting working code.**93 - If behavior can stay the same while the structure becomes meaningfully cleaner, push for the cleaner version.94 - Do not rubber-stamp "it works" implementations that leave the codebase messier.95 - Strongly prefer simplifications that remove moving pieces altogether over refactors that merely spread the same complexity around.96974. **Prefer direct, boring, maintainable code over hacky or magical code.**98 - Treat brittle, ad-hoc, or "magic" behavior as a code-quality problem.99 - Be skeptical of generic mechanisms that hide simple data-shape assumptions.100 - Flag thin abstractions, identity wrappers, or pass-through helpers that add indirection without buying clarity.1011025. **Push hard on type and boundary cleanliness when they affect maintainability.**103 - Question unnecessary optionality, `unknown`, `any`, or cast-heavy code when a clearer type boundary could exist.104 - Prefer explicit typed models or shared contracts over loosely-shaped ad-hoc objects.105 - If a branch relies on silent fallback to paper over an unclear invariant, ask whether the boundary should be made explicit instead.1061076. **Keep logic in the canonical layer and reuse existing helpers.**108 - Call out feature logic leaking into shared paths or implementation details leaking through APIs.109 - Prefer existing canonical utilities/helpers over bespoke one-offs.110 - Push code toward the right package, service, or module instead of normalizing architectural drift.1111127. **Treat unnecessary sequential orchestration and non-atomic updates as design smells when the cleaner structure is obvious.**113 - If independent work is serialized for no good reason, ask whether the flow should run in parallel instead.114 - If related updates can leave state half-applied, push for a more atomic structure.115 - Do not over-index on micro-optimizations, but do flag avoidable orchestration complexity that makes the implementation more brittle.116117## Primary Review Questions118119For every meaningful change, ask:120121- Is there a "code judo" move that would make this dramatically simpler?122- Can this change be reframed so fewer concepts, branches, or helper layers are needed?123- Does this improve or worsen the local architecture?124- Did the diff add branching complexity where a better abstraction should exist?125- Did a previously cohesive module become more coupled, more stateful, or harder to scan?126- Is this logic living in the right file and layer?127- Did this change enlarge a file or component past a healthy size boundary?128- Are there repeated conditionals that signal a missing model or missing helper?129- Is the implementation direct and legible, or does it rely on special cases and incidental control flow?130- Is this abstraction actually earning its keep, or is it just a wrapper?131- Did the diff introduce casts, optionality, or ad-hoc object shapes that obscure the real invariant?132- Is this logic living in the canonical layer, or did the diff leak details across a boundary?133- Is this orchestration more sequential or less atomic than it needs to be?134135## What to Flag Aggressively136137Escalate findings when you see:138139- A complicated implementation where a cleaner reframing could delete whole categories of complexity.140- Refactors that move code around but fail to reduce the number of concepts a reader must hold in their head.141- A file crossing 1000 lines due to the PR, especially if the new code could be split out.142- New conditionals bolted onto unrelated code paths.143- One-off booleans, nullable modes, or flags that complicate existing control flow.144- Feature-specific logic leaking into general-purpose modules.145- Generic "magic" handling that hides simple structure and makes the code harder to reason about.146- Thin wrappers or identity abstractions that add indirection without simplifying anything.147- Unnecessary casts, `any`, `unknown`, or optional params that muddy the real contract.148- Copy-pasted logic instead of extracted helpers.149- Narrow edge-case handling implemented in the middle of an already busy function.150- Refactors that technically pass tests but make the code less modular or less readable.151- "Temporary" branching that is likely to become permanent debt.152- Bespoke helpers where the codebase already has a canonical utility for the job.153- Logic added in the wrong layer/package when it should live somewhere more central.154- Sequential async flow where obviously independent work could stay simpler and clearer with parallel execution.155- Partial-update logic that leaves state less atomic than necessary.156157## Preferred Remedies158159When you identify a code-quality problem, prefer suggestions like:160161- Delete a whole layer of indirection rather than polishing it.162- Reframe the state model so conditionals disappear instead of getting centralized.163- Change the ownership boundary so the feature becomes a natural extension of an existing abstraction.164- Turn special-case logic into a simpler default flow with fewer exceptions.165- Extract a helper or pure function.166- Split a large file into smaller focused modules.167- Move feature-specific logic behind a dedicated abstraction.168- Replace condition chains with a typed model or explicit dispatcher.169- Separate orchestration from business logic.170- Collapse duplicate branches into a single clearer flow.171- Delete wrappers that do not meaningfully clarify the API.172- Reuse the existing canonical helper instead of introducing a near-duplicate.173- Make type boundaries more explicit so the control flow gets simpler.174- Move the logic to the package/module/layer that already owns the concept.175- Parallelize independent work when that also simplifies the orchestration.176- Restructure related updates into a more atomic flow when partial state would be harder to reason about.177178Do not be satisfied with "maybe rename this" feedback when the real issue is structural.179Do not be satisfied with a merely cleaner version of the same messy idea if there is a plausible path to a much simpler idea.180181## Review Tone182183Be direct, serious, and demanding about quality.184Do not be rude, but do not soften major maintainability issues into mild suggestions.185If the code is making the codebase messier, say so clearly.186If the implementation missed an opportunity for a dramatic simplification, say that clearly too.187188Good phrases:189190- `this pushes the file past 1k lines. can we decompose this first?`191- `this adds another special-case branch into an already busy flow. can we move this behind its own abstraction?`192- `this works, but it makes the surrounding code more spaghetti. let's keep the behavior and restructure the implementation.`193- `this feels like feature logic leaking into a shared path. can we isolate it?`194- `this abstraction seems unnecessary. can we just keep the direct flow?`195- `why does this need a cast / optional here? can we make the boundary more explicit instead?`196- `this looks like a bespoke helper for something we already have elsewhere. can we reuse the canonical one?`197- `i think there's a code-judo move here that makes this much simpler. can we reframe this so these branches disappear?`198- `this refactor moves complexity around, but doesn't really delete it. is there a way to make the model itself simpler?`199200## Output Expectations201202Prioritize findings in this order:2032041. Structural code-quality regressions2052. Missed opportunities for dramatic simplification / code-judo restructuring2063. Spaghetti / branching complexity increases2074. Boundary / abstraction / type-contract problems that make the code harder to reason about2085. File-size and decomposition concerns2096. Modularity and abstraction issues2107. Legibility and maintainability concerns211212Do not flood the review with low-value nits if there are larger structural issues.213Prefer a smaller number of high-conviction comments over a long list of cosmetic notes.214Label every finding **in-scope (blocking)**, **in-scope (advisory)**, or215**out-of-scope (follow-up)** per the scope boundary: an unlabeled finding reads as blocking.216217## Approval Bar218219Do not approve merely because behavior seems correct.220The bar for approval is:221222- no clear structural regression223- no unaddressed material structural problem where a demonstrated simplification resolves the consequence224- no unjustified file-size explosion225- no obvious spaghetti-growth from special-case branching226- no obviously hacky or magical abstraction that makes the code harder to reason about227- no unnecessary wrapper/cast/optionality churn obscuring the real design228- no clear architecture-boundary leak or avoidable canonical-helper duplication229- no missed opportunity for an obvious decomposition that would materially improve maintainability230231Investigate these aggressively and require a clear structural justification.232They block when the review demonstrates a correctness or material maintainability233consequence; file length or an alternative design alone is not sufficient:234235- the PR preserves a lot of incidental complexity when there is a plausible code-judo move that would delete it236- the PR pushes a file from below 1000 lines to above 1000 lines237- the PR adds ad-hoc branching that makes an existing flow more tangled238- the PR solves a local problem by scattering feature checks across shared code239- the PR adds an unnecessary abstraction, wrapper, or cast-heavy contract that makes the design more indirect240- the PR duplicates an existing helper or puts logic in the wrong layer when there is a clear canonical home241242If those conditions are not met, leave explicit, actionable feedback and push for a cleaner decomposition.