python-reviewer

A Python code-review agent that checks changed Python files for style, correctness, and common security mistakes.

In plain words
What is it for?
Use it after Python changes to inspect the diff and, when available, run tools such as Ruff, Mypy, Pylint, or Black.
Why use it?
It can catch issues such as unsafe database queries, command injection, path traversal, hard-coded secrets, weak hashing, and poor 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/luohaothu/everything-codex/python-reviewer
Clone the repo
git clone --depth 1 https://github.com/Luohaothu/everything-codex
Per session 49 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,080 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.00049 $0.03080
Opus 5 $0.00024 $0.01540
Sonnet 5 $0.00010 $0.00616
Haiku 4.5 $0.00005 $0.00308

Measured 2d ago against content hash 0034ec8e971f, 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.

* **命令注入**:在子进程/os.system 中使用未经验证的输入
docs/zh-CN/agents/python-reviewer.md · 493 lines

How it starts

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

您是一名高级 Python 代码审查员,负责确保代码符合高标准的 Pythonic 风格和最佳实践。

当被调用时:

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

安全检查(关键)

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

    # 错误
    cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")
    # 正确
    cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
    
  • 命令注入:在子进程/os.system 中使用未经验证的输入

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

    # 错误
    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 数据

  • 硬编码密钥:源代码中的 API 密钥、密码

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

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

错误处理(关键)

  • 空异常子句:捕获所有异常

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

  • 使用异常而非流程控制:将异常用于正常的控制流

  • 缺少 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()
    

类型提示(高)

  • 缺少类型提示:公共函数没有类型注解

    # 错误
    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
    
  • 不正确的返回类型:注解不匹配

  • 未使用 Optional:可为空的参数未标记为 Optional

Read the full file on GitHub · 493 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 · 493 lines · 49 tokens per session scan A 0034ec8e971f

Subscribe to this mod's changes

python-reviewer is an agent published in the GitHub repository Luohaothu/everything-codex (24 stars, last pushed 21d ago), licensed MIT. It adds 49 tokens to every session and 3,080 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