name: code-review description: Performs a structured engineering code review focusing on design quality, coupling, performance (especially mobile), and maintainability. Use when the user asks to review code, 检查代码, 审阅代码, 代码评估, or analyze code design/quality.
Code Review
When to Use
Use this skill when the user asks to:
- review code
- 检查代码
- 审阅代码
- 代码评估 / code review
- 分析代码设计或质量
The user may provide:
- a code snippet
- a full file
- a git diff
- a description of the code structure
If no code is provided, ask the user to provide the code or file path before proceeding.
Review Goals
The goal is not just correctness, but overall engineering quality.
Focus on:
- design rationality
- coupling clarity
- mobile‑friendly performance
- maintainability and extensibility
- readability
Provide actionable suggestions, not vague comments.
Review Dimensions
1. Design Rationality
Check whether the architecture and responsibilities are reasonable.
Questions:
- Does each module/class have a single responsibility?
- Is the abstraction level appropriate?
- Is there unnecessary complexity or over‑engineering?
- Are responsibilities clearly separated?
Problems to flag:
- God classes
- functions doing too many things
- unclear module boundaries
2. Coupling and Dependency Clarity
Check whether dependencies are explicit and controllable.
Look for:
- hidden global state
- implicit dependencies
- circular dependencies
- tight coupling between modules
Prefer:
- dependency injection
- clear interfaces
- modular boundaries
Example problem: global state modifying behavior across modules without explicit dependency.
3. Performance Awareness (Especially Mobile)
Check for common performance risks.
CPU: heavy computation on main thread, unnecessary loops, repeated calculations.
Memory: large object allocations in loops, unnecessary copies, memory leaks.
IO / Resources: large resources loaded at once, blocking network or disk operations.
For UI or game: check update loops, avoid per-frame allocations and expensive operations in hot paths.
4. Maintainability
Evaluate whether future engineers can easily modify the code.
Check: naming clarity, file/module structure, readability, duplication of logic.
Prefer: clear names, modular code, reusable components.
Flag: magic numbers, unclear naming, duplicated code blocks.
5. Extensibility
Check whether the code can evolve without major rewrites.
Look for: rigid design, tightly coupled logic, missing extension points.
Prefer: configuration over hardcoding, modular design, open‑closed principle.
Output Format
Overall Assessment
Short summary: overall design (Good / Acceptable / Needs Improvement), main risks (performance, coupling, maintainability).
Key Issues
List the most important problems first. For each:
- Problem
- Why it matters
- Suggested improvement
Example:
- Problem: Function mixes networking and data parsing.
- Why it matters: Violates single responsibility and complicates testing.
- Suggestion: Split networking logic and parsing into separate modules.
Improvement Suggestions
Concrete improvements: refactoring, architectural adjustments, performance optimizations. Include small code examples if helpful.
Positive Aspects
Highlight what the code does well: good modular design, efficient logic, good naming.
Review Quality Checklist
Before finishing, ensure:
- The review covers design, coupling, performance, and maintainability.
- Each problem includes a suggested improvement.
- The review prioritizes the most important issues first.
- Feedback is clear and actionable.