Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计通过

python-backend-reviewerPython backend reviewer 搜索

Agent Skill

用于辅助 Python 项目开发、测试、依赖管理和常见框架工作流。它适合让 Agent 阅读 Python 代码、定位测试问题、整理运行命令、生成脚本或分析数据处理逻辑。使用时需要确认项目虚拟环境、依赖版本和测试入口;涉及执行脚本、读写文件、访问数据库或调用外部 API 时,应先明确运行目录和输入输出范围,避免误改生产数据。

总安装

196

周安装

8

GitHub Stars

95

下载量

63
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:python-backend-reviewer(Python backend reviewer 搜索)
来源仓库:https://github.com/qredence/agentic-fleet
仓库路径:skills/python-backend-reviewer
安装命令:
npx skills add https://github.com/qredence/agentic-fleet --skill python-backend-reviewer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/qredence/agentic-fleet --skill python-backend-reviewer

简介

用于 Python 后端代码的质量审查与改进建议。

  • 适合分析架构合理性、测试覆盖率和代码规范符合度。
  • 可识别潜在问题并提供修复方案或重构思路。python-backend-reviewer 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 安装方式:通过 GitHub 仓库部署,支持多种 AI 开发平台。
  • 涉及生产环境修改时,需提前备份数据并确认操作范围。

SKILL.md

Python Backend Code Reviewer

Expert analysis and refactoring of Python backend code to eliminate duplication, reduce complexity, and enforce best practices.

Overview

This skill helps identify and fix common issues in Python backend code, particularly problems introduced by AI code generation:

  • Duplicate code across multiple files
  • Recreated utilities instead of imports
  • Over-engineered solutions
  • High complexity functions and classes
  • Anti-patterns and code smells
  • Concurrency issues in async code (shared state mutation)

The skill provides automated analysis tools and comprehensive refactoring guidance.

⚠️ Architecture-Aware Prioritization

Static analysis finds issues, but architectural context determines priority.

Before prioritizing fixes, identify:

  1. Critical paths: Which code runs on every request?

- WebSocket/HTTP handlers - Main workflow orchestration - Shared services/middleware

  1. Secondary paths: Less critical code

- CLI tools - Scripts - Dev-only utilities - One-time migrations

  1. Concurrency model: How is state shared?

- Are handlers concurrent? - Are instances shared across requests? - Is there mutable singleton state?

Prioritization rule: Correctness in critical paths > Complexity in secondary paths

FindingCritical PathSecondary Path
Shared state mutation🔴 Fix immediately🟡 Review
High complexity (>25)🟡 Refactor carefully🟢 Backlog
Duplicates🟡 Extract if >3 occurrences🟢 Nice to have
God class🟡 Migrate to façade🟢 Low priority

Pragmatic Thresholds

For orchestration/workflow code, use realistic thresholds:

MetricStrict ThresholdPragmatic ThresholdNotes
Cyclomatic complexity1025Orchestrators naturally have decision points
Function length50 lines150 linesAsync flows can be longer
Nesting depth45Guard clauses help more than extracting
God class methods20N/AOK if it's a façade that delegates

Hard limits (always fix):

  • No functions > 300 lines
  • No nesting > 7 levels
  • No shared-state mutation without synchronization guard

Quick Start

1. Run Automated Analysis

Start with automated tools to identify issues:

# Detect duplicate code blocks
uv run python scripts/detect_duplicates.py <path>

# Analyze imports and utility reimplementation
uv run python scripts/analyze_imports.py <path>

# Check code complexity
uv run python scripts/complexity_analyzer.py <path>

# Check for concurrency issues (shared state mutation)
uv run python scripts/concurrency_analyzer.py <path>

2. Review Analysis Results

Each tool outputs:

  • Severity levels: Warnings (must fix) vs Info (should review)
  • File locations: Exact line numbers for each issue
  • Specific recommendations: What to change and why

3. Apply Fixes

Use the reference guides to refactor issues:

Main Workflows

Review a Python File

