python-review

A command that reviews changed Python files for style, type-safety, security problems, and common Python mistakes. PEP 8 is a widely used set of Python style guidelines, and type hints describe expected value types.

In plain words
What is it for?
Use it after changing Python code to run linting, type checks, formatting checks, security checks, and a severity-ranked review.
Why use it?
It gathers several checks into one review, helping find defects and unsafe code before a commit or pull request.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/rohitbind123/claude-setup/python-review
Clone the repo
git clone --depth 1 https://github.com/RohitBind123/claude-setup
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,676 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.01676
Opus 5 $0.00015 $0.00838
Sonnet 5 $0.00006 $0.00335
Haiku 4.5 $0.00003 $0.00168

Measured yesterday against content hash 3f1791ba569f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-review scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to python-review — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

commands/python-review.md · 298 lines

How it starts

The opening of the file, as written. The whole thing — 298 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Code Review

This command invokes the python-reviewer agent for comprehensive Python-specific code review.

What This Command Does

  1. Identify Python Changes: Find modified .py files via git diff
  2. Run Static Analysis: Execute ruff, mypy, pylint, black --check
  3. Security Scan: Check for SQL injection, command injection, unsafe deserialization
  4. Type Safety Review: Analyze type hints and mypy errors
  5. Pythonic Code Check: Verify code follows PEP 8 and Python best practices
  6. Generate Report: Categorize issues by severity

When to Use

Use /python-review when:

  • After writing or modifying Python code
  • Before committing Python changes
  • Reviewing pull requests with Python code
  • Onboarding to a new Python codebase
  • Learning Pythonic patterns and idioms

Review Categories

CRITICAL (Must Fix)

  • SQL/Command injection vulnerabilities
  • Unsafe eval/exec usage
  • Pickle unsafe deserialization
  • Hardcoded credentials
  • YAML unsafe load
  • Bare except clauses hiding errors

HIGH (Should Fix)

  • Missing type hints on public functions
  • Mutable default arguments
  • Swallowing exceptions silently
  • Not using context managers for resources
  • C-style looping instead of comprehensions
  • Using type() instead of isinstance()
  • Race conditions without locks

MEDIUM (Consider)

  • PEP 8 formatting violations
  • Missing docstrings on public functions
  • Print statements instead of logging
  • Inefficient string operations
  • Magic numbers without named constants
  • Not using f-strings for formatting
  • Unnecessary list creation

Automated Checks Run

# Type checking
mypy .

# Linting and formatting
ruff check .
black --check .
isort --check-only .

# Security scanning
bandit -r .

# Dependency audit
pip-audit
safety check

# Testing
pytest --cov=app --cov-report=term-missing

Example Usage

User: /python-review

Agent:
# Python Code Review Report

## Files Reviewed
- app/routes/user.py (modified)
- app/services/auth.py (modified)

## Static Analysis Results
✓ ruff: No issues
✓ mypy: No errors
⚠️ black: 2 files need reformatting
✓ bandit: No security issues

## Issues Found

[CRITICAL] SQL Injection vulnerability
File: app/routes/user.py:42
Issue: User input directly interpolated into SQL query
```python
query = f"SELECT * FROM users WHERE id = {user_id}"  # Bad

Fix: Use parameterized query

query = "SELECT * FROM users WHERE id = %s"  # Good
cursor.execute(query, (user_id,))

[HIGH] Mutable default argument File: app/services/auth.py:18 Issue: Mutable default argument causes shared state

def process_items(items=[]):  # Bad
    items.append("new")
    return items

Fix: Use None as default

def process_items(items=None):  # Good
    if items is None:
        items = []
    items.append("new")
    return items

[MEDIUM] Missing type hints File: app/services/auth.py:25 Issue: Public function without type annotations

def get_user(user_id):  # Bad
    return db.find(user_id)

Fix: Add type hints

def get_user(user_id: str) -> Optional[User]:  # Good
    return db.find(user_id)

[MEDIUM] Not using context manager File: app/routes/user.py:55 Issue: File not closed on exception

f = open("config.json")  # Bad
data = f.read()
f.close()

Fix: Use context manager

with open("config.json") as f:  # Good
    data = f.read()

Summary

  • CRITICAL: 1
  • HIGH: 1
  • MEDIUM: 2

Recommendation: ❌ Block merge until CRITICAL issue is fixed

Formatting Required

Run: black app/routes/user.py app/services/auth.py

Read the full file on GitHub · 298 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 298 lines · 31 tokens per session scan A 3f1791ba569f

Subscribe to this mod's changes

python-review is a command published in the GitHub repository RohitBind123/claude-setup (2 stars, last pushed 4mo ago), licensed MIT. It adds 31 tokens to every session and 1,676 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to python-review, differing in 0 lines, and is treated as a copy.