Code Review Standards
This skill should be used when the user asks to "review code", "perform code review", "check code quality", "review PR", "provide code feedback", or needs guidance on code review best practices and standards in k2-dev workflows.
What this skill does
# Code Review Standards Skill
## Overview
Code review is a critical quality control process that catches bugs, ensures standards compliance, and facilitates knowledge sharing.
**Review Objectives:** Ensure code quality and maintainability, catch bugs and logic errors, validate security practices, enforce project standards, share knowledge.
## Review Process
### Four-Pass Review Method
**Pass 1: High-Level Understanding**
- Read PR description and ticket context
- Understand what the code is supposed to do
- Review architectural approach
- Identify scope and boundaries
**Pass 2: Line-by-Line Detailed Review**
- Read every changed line
- Check logic correctness
- Identify potential bugs
- Note style issues
**Pass 3: Standards Validation**
- Validate against AGENTS.md quality gates
- Verify constitution.md principles
- Ensure project standards followed
**Pass 4: Architectural Assessment**
- Evaluate design decisions
- Check for code smells
- Assess maintainability
- Consider alternatives
## Review Checklist
### Code Quality
**Readability:**
- [ ] Code is self-documenting
- [ ] Variable names are descriptive
- [ ] Functions appropriately sized (<50 lines ideal)
- [ ] Complex logic has explanatory comments
- [ ] No commented-out code
**Structure:**
- [ ] Proper separation of concerns
- [ ] DRY principle followed (no duplication)
- [ ] Single Responsibility Principle
- [ ] Appropriate abstraction levels
- [ ] Consistent code style
**Error Handling:**
- [ ] All errors handled appropriately
- [ ] Error messages are informative
- [ ] No silent failures
- [ ] Edge cases considered
- [ ] Graceful degradation
### Logic and Correctness
**Functionality:**
- [ ] Implements requirements correctly
- [ ] Edge cases handled
- [ ] Boundary conditions tested
- [ ] No off-by-one errors
- [ ] Correct algorithm complexity
**Data Handling:**
- [ ] Null/undefined checks
- [ ] Type safety maintained
- [ ] Data validation present
- [ ] Proper data transformations
- [ ] No data loss scenarios
### Security
**OWASP Top 10 Security Checklist (Detailed)**
For every PR, validate:
1. **Injection**:
- [ ] SQL queries use parameterized statements or ORMs
- [ ] NoSQL queries don't use string concatenation
- [ ] OS commands don't use unsanitized user input
- [ ] LDAP queries are parameterized
2. **Broken Authentication**:
- [ ] Passwords are hashed (bcrypt, Argon2)
- [ ] Session tokens are secure, random, and expire
- [ ] Multi-factor authentication is implemented (if required)
- [ ] No credentials in code or config
3. **Sensitive Data Exposure**:
- [ ] No API keys, passwords, or secrets in code
- [ ] Sensitive data encrypted in transit (HTTPS/TLS)
- [ ] Sensitive data encrypted at rest
- [ ] No sensitive data in logs or error messages
4. **XML External Entities (XXE)**:
- [ ] XML parsing disables external entity processing
- [ ] XML libraries are configured securely
5. **Broken Access Control**:
- [ ] Authorization checks before sensitive operations
- [ ] Users can't access others' data without permission
- [ ] Admin functions require admin privileges
- [ ] CORS policies are restrictive
6. **Security Misconfiguration**:
- [ ] No default passwords or credentials
- [ ] Error messages don't leak sensitive info
- [ ] Security headers are set (CSP, X-Frame-Options, etc.)
- [ ] Unnecessary features/services are disabled
7. **Cross-Site Scripting (XSS)**:
- [ ] User input is escaped before rendering
- [ ] HTML sanitization is applied to rich content
- [ ] Content Security Policy is used
- [ ] No `dangerouslySetInnerHTML` or equivalent without sanitization
8. **Insecure Deserialization**:
- [ ] Deserialization is from trusted sources only
- [ ] Input validation before deserialization
- [ ] Type checks on deserialized objects
9. **Using Components with Known Vulnerabilities**:
- [ ] Dependencies are up-to-date
- [ ] No known CVEs in dependencies
- [ ] Dependency versions are locked
10. **Insufficient Logging & Monitoring**:
- [ ] Security events are logged
- [ ] Errors are logged (without sensitive data)
- [ ] Audit trail for sensitive operations
**Input Validation:**
- [ ] All external input validated
- [ ] Proper sanitization
- [ ] Type checking
- [ ] Length/size limits enforced
- [ ] Whitelist validation where possible
**Authentication & Authorization:**
- [ ] Proper authentication checks
- [ ] Authorization verified
- [ ] Session management secure
- [ ] No hardcoded credentials
- [ ] Secure password handling
**Data Protection:**
- [ ] Sensitive data encrypted
- [ ] No secrets in code
- [ ] Proper key management
- [ ] HTTPS enforced
- [ ] Secure headers present
### Performance
**Efficiency:**
- [ ] No unnecessary computations
- [ ] Appropriate data structures
- [ ] Efficient algorithms
- [ ] No N+1 query problems
- [ ] Proper indexing
**Resource Usage:**
- [ ] No memory leaks
- [ ] File handles closed
- [ ] Database connections managed
- [ ] Caching implemented where beneficial
- [ ] Batch operations used appropriately
### Testing
**Coverage:**
- [ ] Meets minimum coverage requirement (typically 80%)
- [ ] Critical paths fully tested
- [ ] Edge cases covered
- [ ] Error conditions tested
- [ ] Integration tests present
**Test Quality:**
- [ ] Tests are clear and maintainable
- [ ] Tests are deterministic (no flakiness)
- [ ] Good test data
- [ ] Appropriate mocking
- [ ] Tests run fast
### Documentation
**Code Documentation:**
- [ ] Public APIs documented
- [ ] Complex logic explained
- [ ] Assumptions stated
- [ ] TODOs tracked
- [ ] Examples provided where helpful
**External Documentation:**
- [ ] README updated if needed
- [ ] API docs updated
- [ ] Migration guide if breaking changes
- [ ] Changelog entry
- [ ] Configuration documented
### Project Standards
**AGENTS.md Compliance:**
- [ ] Quality gates pass
- [ ] File patterns follow conventions
- [ ] Code review standards met
- [ ] Testing requirements satisfied
- [ ] Architectural patterns followed
- [ ] Preferred libraries used
- [ ] File organization correct
- [ ] Coding style consistent
**constitution.md Compliance:**
- [ ] Core principles upheld
- [ ] Constraints respected
- [ ] Security policies followed
- [ ] Performance requirements met
## Providing Feedback
### Feedback Structure
**Standard format:**
```markdown
**[Severity]** [Category]: [Issue]
[Explanation]
[Suggestion]
[Example or reference]
```
**Severity levels:**
- **P0 (Critical):** Security vulnerabilities, data loss, breaking changes
- **P1 (Important):** Logic errors, quality gate violations, architecture issues
- **P2 (Minor):** Style issues, optimization opportunities, refactoring suggestions
- **Suggestion:** Nice-to-haves, alternative approaches, learning opportunities
**Reference:** See k2-dev-reference.md#review-severity-levels
### Example Feedback
**P0 - Security Issue:**
```markdown
**P0** Security: SQL Injection Vulnerability
The search query is directly concatenated into the SQL statement, allowing injection attacks.
\```typescript
// Current (vulnerable)
const query = `SELECT * FROM users WHERE name = '${searchTerm}'`;
// Fix: Use parameterized queries
const query = 'SELECT * FROM users WHERE name = ?';
const results = await db.query(query, [searchTerm]);
\```
Reference: OWASP SQL Injection Prevention Cheat Sheet
```
**P1 - Logic Error:**
```markdown
**P1** Logic: Off-by-One Error in Pagination
The pagination logic will skip the last item on each page due to incorrect boundary condition.
\```typescript
// Current (incorrect)
const end = start + pageSize; // Should be exclusive
// Fix
const end = Math.min(start + pageSize, totalItems);
\```
Add test case TC-045 to catch this.
```
### Tone and Approach
**DO:**
✅ Be specific and objective
✅ Explain the reasoning
✅ Provide examples and references
✅ Suggest solutions, not just problems
✅ Distinguish between must-fix and nice-to-have
✅ AckRelated 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.