When a user asks to review a specific file:

  1. Run all analysis tools on the file: python scripts/detect_duplicates.py path/to/file.py python scripts/analyze_imports.py path/to/file.py python scripts/complexity_analyzer.py path/to/file.py
  2. Analyze results and categorize issues:

- Critical: Duplicates, high complexity, security issues - Important: Utility reimplementation, deep nesting - Minor: Style issues, minor inefficiencies

  1. Provide specific fixes:

- Quote exact code locations with line numbers - Show before/after examples - Explain why the change improves the code

  1. Offer to implement fixes if requested

Check Backend for Duplicates

When a user asks to check a project/module for duplicates:

  1. Run duplicate detection on the entire directory: python scripts/detect_duplicates.py src/
  2. Group duplicates by severity:

- High: 10+ lines duplicated, 3+ occurrences - Medium: 5-10 lines, 2+ occurrences - Low: Helper functions that could be extracted

  1. Recommend consolidation strategy:

- Extract to shared utilities for cross-cutting concerns - Create base classes for inherited behavior - Use decorators for repeated patterns

Analyze Module Over-Engineering

When code appears over-engineered:

  1. Run complexity analysis: python scripts/complexity_analyzer.py --max-complexity 10 --max-length 50 path/
  2. Identify over-engineering patterns:

- Premature abstractions (base classes with one implementation) - Excessive configuration options - God classes (20+ methods) - Deep inheritance hierarchies

  1. Suggest simplifications:

- Replace abstractions with simple functions - Remove unused configuration - Split god classes by responsibility - Flatten inheritance

  1. Reference specific patterns from python_antipatterns.md

Optimize Following Best Practices

When asked to optimize code or ensure best practices:

  1. Run all analysis tools to get baseline metrics
  2. Check against best practices:

- DRY principle violations - SOLID principle violations - Type hint coverage - Error handling patterns - Async/await consistency

  1. Prioritize optimizations:

- First: Correctness (bugs, security) - Second: Maintainability (duplicates, complexity) - Third: Performance (N+1 queries, inefficiencies) - Fourth: Style (naming, imports)

  1. Reference best_practices.md for specific guidelines

Analyze Concurrency Safety

When reviewing async code that handles concurrent requests:

  1. Run concurrency analysis: uv run python scripts/concurrency_analyzer.py services/ workflows/
  2. Prioritize by severity:

- Critical: Fix before production deployment - Warning: Review for actual sharing patterns - Info: Consider but often acceptable

  1. Common fixes for shared state mutation: # ❌ Before: Mutating shared instance state class Workflow: async def run(self, task): self.current_task = task # Race condition! # ✅ After: Request-scoped state class Workflow: async def run(self, task): execution = ExecutionContext(task=task) return await self._execute(execution)
  2. Alternative patterns:

- Pass state through parameters (preferred) - Use contextvars for request-scoped data - Use asyncio.Lock for truly shared state - Create new instances per request

Analysis Tools

detect_duplicates.py

Finds duplicate code blocks using AST analysis.

Usage:

uv run python scripts/detect_duplicates.py <path>
uv run python scripts/detect_duplicates.py --min-lines 10 <path>

Detects:

  • Duplicate functions (identical implementations)
  • Duplicate classes
  • Repeated code blocks

Options:

  • --min-lines N: Minimum lines for a block to be considered (default: 5)

analyze_imports.py

Analyzes import organization and detects recreated utilities.

Usage:

uv run python scripts/analyze_imports.py <path>

Detects:

  • Wildcard imports (from module import *)
  • Relative imports in non-package contexts
  • Functions that look like reimplemented utilities
  • Common patterns that should use libraries

Common utilities flagged:

  • JSON serialization → use json or orjson
  • Retry logic → use tenacity or backoff
  • Validation → use pydantic
  • HTTP clients → use requests or httpx

complexity_analyzer.py

Measures cyclomatic complexity, function length, and nesting depth.

Usage:

uv run python scripts/complexity_analyzer.py <path>
uv run python scripts/complexity_analyzer.py --max-complexity 10 --max-length 50 <path>

