Skill 详情
code-review
Language-agnostic structured code and PR review guidance.
使用前先检查
自动化审核只检查相关性,不代表安全审查或推荐。使用前请阅读来源中的说明。
SKILL.md
这段内容是审核时保存的快照。外部来源才是完整且最新的版本。
--- name: code-review description: "Provide structured code review guidance for catching defects and improving quality. This skill should be used when the user asks to 'review this code', 'check for issues', 'PR review', 'code quality check', or wants systematic code evaluation. Keywords: code review, PR, pull request, quality, defects, security, maintainability, performance." license: MIT compatibility: Works with any programming language. Integrates with github-agile for PR workflow. metadata: author: jwynia version: "1.0" type: diagnostic mode: evaluative domain: development --- # Code Review Diagnostic Systematic code review catches 60-90% of defects before production, reduces maintenance costs by 40%, and serves as effective knowledge transfer. This skill provides structured review guidance for both human reviewers and AI agents. ## When to Use This Skill Use this skill when: - Reviewing code before merge - Assessing code quality - Preparing code for PR submission - Self-reviewing before requesting review Do NOT use this skill when: - Writing new code (use implementation skills) - Designing architecture (use system-design) - Working on requirements (use requirements-analysis) ## Core Principle **Review effectiveness degrades sharply with PR size.** Under 400 lines: highest defect detection. 400-800 lines: 50% less effective. 800+ lines: 90% less effective. ## Quick Reference: Review Effectiveness | Factor | Optimal | Degraded | |--------|---------|----------| | PR size | < 400 lines | > 800 lines | | Review time | < 60 minutes | > 90 minutes | | Review speed | 200-400 LOC/hour | > 500 LOC/hour | | Reviewers | 2 | 4+ (diminishing returns) | ## Quality Pyramid | Level | Checks | Catches | Frequency | |-------|--------|---------|-----------| | 1. Automated | Lint, types, unit tests, security scan | 60% | Every commit | | 2. Integration | Integration tests, contracts, performance | 25% | Every PR | | 3. Human Review | Design, logic, maintainability, context | 15% | Significant changes | ## Review Focus Areas ### 1. Correctness **Questions:** - Does it solve the stated problem? - Are edge cases handled? - Is error handling complete? - Are assumptions valid? **Validation:** Test coverage, business logic, data integrity, concurrency handling ### 2. Maintainability **Questions:** - Is the code self-documenting? - Can it be easily modified? - Are abstractions appropriate? - Is complexity justified? **Indicators:** Clear naming, single responsibility, minimal coupling, high cohesion ### 3. Performance **Questions:** - Are there obvious bottlenecks? - Is caching appropriate? - Are queries optimized? - Is memory managed? **Red Flags:** N+1 queries, unbounded loops, synchronous I/O in async context, memory leaks ### 4. Security **Questions:** - Is input validated? - Are secrets protected? - Is authentication checked? - Are permissions verified? **Critical Checks:** No hardcoded secrets, SQL parameterized, XSS prevention, CSRF tokens ## Code Smells Checklist ### Method Level | Smell | Threshold | Action | |-------|-----------|--------| | Long method | > 50 lines | Extract method | | Long parameter list | > 5 params | Parameter object | | Duplicate code | > 10 similar lines | Extract common | | Dead code | Never called | Remove | ### Class Level | Smell | Symptoms | Action | |-------|----------|--------| | God class | > 1000 lines, > 20 methods | Split class | | Feature envy | Uses other class data excessively | Move method | | Data clumps | Same parameter groups | Extract class | ### Architecture Level | Smell | Detection | Action | |-------|-----------|--------| | Circular dependencies | Dependency cycles | Introduce interface | | Unstable dependencies | Depends on volatile modules | Dependency inversion | ## Comment Guidelines ### Comment Types **[BLOCKING]** - Must fix before merge - Security vulnerabilities, data corruption risks, breaking API changes **[MAJOR]** - Should fix before merge -在 GitHub 阅读完整来源 (打开外部页面)