review-architecture

A command that reads Python code and recommends which of a defined set of reusable design approaches could improve its organization.

In plain words
What is it for?
Use it on a directory or the current project to inspect Python files and suggest approaches for switching behavior, object creation, undoable work, event handling, configuration, and data transformations.
Why use it?
Developers may see that code is hard to extend or repetitive without knowing which structure would address the problem. The scan links specific code smells to suggested approaches.

Command

Part of the python-clean-architecture plugin — 1 skill, 13 commands shipped together

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/mktoronto/python-clean-architecture/review-architecture
Clone the repo
git clone --depth 1 https://github.com/MKToronto/python-clean-architecture

Or install python-clean-architecture, the plugin that ships this one along with the rest of its 1 skill, 13 commands.

Per session 11 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,521 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 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.00011 $0.01521
Opus 5 $0.00005 $0.00760
Sonnet 5 $0.00002 $0.00304
Haiku 4.5 $0.00001 $0.00152

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

Security

Grade A, and why

review-architecture 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 3d 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.

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.

commands/review-architecture.md · 124 lines

How it starts

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

Before starting the review, use AskUserQuestion to ask: "Which review depth?" with these options:

  1. Standard — "Reviews against built-in checklists. No extra permissions needed."
  2. In-depth — "Loads detailed reference files for deeper analysis with refactoring recipes and pattern guidance."

Then review the code at $ARGUMENTS (or the current working directory if no path given) against Python Clean Architecture principles.

Review Process

  1. Read the code — Find and read ALL Python files in the target path recursively. Read every .py file — do not skip any. Understand the project structure, imports, and relationships between files.

  2. Check architecture layers — Verify the three-layer separation:

    • Routers (API) → Operations (business logic) → Database (persistence)
    • No layer skipping (routers should not import DB modules directly)
    • Operations accept DataInterface Protocol, not concrete DB classes
    • Router acts as composition root (wires concrete implementations)
  3. Check the 7 design principles — For each file/class/function, evaluate:

    • High Cohesion — Does each unit have a single responsibility?
    • Low Coupling — Are dependencies minimized? Any Law of Demeter violations?
    • Depend on Abstractions — Protocol/Callable used for DI? Or concrete imports?
    • Composition over Inheritance — Any deep hierarchies or mixins?
    • Separate Creation from Use — One composition root? Dict mapping over if/elif?
    • Start with the Data — Prefixed fields? Parallel lists? Methods far from data?
    • Keep Things Simple — Over-engineered? Speculative features? Unnecessary abstractions?
  4. Check code quality — Apply the 22 design rules:

    • No type abuse, vague identifiers, flag parameters, deep nesting
    • Tell don't ask, no parallel data structures, no god classes
    • No broad exception catching, no mutable defaults, no wildcard imports
    • Type hints on all functions, enums for fixed options, context managers for resources
  5. Check Pythonic patterns — Are patterns implemented the Pythonic way?

    • Strategy as Callable, not ABC hierarchy
    • Factory as dict mapping, not if/elif
    • Protocol over ABC (unless shared state needed)
    • functools.partial for configuration, closures for builders
    • Pub/Sub for notification side effects, not inline calls
    • Registry for data-driven object creation, not if/elif
    • Context managers for resource management, not try/finally
    • Custom exception classes, not broad except catching
    • Dataclasses for value objects and DTOs, not manual init
    • Pure functions where possible, side effects pushed to boundaries
  6. Check code cleanup opportunities — Look for concrete refactoring targets:

    • Extract class when a class does two things
    • Extract function when a function does two things
    • Replace mutable globals with injected dataclass context
    • Replace boolean flag parameters with separate functions
    • Replace string constants with Enums
    • Replace deep nesting (3+ levels) with early returns or extraction
    • Replace god classes (too many responsibilities) with collaborators
    • Move methods to the class that owns the data (Information Expert)
    • Replace parallel data structures with a single data class
    • Replace if/elif chains with dict mapping
  7. Report findings — Structure the output in this order:

    Architecture Summary

    Classify every Python file into a layer, then show the dependency flows. Use a simple vertical list format — never multi-column ASCII art. Example:

    Layers
    ──────
    API:        routers/booking.py, routers/customer.py
    Logic:      operations/booking.py, operations/customer.py
    Database:   db/db_interface.py, db/models.py, db/database.py
    Unclear:    utils/helpers.py (mixed concerns)
    
    Dependency Flows
    ────────────────
    routers/booking.py → operations/booking.py → db/db_interface.py    ✓
    routers/customer.py → operations/customer.py → db/db_interface.py  ✓
    routers/admin.py → db/models.py                                    ⚠ layer skip
    
    Layer Violations
    ────────────────
    ⚠ routers/admin.py imports db/models.py directly — should go through operations
    

Read the full file on GitHub · 124 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. 3d ago First seen · 124 lines · 11 tokens per session scan A aaa28f94d9a0

Subscribe to this mod's changes

review-architecture is a command published in the GitHub repository MKToronto/python-clean-architecture (8 stars, last pushed 2mo ago), licensed MIT. It adds 11 tokens to every session and 1,521 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.