skills/python-doctor/SKILL.md
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.
npx skillsauth add ragnarok22/agent-skills python-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 Python 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.
exceptexcept Exception with weak handlingassert used for runtime validationNone with equality operatorssuper().__init__() callsis used for value comparison__init__.py for packagespyproject.toml, setup.cfg, setup.py, or requirements*.txt)..git, virtualenv directories, build artifacts, generated files, and vendored code.Runtime execution safety gate (mandatory):
Execution mode selection (mandatory):
<PY_CMD> using project cues in this order:
poetry run python when Poetry is used (poetry.lock or [tool.poetry] in pyproject.toml).uv run python when uv is used (uv.lock).pipenv run python when Pipenv is used (Pipfile).python (or python3) as fallback.<PY_CMD> in the report.From the project root, only after explicit approval, run these checks when prerequisites are present:
<PY_CMD> -m compileall -q .
<PY_CMD> -m pytest -q
<PY_CMD> -m ruff check .
<PY_CMD> -m mypy .
Runtime check rules:
compileall: always attempt.pytest: run only when test suite and pytest are present.ruff: run only when Ruff appears configured or installed.mypy: run only when MyPy appears configured or installed.SKIPPED (not configured or unavailable).Capture full output and summarize pass/fail status in the report.
If runtime checks are skipped due to trust or approval, mark each 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:
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:
## Python 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: `<PY_CMD>` (or `SKIPPED`)
### Runtime Checks
- compileall: [PASS/FAIL/SKIPPED + short summary]
- pytest -q: [PASS/FAIL/SKIPPED + short summary]
- ruff check: [PASS/FAIL/SKIPPED + short summary]
- mypy: [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
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.
development
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.