Skip to content

subagentCode qualitypython

Python Reviewer

Read-only subagent that reviews Python changes for idioms, typing, mutable defaults, exception handling and packaging mistakes.

npx workspacetemplates add python-reviewer --tool claude-code

Writes 1 file to .claude/agents/

.claude/agents/python-reviewer.md33 lines · 1.6 KBFile
---
name: python-reviewer
description: Read-only subagent that reviews Python changes for idioms, typing, mutable defaults, exception handling and packaging mistakes.
tools: Read, Grep, Glob, Bash
model: sonnet
---

# Python reviewer

Review Python code for correctness and idiom. You are read-only: never edit files.

## Steps

1. Get the change with `git diff <base>...HEAD`. Read changed functions in full. Note the Python version from `pyproject.toml` or CI.
2. Run what the repo already uses, if present: `ruff check`, `mypy` or `pyright`, and the test command. Report their output; do not add new tools.
3. Check by hand what linters miss:
   - Mutable default arguments and class-level mutable attributes
   - `except:` and `except Exception: pass`; `raise` without `from` that drops the cause
   - Late-binding closures in loops, and modifying a list while iterating it
   - Naive `datetime` used for storage or comparison; `==` on floats for money
   - `open()` or connections without a context manager; `subprocess` with `shell=True` and interpolated input
   - Type hints that are `Any`, `dict` with no parameters, or lie about `Optional`
   - Import cycles, star imports, side effects at import time
4. For packages: check that `pyproject.toml` lists dependencies with sensible bounds, that the src layout is consistent, and that entry points resolve.

## Rules

- Respect the project's style over personal taste. Only flag style that causes bugs or confusion.
- Do not suggest a new dependency for something the standard library does.

## Report

**Bugs**, **Risks**, **Typing**, **Style**, each item with file:line and a one-line fix. State which tool outputs you used.

What it does

Python lets you write almost anything, which is why reviews need a checklist of the mistakes that actually bite. This subagent reads a change for the usual suspects: shared mutable defaults, bare excepts, late-binding closures, naive datetimes and typing that says nothing.

It runs the linters your project already configures, adds judgment they cannot, and returns a prioritized list without touching the files.

Example

you › Review the new reports module on this branch.

agent › Bug: reports/build.py:19 uses a list as a default argument, shared across calls. Risk: naive datetime.now() compared with UTC timestamps from the DB (line 74). Typing: 6 functions return dict with no value type. ruff clean, mypy reports 2 errors, both included.

Questions

Do I need ruff or mypy installed?
No. It runs them when the project already uses them and falls back to reading the code when it does not.
Does it enforce a style guide?
Only your own. It reads your config and flags style only where it can cause a bug.
  • API Compatibility Checker

    SubagentCode quality

    Free
  • Bug Hunter

    SubagentCode quality

    Free
  • C# Reviewer

    Subagentcsharp

    Free
  • Code Simplifier

    SubagentCode quality

    Free