Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

python-backend-reviewer

БесплатноЗапускает вложенные скриптыНе проверен

Expert Python backend code reviewer that identifies over-complexity, duplicates, bad optimizations, and violations of best practices. Use when asked to review…

Qredenceот Qredence★ 112 звёзд на GitHub42 установки в других каталогах

Об этом скилле

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
  2. Secondary paths: Less critical code

    • CLI tools
    • Scripts
    • Dev-only utilities
    • One-time migrations
  3. 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

Finding Critical Path Secondary 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:

Metric Strict Threshold Pragmatic Threshold Notes
Cyclomatic complexity 10 25 Orchestrators naturally have decision points
Function length 50 lines 150 lines Async flows can be longer
Nesting depth 4 5 Guard clauses help more than extracting
God class methods 20 N/A OK 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
  3. Provide specific fixes:

    • Quote exact code locations with line numbers
    • Show before/after examples
    • Explain why the change improves the code
  4. 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
  3. Recommend consolidation strategy:

    • Extract to shared utilities for cross-cutting concerns
    • Create base classes for inherited behavi
Полный SKILL.md на GitHub

Установить python-backend-reviewer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/best_practices.mdreferences/python_antipatterns.mdreferences/refactoring_patterns.mdscripts/analyze_imports.pyscripts/complexity_analyzer.pyscripts/concurrency_analyzer.pyscripts/detect_duplicates.py

FAQ

Что делает скилл python-backend-reviewer?

Expert Python backend code reviewer that identifies over-complexity, duplicates, bad optimizations, and violations of best practices. Use when asked to review Python code quality, check for duplicate code, analyze module complexity, optimize backend code, identify anti-patterns, or ensure adherence to best practices. Ideal for preventing AI-generated code from creating unnecessary files instead of imports, finding repeated validation logic, and catching over-engineered solutions.

Как установить скилл python-backend-reviewer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл python-backend-reviewer запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить python-backend-reviewer с