跳到正文
cccskills
免费在 GitHub 公开

code-reviewer

Review code for quality, security, and performance with comprehensive feedback.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(3)

  • SKILL.md8.8 KB
  • review-checklist.md20.6 KB
  • security-patterns.md22.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Code Reviewer Skill

Purpose

This skill provides comprehensive code review guidance covering quality, security, performance, and style. It helps identify issues, suggest improvements, and ensure code meets project standards before committing.

Activation

On-demand via command: /review-code <file-path>

Example:

/review-code src/tools/example/core.py

When to Use

  • Self-review before committing
  • Refactoring existing code
  • Security concerns arise
  • Performance optimization needed
  • Ensuring style guide compliance
  • Code quality improvement
  • Pre-pull request review

Resources

review-checklist.md

Comprehensive code review checklist covering:

  • Code Quality: File organization, naming, type hints, docstrings, error handling
  • Testing: Coverage, quality, edge cases
  • Performance: Algorithm efficiency, memory usage, I/O optimization
  • Security: Input validation, authentication, authorization, data protection
  • Style: PEP 8 compliance, import organization, formatting

security-patterns.md

Security best practices including:

  • OWASP Top 10: Injection, authentication, XSS, etc.
  • Python-Specific Security: eval() usage, pickle security, SQL injection
  • Best Practices: Input validation patterns, secure authentication, data protection

Provides

Code Quality Feedback

  • File size enforcement (500-line limit)
  • Single responsibility principle adherence
  • Type hint completeness
  • Docstring quality (Google-style)
  • Error handling patterns
  • Naming convention compliance

Security Vulnerability Detection

  • Input validation issues
  • SQL injection vulnerabilities
  • XSS vulnerabilities
  • Authentication/authorization flaws
  • Sensitive data exposure
  • Insecure dependencies

Performance Optimization Suggestions

  • Algorithm efficiency improvements
  • Memory usage optimization
  • I/O operation optimization
  • Caching opportunities
  • Database query optimization

Refactoring Recommendations

  • Code duplication removal
  • Complexity reduction
  • Design pattern applications
  • Dependency injection improvements
  • Interface clarity

Style Guide Compliance Checks

  • PEP 8 for Python
  • Import organization
  • Code formatting
  • Comment quality
  • Documentation completeness

Usage Examples

Example 1: Review Python Module

/review-code src/tools/doc_fetcher/core.py

Provides feedback on:

  • Function complexity and size
  • Type hints and docstrings
  • Error handling
  • Security concerns (if any)
  • Performance bottlenecks
  • Style violations

Example 2: Security-Focused Review

/review-code src/api/authentication.py

Focuses on:

  • Authentication patterns
  • Password handling
  • Session management
  • Input validation
  • Authorization checks
  • Token security

Example 3: Performance Review

/review-code src/processors/data_processor.py

Analyzes:

  • Algorithm complexity
  • Memory allocation
  • I/O operations
  • Caching strategy
  • Database queries
  • Batch processing opportunities

Review Categories

1. Code Quality (⭐⭐⭐⭐⭐ Essential)

File Organization

  • ✓ File size ≤ 500 lines
  • ✓ Logical module structure
  • ✓ Clear separation of concerns
  • ✓ Appropriate file naming

Naming Conventions

  • ✓ Descriptive variable names
  • ✓ Clear function names (verb_noun pattern)
  • ✓ Class names (PascalCase)
  • ✓ Constants (UPPER_CASE)
  • ✓ Private members (_prefix)

Type Hints

  • ✓ All function parameters typed
  • ✓ All return types specified
  • ✓ Complex types properly annotated
  • ✓ Optional types used correctly

Docstrings

  • ✓ Google-style format
  • ✓ Clear description
  • ✓ Args documented
  • ✓ Returns documented
  • ✓ Raises documented

Error Handling

  • ✓ Appropriate exception types
  • ✓ Error messages clear
  • ✓ No bare except clauses
  • ✓ Cleanup in finally blocks

2. Testing (⭐⭐⭐⭐ Important)

Test Coverage

  • ✓ 80%+ code coverage
  • ✓ All public functions tested
  • ✓ Edge cases covered
  • ✓ Error paths tested

Test Quality

  • ✓ Clear test names
  • ✓ Arrange-Act-Assert pattern
  • ✓ Independent tests
  • ✓ Appropriate fixtures

3. Performance (⭐⭐⭐ Moderate)

Efficiency

  • ✓ Optimal algorithm complexity
  • ✓ No unnecessary loops
  • ✓ Efficient data structures
  • ✓ Batch operations where possible

Resource Usage

  • ✓ Memory-efficient
  • ✓ File handles closed
  • ✓ Database connections managed
  • ✓ No resource leaks

Optimization

  • ✓ Caching implemented
  • ✓ Lazy loading used
  • ✓ Async for I/O operations
  • ✓ Query optimization

4. Security (⭐⭐⭐⭐⭐ Critical)

Input Validation

  • ✓ All inputs validated
  • ✓ Type checking
  • ✓ Range checking
  • ✓ Sanitization

Authentication & Authorization

  • ✓ Strong authentication
  • ✓ Proper authorization
  • ✓ Session management
  • ✓ Token validation