Metrics:

  • Cyclomatic complexity: Number of decision points (default threshold: 10)
  • Function length: Lines in function (default threshold: 50)
  • Nesting depth: Maximum levels of nested control structures (threshold: 4)
  • God classes: Classes with 20+ methods

Options:

  • --max-complexity N: Cyclomatic complexity threshold (default: 10)
  • --max-length N: Function length threshold (default: 50)

concurrency_analyzer.py

Detects concurrency issues in async Python code.

Usage:

uv run python scripts/concurrency_analyzer.py <path>

Detects:

  • Shared state mutation in async methods (self.x = y in async def)
  • Module-level mutable state (shared across requests)
  • Missing synchronization patterns
  • Potentially unsafe singleton patterns

Severity levels:

  • Critical: Mutation of shared state like client, session, agent, config
  • Warning: Any self.attr mutation in async context
  • Info: Module-level mutable objects

When to use: Run on services, handlers, and workflow code that handles concurrent requests.

Reference Documentation

python_antipatterns.md

Comprehensive catalog of anti-patterns with examples:

  • Code duplication patterns
  • Over-engineering examples
  • God objects
  • Complexity issues
  • Import problems
  • Error handling mistakes
  • Performance anti-patterns

Use when: You identify an issue but need to see the anti-pattern and solution

refactoring_patterns.md

Step-by-step refactoring techniques:

  • Extract function/variable
  • Consolidate duplicates
  • Simplify conditionals
  • Break up god classes
  • Reduce complexity
  • Improve imports

Use when: You know what's wrong and need concrete refactoring steps

best_practices.md

Python backend best practices and principles:

  • Core principles (DRY, SOLID)
  • Code organization
  • Type hints
  • Error handling
  • Async patterns
  • Database practices
  • API design
  • Security guidelines

Use when: Establishing coding standards or need authoritative guidance

Example Reviews

Example 1: Duplicate Validation Logic

User request: "Review this code for quality issues"

Analysis:

uv run python scripts/detect_duplicates.py api/

Finding: Email validation duplicated in 5 files

Recommendation:

# Extract to utils/validation.py
def validate_email(email: str) -> None:
    if not email or "@" not in email:
        raise ValueError("Invalid email")

# Import everywhere
from utils.validation import validate_email

Example 2: Recreated Retry Logic

User request: "Check if we're recreating utility functions"

Analysis:

uv run python scripts/analyze_imports.py services/

Finding: Custom retry logic in 3 services

Recommendation:

# Replace with tenacity
from tenacity import retry, stop_after_attempt, wait_exponential

@retry(stop=stop_after_attempt(3), wait=wait_exponential())
async def fetch_data(url: str):
    return await client.get(url)

Example 3: Complex Function

User request: "This function is hard to understand"

Analysis:

uv run python scripts/complexity_analyzer.py utils/processor.py

Finding: Complexity 23, nesting depth 6

Recommendation: Extract nested logic into helper functions (see refactoring_patterns.md)

When NOT to Refactor

⚠️ Avoid refactoring when:

  • No tests exist and can't be added
  • Close to deadline
  • Code won't be modified again
  • Would break public APIs without migration path

Output Format

When reviewing code, structure feedback as:

  1. Summary: Brief overview of findings
  2. Critical Issues: Must-fix problems (duplicates, security)
  3. Important Issues: Should-fix problems (complexity, utilities)
  4. Suggestions: Nice-to-have improvements
  5. Code Examples: Specific before/after for each issue
  6. Next Steps: Recommended action plan

Always include:

  • Exact file paths and line numbers
  • Severity level for each issue
  • Concrete code examples
  • References to patterns/practices when applicable

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenCode

29.47%
按下载量换算19

Antigravity

23.78%
按下载量换算15

windsurf

18.73%
按下载量换算12

Claude Code

11.49%
按下载量换算7

Gemini CLI

7.4%
按下载量换算5

Codex

2.95%
按下载量换算2

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills