plugins/development-harness/skills/code-review-python/SKILL.md
Provides Python-specific code review rules for the dh code-reviewer agent. Activates on pyproject.toml or *.py file detection — enforces uv, ruff, ty, pytest, type annotation, error handling, and Python 3.11+ idioms including pathlib, match statements, and modern union syntax.
npx skillsauth add jamie-bitflight/claude_skills code-review-pythonInstall 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.
Stack-specific rules loaded by dh:code-reviewer when pyproject.toml or *.py files are detected.
Any is only acceptable with an inline comment explaining why a specific type cannot be usedTypedDict is required for dicts that cross module boundaries; plain dict[str, ...] is only acceptable within a single functionOptional[X] is legacy — use X | None (Python 3.10+ union syntax)Union[X, Y] is legacy — use X | YNone must be explicit on functions that have no return value but have side effectsexcept: is a blocking finding — must be except ExceptionType:print() in library code (non-CLI, non-script) is a blocking finding (T201) — use logging instead% and .format() are legacy__all__ must be defined in modules that have public API surfaceuv add — fix the import, not the type checker# ty: ignore suppressions are prohibited — fix the code to satisfy tyty extra-paths in pyproject.toml must stay in sync with pytest pythonpathtest_<what>_when_<condition>_returns_<result> or test_<what>_when_<condition>_raises_<exception>assert result is not None is not a meaningful assertion — assert the actual expected value@pytest.mark.parametrizesrc/foo/bar.py → tests/foo/test_bar.pyuv run — bare python invocations are only acceptable in CI where the venv is pre-activateduv add — manual edits to pyproject.toml dependencies without running uv add leave the lockfile stale# /// script) and also add those deps via uv add --dev for IDE toolinguv run --script is used for standalone scripts with PEP 723 metadataexcept Exception: is a blocking finding unless immediately followed by a re-raise or very specific loggingexcept blocks are a blocking finding — they swallow all errors silentlyraise ValueError(f"Expected positive int, got {value!r}") not raise ValueError("invalid input")None or -1 on error without raising) require a documented contract — silence must be intentional and documentedmatch statements are preferred for multi-branch dispatch on type or value (over long if/elif chains)pathlib.Path is required for all file path operations — os.path is legacytomllib (stdlib in 3.11+) is used for reading TOML — do not add tomli as a dependencydatetime.UTC is used instead of datetime.timezone.utc (Python 3.11+)ExceptionGroup and except* are used for concurrent exception handling where appropriatestr.removeprefix() and str.removesuffix() replace manual slicing for prefix/suffix removal# WRONG: bare except
try:
do_thing()
except:
pass
# RIGHT: narrow except with action
try:
do_thing()
except ConnectionError as e:
logger.warning("Connection failed: %s", e)
raise
# WRONG: magic number
if status == 429:
...
# RIGHT: named constant
HTTP_TOO_MANY_REQUESTS = 429
if status == HTTP_TOO_MANY_REQUESTS:
...
# WRONG: os.path
import os
path = os.path.join(base, "config.toml")
# RIGHT: pathlib
from pathlib import Path
path = Path(base) / "config.toml"
development
When an application needs to store config, data, cache, or state files. When designing where user-specific files should live. When code writes to ~/.appname or hardcoded home paths. When implementing cross-platform file storage with platformdirs.
testing
Enforce mandatory pre-action verification checkpoints to prevent pattern-matching from overriding explicit reasoning. Use this skill when about to execute implementation actions (Bash, Write, Edit) to verify hypothesis-action alignment. Blocks execution when hypothesis unverified or action targets different system than hypothesis identified. Critical for preventing cognitive dissonance where correct diagnosis leads to wrong implementation.
tools
Reference guide for the Twelve-Factor App methodology — 15 principles (12 original + 3 modern extensions) for building portable, resilient, cloud-native applications. Use when evaluating application architecture, designing cloud-native services, reviewing codebases for methodology compliance, advising on configuration, scaling, observability, security, and deployment patterns. Incorporates the 2025 open-source community evolution and cloud-native reinterpretations of each factor.
tools
Converts user-facing documentation (how-to guides, tutorials, API references, examples) in any format — Markdown, PDF, DOCX, PPTX, XLSX, AsciiDoc, RST, HTML, Jupyter notebooks, man pages, TOML/YAML/JSON configs, and plain text — into Claude Code skill directories with SKILL.md plus thematically grouped references/*.md files. Use when given a docs directory or mixed-format documentation to transform into an AI skill. Uses MCP file-reader server for binary formats.