Data Protection

  • ✓ No secrets in code
  • ✓ Sensitive data encrypted
  • ✓ SQL parameterized
  • ✓ Output encoding

OWASP Top 10

  • ✓ Injection prevention
  • ✓ Broken auth prevention
  • ✓ XSS prevention
  • ✓ Access control
  • ✓ Security misconfiguration

5. Style (⭐⭐⭐ Moderate)

PEP 8 Compliance

  • ✓ Line length ≤ 88 characters
  • ✓ Indentation (4 spaces)
  • ✓ Blank line usage
  • ✓ Whitespace around operators

Import Organization

  • ✓ Grouped (stdlib, third-party, local)
  • ✓ Alphabetically sorted
  • ✓ No unused imports
  • ✓ Absolute imports preferred

Code Formatting

  • ✓ Black-formatted
  • ✓ Consistent style
  • ✓ Readable layout
  • ✓ Appropriate comments

Review Output Format

# Code Review: <file-path>

## Summary
[Brief overview of file purpose and key findings]

## Quality Score: X/10
[Overall quality score with justification]

## Critical Issues (Must Fix)
- [Issue 1 with location and recommendation]
- [Issue 2 with location and recommendation]

## Important Issues (Should Fix)
- [Issue 1 with location and recommendation]
- [Issue 2 with location and recommendation]

## Suggestions (Consider)
- [Suggestion 1 with rationale]
- [Suggestion 2 with rationale]

## Strengths
- [Positive aspect 1]
- [Positive aspect 2]

## Detailed Analysis

### Code Quality
[Detailed quality assessment]

### Security
[Security assessment and concerns]

### Performance
[Performance analysis]

### Testing
[Test coverage and quality]

### Style
[Style guide compliance]

## Recommendations
1. [Priority 1 recommendation]
2. [Priority 2 recommendation]
3. [Priority 3 recommendation]

## Next Steps
[Suggested actions for improvement]

Best Practices

Constructive Feedback

  • Focus on code, not person
  • Explain "why" behind suggestions
  • Provide specific examples
  • Offer alternative solutions
  • Acknowledge good practices

Priority Levels

  • Critical: Security vulnerabilities, bugs, data loss
  • Important: Poor performance, missing tests, unclear code
  • Suggestions: Style improvements, refactoring opportunities

Context Awareness

  • Consider project stage (prototype vs. production)
  • Respect project conventions
  • Balance perfection with pragmatism
  • Focus on impactful improvements

Common Issues to Check

Python-Specific

  • Using eval() or exec() unsafely
  • Mutable default arguments
  • Catching Exception too broadly
  • Not using context managers for resources
  • String concatenation in loops
  • Missing init.py in packages
  • Incorrect use of class variables
  • Not using generators for large datasets

General Issues

  • Magic numbers (use constants)
  • Deeply nested code (>3 levels)
  • Long functions (>50 lines)
  • Duplicate code
  • Unclear variable names
  • Missing error handling
  • No input validation
  • Hard-coded credentials

Integration with Development Workflow

Pre-Commit Review

Use this skill before committing:

/review-code <file-you-modified>

Pre-Pull Request Review

Review all changed files:

git diff --name-only main | xargs -I {} /review-code {}

Refactoring Review

After refactoring, verify improvements:

/review-code <refactored-file>

Notes

  • Guidance Only: This skill provides review feedback and guidance. It does not automatically fix issues.
  • Comprehensive: Reviews cover multiple dimensions (quality, security, performance, style).
  • Actionable: Feedback includes specific recommendations and examples.
  • Project-Aware: Considers project-specific standards and conventions.

Used When

  • Before committing changes
  • During code refactoring
  • When security review is needed
  • For performance optimization
  • To ensure style compliance
  • Pre-pull request submission
  • Learning best practices
  • Mentoring code quality

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Validate WCAG 2.1 Level AA compliance and accessibility best practices. Use when performing accessibility audits and WCAG certification.

中文简介正在准备中。当前显示原文说明。

matteocervelli/llms252026年5月22日 更新

analysis

免费

Analyze feature requirements, dependencies, and security considerations. Use when starting feature implementation from GitHub issues to understand scope, technical feasibility, and risks.

中文简介正在准备中。当前显示原文说明。

matteocervelli/llms252026年5月22日 更新

analytics

免费

Run SQL queries against psql, BigQuery, or MySQL from the terminal, including natural-language-to-SQL and schema exploration. Use when analyzing data, inspecting DB state, or debugging tables. Trigger on "query the database", "SQL", "show me data from", "explore table".

中文简介正在准备中。当前显示原文说明。

matteocervelli/llms252026年5月22日 更新

Design REST APIs or function contracts with clear request/response specifications, error handling patterns, authentication strategies, and comprehensive documentation.

中文简介正在准备中。当前显示原文说明。

matteocervelli/llms252026年5月22日 更新

Generate comprehensive API endpoint tests for REST and GraphQL APIs. Creates tests for all HTTP methods, status codes, authentication, and validation.

中文简介正在准备中。当前显示原文说明。

matteocervelli/llms252026年5月22日 更新

Design component architecture and module structure using established architectural patterns for clean, maintainable, and scalable systems.

中文简介正在准备中。当前显示原文说明。

matteocervelli/llms252026年5月22日 更新

查看 matteocervelli 的全部技能

报告此技能的问题