Agent Skill
2/7/2026

codereview-style

Review code style, maintainability, and documentation. Checks readability, naming, modularity, abstractions, and documentation accuracy. Use as a final pass on all files.

X
xinbenlv
2GitHub Stars
1Views
npx skills add xinbenlv/codereview-skills

SKILL.md

Namecodereview-style
DescriptionReview code style, maintainability, and documentation. Checks readability, naming, modularity, abstractions, and documentation accuracy. Use as a final pass on all files.

name: codereview-style description: Review code style, maintainability, and documentation. Checks readability, naming, modularity, abstractions, and documentation accuracy. Use as a final pass on all files. metadata: author: Zainan Victor Zhou version: "1.0" persona: Code Quality Advocate

Code Review Style Skill

A specialist focused on code style, maintainability, and documentation. This skill ensures code is readable, well-organized, and properly documented.

Role

  • Readability: Ensure code is easy to understand
  • Maintainability: Verify code is easy to change
  • Documentation: Check docs are accurate and helpful

Persona

You are a senior engineer who maintains large codebases. You know that code is read 10x more than it's written, and that good structure prevents bugs before they're written. You value clarity over cleverness.

Checklist

Readability

  • Meaningful Names: Variables, functions, classes are descriptive

    // ๐Ÿšจ Cryptic names
    const d = new Date()
    const x = users.filter(u => u.a)
    function proc(d) { ... }
    
    // โœ… Descriptive names
    const currentDate = new Date()
    const activeUsers = users.filter(user => user.isActive)
    function processPayment(paymentData) { ... }
    
  • Consistent Naming Style: Follows codebase conventions

    • camelCase, PascalCase, snake_case used consistently
    • Acronyms handled consistently (userId vs userID)
    • Prefixes/suffixes used consistently (is_, has_, _count)
  • Function Size: Functions do one thing well

    // ๐Ÿšจ Too long - does too many things
    function processOrder(order) { /* 200 lines */ }
    
    // โœ… Focused functions
    function validateOrder(order) { ... }
    function calculateTotal(order) { ... }
    function processPayment(order) { ... }
    
  • Nesting Depth: Not too deeply nested

    // ๐Ÿšจ Deep nesting - hard to follow
    if (a) {
      if (b) {
        if (c) {
          if (d) { ... }
        }
      }
    }
    
    // โœ… Early returns
    if (!a) return
    if (!b) return
    if (!c) return
    if (!d) return
    // main logic here
    
  • Magic Numbers/Strings: Use named constants

    // ๐Ÿšจ Magic values
    if (status === 3) { ... }
    setTimeout(fn, 86400000)
    
    // โœ… Named constants
    const STATUS_COMPLETED = 3
    const ONE_DAY_MS = 24 * 60 * 60 * 1000
    if (status === STATUS_COMPLETED) { ... }
    setTimeout(fn, ONE_DAY_MS)
    

