Write and review code that is easy to read, safe to change, and cheap to maintain.
When To Use
Use this skill when the user wants:
- Code review focused on quality, not just correctness
- Refactoring for readability and maintainability
- Better naming and function boundaries
- Code smell detection and prioritization
- A stronger long-term codebase structure
Prefer pairing with:
code-quality-engineeringfor broader senior-level quality passestesting-qualitywhen behavior changes or regression risk is significant
Mission
Produce code that is:
- Correct
- Readable
- Testable
- Evolvable
- Boring in the best way (predictable, unsurprising)
Maintainability Contract (Agent Behavior)
Always enforce these rules:
- Preserve behavior first. Refactor without changing outputs unless asked.
- Make intent obvious. Names should remove guesswork.
- Keep units focused. One function/class should have one clear reason to change.
- Reduce cognitive load. Prefer straight-line logic over nested cleverness.
- Keep error paths explicit. Fail loudly with actionable context.
- Add or update tests proportionate to risk.
- Leave the touched area cleaner than it was.
Never do these:
- Over-abstract for style points
- Introduce indirection with vague helper names
- Rewrite whole modules when a surgical refactor solves the issue
- Hide uncertainty; call out assumptions and risks explicitly
Cute Code Policy
"Cute code" means delightful readability, not gimmicks.
Allowed:
- Small expressive helpers with precise names
- Intent-revealing variables that read like prose
- Minimal, tasteful comments for non-obvious "why"
Not allowed:
- Joke names in production code
- Clever one-liners that reduce clarity
- Decorative comments, emoji comments, or noisy style tricks
Fast Review Workflow (5-10 min)
- Read for intent: What is this code responsible for?
- Find top 3 issues: prioritize by maintenance risk.
- Classify issues: naming, function shape, structure, error handling, tests.
- Propose minimal high-impact fixes.
- Report findings with severity and concrete examples.
Deep Refactor Workflow
Phase 1: Safety
- Confirm expected behavior and constraints.
- Identify existing tests; add guard tests if needed.
Phase 2: Clarity
- Rename unclear identifiers.
- Replace magic values with named constants.
- Flatten deeply nested control flow where possible.
Phase 3: Boundaries
- Split multi-purpose functions.
- Remove flag-argument branches by splitting intent into separate functions.
- Isolate side effects from pure logic.
Phase 4: Design Hygiene
- Enforce single responsibility in classes/modules.
- Reduce coupling via clearer interfaces.
- Remove dead code and redundant comments.
Phase 5: Verification
- Run tests/lint/types.
- Confirm no unintentional behavior changes.
- Summarize residual risk.
Prioritization Matrix
Fix in this order:
- Correctness and data-loss risk
- Error-handling ambiguity
- Hard-to-read hot paths
- Naming and API clarity
- Structural debt (coupling/cohesion)
- Cosmetic cleanup
Quality Checklist
Naming
- Names reveal intent and domain meaning
- Booleans read as predicates (
is,has,should) - No vague placeholders (
tmp,data,misc,util)
Functions
- One level of abstraction per function
- Minimal parameters (prefer 0-3, justify beyond)
- Command-query separation where practical
- No hidden side effects
Modules/Classes
- Single clear responsibility
- Cohesive public API
- Dependencies point inward to stable abstractions
Error Handling
- Include actionable context in errors
- Avoid silent fallback that hides failures
- Distinguish "empty result" vs "failed operation"
Tests
- Cover critical behavior and failure paths
- Add regression tests for bugs/refactors
- Avoid brittle tests that mirror implementation details
Output Format For Reviews
When returning review feedback, use:
- Findings first, sorted by severity (
high,medium,low) - For each finding: location, issue, why it matters, minimal fix
- Open questions/assumptions
- Short change plan (smallest safe sequence)
Examples
Example: Naming
Bad:
let d; // elapsed days
let flg;
Good:
const elapsedDays = 3;
const isEligibleForRetry = true;
Example: Flag Argument
Bad:
function processPayment(isRefund) {
if (isRefund) refund();
else charge();
}
Good:
function refundPayment() {
refund();
}
function chargePayment() {
charge();
}
Example: Comment Cleanup
Bad:
// increment retry count
retryCount++;
Good:
retryCount++;
Troubleshooting
Reviews are shallow
- Force severity-based findings (not generic praise)
- Require concrete code references and minimal patches
Too many suggestions
- Limit to highest impact first pass
- Split into iterative rounds: naming -> functions -> structure
Refactor resistance
- Explain maintenance payoff in concrete terms (faster onboarding, safer edits, fewer regressions)
- Use incremental diffs, not big-bang rewrites
References
Read only as needed:
references/code-smells.mdfor smell catalog and heuristicsreferences/naming-patterns.mdfor naming conventionsreferences/refactoring-patterns.mdfor extraction and decomposition patternsreferences/javascript-examples.mdfor JS-focused examples
Success Criteria
This skill succeeds when code after the pass is:
- Faster to understand
- Safer to modify
- Easier to test
- Less coupled
- Free of avoidable ambiguity