1---2name: python-code-review3description: Python Code Review4---5# Python Code Review67## Workflow81. Verify `AGENTS.md`, `docs/REPO_STYLE.md`, `docs/PYTHON_STYLE.md`, and `docs/CHANGELOG.md` exist.92. Read those files and summarize repo rules in four one-sentence lines with prefixes:10`AGENTS:`, `REPO_STYLE:`, `PYTHON_STYLE:`, `CHANGELOG:`.113. Inspect changed files first (`git diff`, `git status --short`), then inspect related call sites.124. If the repo has `docs/active_plans/`, identify the active plan document(s) that govern the change. Otherwise, skip plan-conformance steps.135. If an active plan exists, map code and tests to plan requirements, acceptance criteria, and stated constraints. Otherwise, skip this step.146. Prioritize findings by severity: plan mismatch/regressions (if applicable), correctness/safety, then maintainability.157. Provide concrete, minimal fixes with before/after examples when a fix is straightforward.168. Flag uncertainty explicitly and ask targeted review questions for unclear logic or contracts.1718## Review Output Contract19- Report findings first, ordered by severity.20- For each finding include:21 - Severity (`P1` critical, `P2` high, `P3` medium, `P4` low)22 - File path and line reference23 - Risk and likely impact24 - Recommended change25- After findings, include:26 - Open questions27 - Test gaps and residual risk28 - Brief summary2930## What To Check31- Plan conformance: implementation and tests match active plan scope, ordering, and acceptance criteria.32- Plan drift: behavior changed without corresponding plan/changelog updates, or plan claims complete while code is partial.33- Correctness: edge cases, off-by-one logic, stale assumptions, API misuse, compatibility breaks.34- Security: unsafe eval/exec, command injection, path traversal, deserialization hazards, weak validation.35- Maintainability: dead code, hidden coupling, unclear naming, duplicated logic, brittle tests.36- Performance only when materially relevant.3738## Fix Guidance39- Prefer small, local edits that preserve behavior unless a bug requires behavior change.40- Keep fixes aligned with repo Python style and test conventions.41- Add or adjust tests for each behavior-changing fix.