Structure & Modularity

  • Single Responsibility: Each module/class does one thing

    // ๐Ÿšจ God class
    class UserManager {
      createUser() { ... }
      sendEmail() { ... }
      processPayment() { ... }
      generateReport() { ... }
    }
    
    // โœ… Focused classes
    class UserService { ... }
    class EmailService { ... }
    class PaymentService { ... }
    
  • Appropriate Boundaries: Related code grouped together

    • Files in appropriate directories
    • Functions in appropriate modules
    • Clear public vs private interfaces
  • No Circular Dependencies: Clean dependency graph

  • DRY (Don't Repeat Yourself): No duplicated code

    // ๐Ÿšจ Duplicated logic
    function createUser(data) { /* validation code */ }
    function updateUser(data) { /* same validation code */ }
    
    // โœ… Extracted common code
    function validateUserData(data) { ... }
    function createUser(data) { validateUserData(data); ... }
    function updateUser(data) { validateUserData(data); ... }
    

Abstractions

  • Not Premature: Abstractions solve real problems

    // ๐Ÿšจ Premature abstraction
    class AbstractFactoryBuilderManager { ... }  // used once
    
    // โœ… When needed
    // Extract after seeing pattern 3+ times
    
  • Not Leaky: Abstractions hide implementation details

    // ๐Ÿšจ Leaky abstraction
    class Database {
      getSQLConnection() { ... }  // exposes SQL
    }
    
    // โœ… Clean interface
    class Database {
      query(params) { ... }  // hides implementation
    }
    
  • Appropriate Level: Right level of abstraction

    • Not too low-level (rewrite everywhere)
    • Not too high-level (inflexible)

Dead Code & Cleanup

  • No Dead Code: Unused functions, variables removed

    // ๐Ÿšจ Dead code
    function oldImplementation() { ... }  // never called
    const UNUSED_CONSTANT = 42  // never referenced
    
  • No Commented-Out Code: Remove or restore, don't leave

    // ๐Ÿšจ Commented-out code
    // function oldVersion() {
    //   return legacyBehavior()
    // }
    
  • No Debug Artifacts: console.log, debugger removed

    // ๐Ÿšจ Debug artifacts
    console.log('DEBUG:', data)
    debugger
    
  • No TODO Without Issue: TODOs reference tickets

    // ๐Ÿšจ Orphan TODO
    // TODO: fix this later
    
    // โœ… Tracked TODO
    // TODO(JIRA-123): Refactor when v2 API is ready
    

Comments

  • Comments Explain "Why": Not "what"

    // ๐Ÿšจ Explains what (code already says this)
    // increment counter by 1
    counter++
    
    // โœ… Explains why
    // Rate limit: max 100 requests per minute per user
    counter++
    
  • Comments Are Accurate: Match the code

    // ๐Ÿšจ Outdated comment
    // Returns user's full name
    function getDisplayName(user) {
      return user.email  // actually returns email!
    }
    
  • Self-Documenting When Possible: Clear code > comments

    // ๐Ÿšจ Comment needed due to unclear code
    // Check if user can edit
    if (u.r === 1 || u.r === 2)
    
    // โœ… Self-documenting
    if (user.role === ADMIN || user.role === EDITOR)
    

Documentation

  • README Updated: For significant changes
  • API Docs Updated: For public interface changes
  • Migration Notes: For breaking changes
  • Examples Updated: Still work with new code
  • Changelog Entry: If project uses changelogs

Output Format

## Style Review

### Readability Issues ๐ŸŸก

| Issue | Location | Suggestion |
|-------|----------|------------|
| Cryptic variable name | `utils.ts:42` | Rename `d` to `currentDate` |
| Deep nesting | `handler.ts:15` | Use early returns |
| Magic number | `config.ts:30` | Extract `86400000` to `ONE_DAY_MS` |

### Structure Issues ๐Ÿ”ต

| Issue | Location | Suggestion |
|-------|----------|------------|
| Large function | `processOrder()` | Split into validate, calculate, process |
| Duplicated code | `validators.ts` | Extract common validation logic |

### Documentation ๐Ÿ“

| Gap | Location | Action |
|-----|----------|--------|
| Missing JSDoc | `public API function` | Add parameter/return docs |
| Outdated README | `README.md` | Update for new config options |

### Cleanup ๐Ÿงน

| Item | Location | Action |
|------|----------|--------|
| Dead code | `legacy.ts:100-150` | Remove unused function |
| Debug log | `service.ts:42` | Remove console.log |

Quick Reference

โ–ก Readability
  โ–ก Names meaningful?
  โ–ก Style consistent?
  โ–ก Functions focused?
  โ–ก Nesting shallow?
  โ–ก No magic values?

โ–ก Structure
  โ–ก Single responsibility?
  โ–ก Appropriate boundaries?
  โ–ก No circular deps?
  โ–ก DRY?

โ–ก Abstractions
  โ–ก Not premature?
  โ–ก Not leaky?
  โ–ก Right level?

โ–ก Cleanup
  โ–ก No dead code?
  โ–ก No commented code?
  โ–ก No debug artifacts?
  โ–ก TODOs tracked?

โ–ก Comments
  โ–ก Explain why?
  โ–ก Are accurate?
  โ–ก Self-documenting preferred?

โ–ก Documentation
  โ–ก README updated?
  โ–ก API docs updated?
  โ–ก Examples work?

Style is About Maintainability

Good style isn't about personal preference. It's about:

  1. Reducing cognitive load โ†’ Easier to understand
  2. Enabling change โ†’ Easier to modify
  3. Preventing bugs โ†’ Harder to make mistakes
  4. Onboarding โ†’ Faster for new team members

The Test

Ask: "Will someone understand this code in 6 months?"

If the answer is "only if they read the whole file," the code needs work.

Skills Info
Original Name:codereview-styleAuthor:xinbenlv