review-django-commands
БесплатноБез исполняемых скриптовНе проверенReview Django management commands for proper structure and refactor if needed
от jpoutrin★ 16 звёзд на GitHubОб этом скилле
review-django-commands
Category: Django Development
Usage
/review-django-commands [<app-path>] [--fix] [--verbose]
Arguments
| Argument | Required | Description |
|---|---|---|
<app-path> |
No | Path to Django app or project (default: current directory) |
--fix |
No | Automatically refactor non-compliant commands |
--verbose |
No | Show detailed analysis for each command |
Purpose
Review Django management commands to ensure they follow the thin-command/service-layer pattern:
- Scans all management commands in the project
- Analyzes command structure for anti-patterns
- Reports compliance with best practices
- Refactors non-compliant commands (with
--fix)
Best Practice Pattern
Commands should be thin wrappers that delegate to services:
apps/{app}/
├── management/
│ └── commands/
│ └── {command_name}.py # Thin: parse args, call service, format output
└── services/
└── {domain}.py # Fat: business logic, DB operations
Good Pattern
# management/commands/publish_scheduled.py
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("--dry-run", action="store_true")
def handle(self, *args, **options):
result = publish_scheduled_articles(dry_run=options["dry_run"])
self.stdout.write(self.style.SUCCESS(f"Published {result.count} articles"))
# services/publishing.py
def publish_scheduled_articles(dry_run: bool = False) -> PublishResult:
"""Business logic lives here - testable without command scaffolding."""
...
Anti-Patterns to Detect
| Anti-Pattern | Description | Severity |
|---|---|---|
| Fat commands | Business logic in handle() |
HIGH |
| Direct ORM queries | Complex querysets in command | HIGH |
| Missing service layer | No corresponding service file | MEDIUM |
| No type hints | Missing return types, parameters | LOW |
| No docstrings | Missing command help text | LOW |
| Hardcoded values | Magic numbers/strings in logic | MEDIUM |
Execution Instructions for Claude Code
When this command is run, Claude Code should:
1. Parse Arguments
APP_PATH = first positional argument or "."
FIX_MODE = true if --fix specified
VERBOSE = true if --verbose specified
2. Find Management Commands
Scan for management command files:
find "$APP_PATH" -path "*/management/commands/*.py" -not -name "__init__.py"
3. Analyze Each Command
For each command file, analyze:
3.1 Command Structure Check
CHECKS = {
"thin_handle": {
"description": "handle() delegates to service",
"severity": "HIGH",
"check": "handle method < 30 lines, calls external function"
},
"no_orm_in_handle": {
"description": "No direct ORM queries in handle()",
"severity": "HIGH",
"check": "No Model.objects.* calls in handle()"
},
"service_exists": {
"description": "Corresponding service file exists",
"severity": "MEDIUM",
"check": "services/{domain}.py exists in same app"
},
"type_hints": {
"description": "Methods have type hints",
"severity": "LOW",
"check": "handle() has return type annotation"
},
"has_help": {
"description": "Command has help text",
"severity": "LOW",
"check": "help attribute or docstring defined"
},
"no_hardcoded": {
"description": "No hardcoded values in logic",
"severity": "MEDIUM",
"check": "No magic numbers/strings in handle()"
}
}
3.2 Complexity Metrics
Calculate:
- Lines of code in
handle()method - Number of ORM calls
- Cyclomatic complexity (if/for/while count)
- Number of external function calls
4. Report Results
Default Output
Django Command Review
=====================
Project: ./apps
Commands found: 5
Results:
apps/blog/management/commands/publish_scheduled.py: PASS
apps/blog/management/commands/cleanup_drafts.py: FAIL
- [HIGH] Fat command: handle() has 85 lines, should be < 30
- [HIGH] Direct ORM: 3 Model.objects.* calls in handle()
- [MEDIUM] No service: services/drafts.py not found
apps/users/management/commands/sync_users.py: WARN
- [LOW] No type hints on handle()
- [LOW] Missing help text
apps/orders/management/commands/process_orders.py: FAIL
- [HIGH] Fat command: handle() has 120 lines
- [HIGH] Direct ORM: 8 Model.objects.* calls
- [MEDIUM] Hardcoded values: found 3 magic numbers
Summary:
Passed: 2/5
Warnings: 1/5
Failed: 2/5
Run with --fix to refactor non-compliant commands.
Verbose Output (--verbose)
Django Command Review
=====================
=== apps/blog/management/commands/cleanup_drafts.py ===
Current Structure:
handle() lines: 85
ORM calls: 3
Complexity: 12
External calls: 0
Issues:
[HIGH] Fat command
Установить review-django-commands в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл review-django-commands?
Review Django management commands for proper structure and refactor if needed
Как установить скилл review-django-commands?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл review-django-commands запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic