AgentSkillsCN

python-code-review

提供生产级别的 Python 代码审查服务。适用于代码评审、Pull Request 审核,或代码质量分析。从架构、安全性、质量、测试、文档、部署以及一致性等多个维度进行全面检查,并针对各类问题给出严重程度评级与修复建议。

SKILL.md
--- frontmatter
name: python-code-review
description: Production-grade Python code review. Use when reviewing code, PRs, or analyzing code quality. Checks architecture, security, quality, testing, documentation, deployment, and consistency. Provides severity-rated issues with fix suggestions.

Python Code Review

Systematic code review with actionable feedback organized by severity.

Process

  1. Gather context

    bash
    git diff --name-only main
    git diff main
    git log main..HEAD --oneline
    
  2. Run automated checks

    bash
    ruff check --output-format=json <files>
    vulture --min-confidence=80 <files>
    mypy <files>
    
  3. Apply review checklists - see references below

  4. Generate report with issues and fix plan

Severity Levels

LevelDefinitionAction
CriticalSecurity flaws, data loss, breaking changesBlocks merge
HighResource leaks, wrong layer, N+1 queriesFix before merge
ModerateMissing tests, complexity >10, swallowed exceptionsShould address
LowStyle beyond linter, minor refactoringOptional

Review Categories

Apply these checklists to changed files:

  1. Architecture - Layer violations, dependency direction, god classes

  2. Security - Injection, secrets, path traversal, deserialization

  3. Quality - Complexity, error handling, performance

  4. Testing - Coverage, assertions, isolation, fixtures

  5. Documentation - Docstrings, README accuracy

  6. Deployment - Dockerfile, Helm, migrations

  7. Consistency - Code-docs sync, signature matches

Output Format

markdown
# Code Review Report

**Status**: PASS | NEEDS_WORK | BLOCKED

## Issues
| Severity | Count |
|----------|-------|
| Critical | N |

### [Category]
- [severity] file:line - description
  - Fix: specific suggestion

## Fix Plan
1. [Issue] - [Action]

Principles

  • Be specific: "Add try/except at line 42" not "improve error handling"
  • Verify first: Check functions exist before suggesting them
  • Focus on changes: Don't refactor untouched code
  • Provide working examples