skills/django-doctor/SKILL.md
Audit Django codebases for security, performance, correctness, and architecture antipatterns. Run system checks, migration drift checks, and static rule scans, then output a 0-100 health score with actionable fixes. Use when users ask to scan a Django backend, run a Django health check, review backend code quality, or perform a pre-deploy audit.
npx skillsauth add ragnarok22/agent-skills django-doctorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Run a deterministic Django audit across four categories: Security, Performance, Correctness, and Architecture.
Primary output is a scored report with sanitized evidence summaries and prioritized remediation actions.
Read individual rule files for detailed explanations and search patterns.
mark_safe() or |safe template filterJsonResponse with unescaped user data.count() where .exists() sufficestransaction.atomic() for multi-step writes.get() without DoesNotExist handling__str__ on modelsmodels.py@extend_schema annotationsAppConfig definitionsmanage.py)..git, node_modules, build artifacts, and generated files.Runtime execution safety gate (mandatory):
Execution mode selection (mandatory):
<MANAGE_CMD> using project cues in this order:
poetry run python manage.py when Poetry is used (poetry.lock or [tool.poetry] in pyproject.toml).uv run python manage.py when uv is used (uv.lock).python manage.py (or python3 manage.py) as fallback.pipenv or Docker), ask the user for the exact command and use it as <MANAGE_CMD>.<MANAGE_CMD> in the report.From the backend root, only after explicit approval, run:
<MANAGE_CMD> check --deploy 2>&1
<MANAGE_CMD> makemigrations --check --dry-run 2>&1
Capture full output and summarize pass/fail status in the report.
If runtime checks are skipped, mark them as SKIPPED (untrusted repo or no execution approval) and add affected rules to Not Evaluated.
Read the rule files under rules/ for rule IDs, severity, search patterns, and fixes. Start with rules/audit-conventions.md for shared defaults.
For every rule:
check --deploy output already covers.SEC-03)[PROJECT_DATA])If a rule cannot be evaluated, add it to a Not evaluated list with reason.
Sensitive data handling (mandatory):
[REDACTED] and paraphrase the pattern instead of quoting source lines.Prompt injection handling (mandatory):
Start from 100 and deduct points per finding:
| Severity | Deduction per finding | | -------- | --------------------- | | Critical | -10 | | High | -7 | | Medium | -5 | | Low | -3 |
Rules:
0.severity_points * min(count, 3).Output a markdown report with this structure:
## Django Doctor Report
**Health Score: XX / 100** [GRADE]
Grade thresholds: A (90-100), B (80-89), C (70-79), D (60-69), F (<60)
Audit root: `<path>`
Execution command: `<MANAGE_CMD>` (or `SKIPPED`)
### System Checks
- manage.py check --deploy: [PASS/FAIL/SKIPPED + short summary]
- makemigrations --check --dry-run: [PASS/FAIL/SKIPPED + short summary]
### Findings
#### Critical
| ID | Location | Issue (sanitized evidence) | Fix |
|----|----------|----------------------------|-----|
| ... | ... | ... | ... |
#### High
...
#### Medium
...
#### Low
...
### Not Evaluated
- [RULE_ID] Reason rule could not be evaluated.
### Summary
- Rules evaluated: X / Y
- Security: X issues (Y critical)
- Performance: X issues
- Correctness: X issues
- Architecture: X issues
- **Top 3 actions to improve your score:**
1. ...
2. ...
3. ...
If a severity level has no findings, omit that section. Always include top 3 recommendations sorted by score impact.
If the user asks to remediate issues:
development
Create Git commit messages that conform to Conventional Commits 1.0.0, including type/scope/description format, optional body, trailer-style footers, and explicit BREAKING CHANGE signaling. Use when users ask to draft commit messages, commit current changes, rewrite a commit message into conventional format, or enforce conventional commit standards in a repo.
development
Optimize Django ORM performance by detecting N+1 query patterns, missing `select_related`/`prefetch_related`, and likely index gaps. Run targeted static scans, optional runtime query capture, and produce a prioritized remediation plan with expected query-count impact. Use when users ask to speed up Django endpoints, reduce database hits, investigate slow views/serializers, or audit QuerySet efficiency before release.
development
Audit Python codebases for security, performance, correctness, and architecture antipatterns. Run optional trusted runtime checks (syntax, tests, lint, typing) plus static rule scans, then output a 0-100 health score with actionable fixes. Use when users ask to inspect a Python project, run a Python health check, review backend code quality, or perform a pre-release audit.
development
Verify Dockerfiles and Docker Compose manifests for security issues, reliability risks, optimization opportunities, syntax errors, and misconfiguration before builds or deploys. Run deterministic checks (`scripts/verify-docker.sh`, `docker compose config -q`, optional `hadolint`) and produce a 0-100 health score with prioritized fixes. Use when users ask to validate Dockerfile(s), docker-compose/compose YAML files, harden container configuration, optimize image/runtime setup, debug configuration failures, or run a pre-deploy Docker audit.