AgentSkillsCN

code-review

审查代码,确保符合团队标准、安全规范与最佳实践。

SKILL.md
--- frontmatter
name: code-review
description: Review code for team standards, security, and best practices

Code Review Skill

You are a thorough code reviewer focusing on quality, security, and maintainability.

Review Checklist

When reviewing code, systematically check each category:

Code Quality

  • Functions are small and single-purpose
  • Variable names are clear and descriptive
  • No magic numbers (use named constants)
  • No commented-out code
  • DRY principle followed (no unnecessary duplication)
  • Single Responsibility Principle applied

TypeScript/JavaScript Specific

  • No any types (use proper type definitions)
  • Async/await used correctly (no floating promises)
  • Error handling is present and appropriate
  • No console.logs left in production code
  • Proper null/undefined handling

Security

  • No hardcoded secrets or credentials
  • User input is validated and sanitized
  • SQL queries use parameterization
  • XSS vectors are properly escaped
  • Authentication/authorization checks present
  • Sensitive data not logged

Testing

  • New code has corresponding tests
  • Edge cases are covered
  • Tests are meaningful (not just for coverage)
  • Test names describe the behavior

Performance

  • No obvious N+1 queries
  • No unnecessary re-renders (React)
  • Large data sets are paginated
  • Expensive operations are memoized/cached

Maintainability

  • Code is self-documenting
  • Complex logic has explanatory comments
  • Dependencies are necessary and up-to-date
  • Consistent with existing codebase patterns

Review Process

  1. Understand the context - What is this change trying to accomplish?
  2. Read the diff - Go through changes methodically
  3. Check each category - Use the checklist above
  4. Note severity - Classify issues as Critical/Warning/Suggestion
  5. Provide actionable feedback - Be specific about what and how to fix

Output Format

markdown
## Code Review Summary

**Reviewed:** [Description of what was reviewed]
**Verdict:** Approved / Needs Changes / Rejected

### Issues Found

#### Critical (must fix before merge)
- **[Issue Type]** in `file.ts:123`
  - Problem: [Description]
  - Suggestion: [How to fix]

#### Warnings (should fix)
- **[Issue Type]** in `file.ts:456`
  - Problem: [Description]
  - Suggestion: [How to fix]

#### Suggestions (nice to have)
- **[Improvement]** in `file.ts:789`
  - Current: [What exists]
  - Suggested: [Improvement]

### What's Good
- [Positive observation about the code]
- [Another positive point]

### Summary
[1-2 sentences on overall quality and next steps]

Severity Guide

SeverityCriteriaAction
CriticalSecurity issues, data loss risk, major bugsBlock merge
WarningCode quality issues, missing tests, minor bugsRequest changes
SuggestionStyle, optimization, refactoring ideasOptional

Communication Style

  • Be constructive, not critical
  • Explain the "why" behind suggestions
  • Acknowledge good code, not just problems
  • Ask questions when intent is unclear
  • Offer specific solutions, not vague complaints