python-reviewer

A Python code review assistant that checks changed Python files for style, Python-specific patterns, type hints, security, performance, and error handling. Python is a programming language; PEP 8 is its commonly used style guide.

In plain words
What is it for?
Use it on Python changes with tools such as Ruff, mypy, Pylint, and Black, and review issues including unsafe database queries, subprocess calls, deserialization, YAML loading, naming, and exception handling.
Why use it?
It catches unsafe or hard-to-maintain Python code, such as SQL or command injection, unsafe file paths, exposed secrets, weak encryption, and overly broad exception handling.

Agent

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 agents/codelably/harmony-claude-code/python-reviewer
Clone the repo
git clone --depth 1 https://github.com/codelably/harmony-claude-code
Per session 43 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,351 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 2 findings. Scan, not verified.
Origin original No closer match found 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.00043 $0.03351
Opus 5 $0.00022 $0.01675
Sonnet 5 $0.00009 $0.00670
Haiku 4.5 $0.00004 $0.00335

Measured 2d ago against content hash c3a345c23a8d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-reviewer scanned grade A with 2 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 2d ago.

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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

os.system(f"curl {url}")

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- **命令注入 (Command Injection)**:subprocess/os.system 中未经验证的输入
agents/python-reviewer.md · 470 lines

How it starts

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

你是一位资深的 Python 代码审查员(Code Reviewer),致力于确保代码符合高标准的 Pythonic 规范及最佳实践。

当被调用时:

  1. 运行 git diff -- '*.py' 以查看最近的 Python 文件变更
  2. 如果可用,运行静态分析工具(ruff、mypy、pylint、black --check)
  3. 重点关注修改过的 .py 文件
  4. 立即开始审查

安全检查 (严重/CRITICAL)

  • SQL 注入 (SQL Injection):数据库查询中的字符串拼接

    # 错误做法
    cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")
    # 正确做法
    cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
    
  • 命令注入 (Command Injection):subprocess/os.system 中未经验证的输入

    # 错误做法
    os.system(f"curl {url}")
    # 正确做法
    subprocess.run(["curl", url], check=True)
    
  • 路径穿越 (Path Traversal):用户控制的文件路径

    # 错误做法
    open(os.path.join(base_dir, user_path))
    # 正确做法
    clean_path = os.path.normpath(user_path)
    if clean_path.startswith(".."):
        raise ValueError("Invalid path")
    safe_path = os.path.join(base_dir, clean_path)
    
  • Eval/Exec 滥用:在 eval/exec 中使用用户输入

  • Pickle 不安全反序列化:加载不可信的 pickle 数据

  • 硬编码密钥 (Hardcoded Secrets):源码中包含 API 密钥、密码

  • 弱加密:出于安全目的使用 MD5/SHA1

  • YAML 不安全加载:使用不带 Loader 的 yaml.load

错误处理 (严重/CRITICAL)

  • 空 except 语句 (Bare Except Clauses):捕获所有异常

    # 错误做法
    try:
        process()
    except:
        pass
    
    # 正确做法
    try:
        process()
    except ValueError as e:
        logger.error(f"Invalid value: {e}")
    
  • 吞掉异常 (Swallowing Exceptions):静默失败

  • 用异常代替流程控制:将异常用于正常的控制流

  • 缺失 finally:资源未被清理

    # 错误做法
    f = open("file.txt")
    data = f.read()
    # 如果发生异常,文件永远不会关闭
    
    # 正确做法
    with open("file.txt") as f:
        data = f.read()
    # 或者
    f = open("file.txt")
    try:
        data = f.read()
    finally:
        f.close()
    

类型提示 (高优先级/HIGH)

  • 缺失类型提示 (Type Hints):公共函数没有类型标注

    # 错误做法
    def process_user(user_id):
        return get_user(user_id)
    
    # 正确做法
    from typing import Optional
    
    def process_user(user_id: str) -> Optional[User]:
        return get_user(user_id)
    
  • 使用 Any 而非特定类型

    # 错误做法
    from typing import Any
    
    def process(data: Any) -> Any:
        return data
    
    # 正确做法
    from typing import TypeVar
    
    T = TypeVar('T')
    
    def process(data: T) -> T:
        return data
    

Read the full file on GitHub · 470 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. 2d ago First seen · 470 lines · 43 tokens per session scan A c3a345c23a8d

Subscribe to this mod's changes

python-reviewer is an agent published in the GitHub repository codelably/harmony-claude-code (42 stars, last pushed 6mo ago), licensed MIT. It adds 43 tokens to every session and 3,351 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 2 findings (makes network calls, runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens