codereview-style
Review code style, maintainability, and documentation. Checks readability, naming, modularity, abstractions, and documentation accuracy. Use as a final pass on all files.
What this skill does
# 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
```javascript
// ๐จ 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
```javascript
// ๐จ 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
```javascript
// ๐จ 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
```javascript
// ๐จ 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
```javascript
// ๐จ 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
```javascript
// ๐จ 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
```javascript
// ๐จ Premature abstraction
class AbstractFactoryBuilderManager { ... } // used once
// โ
When needed
// Extract after seeing pattern 3+ times
```
- [ ] **Not Leaky**: Abstractions hide implementation details
```javascript
// ๐จ 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
```javascript
// ๐จ Dead code
function oldImplementation() { ... } // never called
const UNUSED_CONSTANT = 42 // never referenced
```
- [ ] **No Commented-Out Code**: Remove or restore, don't leave
```javascript
// ๐จ Commented-out code
// function oldVersion() {
// return legacyBehavior()
// }
```
- [ ] **No Debug Artifacts**: console.log, debugger removed
```javascript
// ๐จ Debug artifacts
console.log('DEBUG:', data)
debugger
```
- [ ] **No TODO Without Issue**: TODOs reference tickets
```javascript
// ๐จ Orphan TODO
// TODO: fix this later
// โ
Tracked TODO
// TODO(JIRA-123): Refactor when v2 API is ready
```
### Comments
- [ ] **Comments Explain "Why"**: Not "what"
```javascript
// ๐จ 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
```javascript
// ๐จ Outdated comment
// Returns user's full name
function getDisplayName(user) {
return user.email // actually returns email!
}
```
- [ ] **Self-Documenting When Possible**: Clear code > comments
```javascript
// ๐จ 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
```markdown
## 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.
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.