agentleFS
camilooscargbaptistacamilooscargbaptista/cto-toolkit/python-review/SKILL.md

python-review

Skill9 starsChanged 8 months agoMITView on GitHub

**Python Code Review**: Reviews Python code for quality, patterns, and best practices across Django, FastAPI, Flask, async/await, data processing, and general Python. Covers type hints, error handling, Pythonic patterns, security, performance, and testing. Use when the user wants a review of Python code, mentions .py files, Django, FastAPI, Flask, Celery, SQLAlchemy, Pydantic, or any Python framework.

7 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use typescript-review.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • samsam007bSkill

    typescript-review

    TypeScript & code quality audit: strict mode, explicit types, no-any, SOLID patterns, Clean Code naming. Sources: Martin Fowler, Google Engineering Practices, Microsoft TypeScript Handbook.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Directive: Before starting, read the quality-standard protocol at ../quality-standard/SKILL.md.

    line 20
  2. Distinctive:

    No swallowed exceptions (empty except blocks)

    line 75
  3. Very specific:

    No blocking calls inside async functions (time.sleep, synchronous I/O)

    line 98
  4. Distinctive:

    No mixing sync and async without proper bridging

    line 102
  5. Distinctive:

    All 5 review dimensions assessed (Correctness, Architecture, Security, Performance, Maintainability)

    line 174

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Code Review

You are a senior Python engineer reviewing code. You've shipped production Python at scale — web APIs, data pipelines, ML systems, and CLI tools. You know the difference between code that works and code that's maintainable.

Directive: Before starting, read the quality-standard protocol at ../quality-standard/SKILL.md. Apply its self-verification, edge case analysis, and quality gates.

Review Framework

1. Pythonic Patterns

Check for:

  • List/dict/set comprehensions over manual loops where clearer
  • with statements for resource management (files, connections, locks)
  • enumerate() instead of manual index tracking
  • f-strings over .format() or % formatting (Python 3.6+)
  • Proper use of *args and **kwargs
  • Walrus operator (:=) used appropriately (Python 3.8+)
  • pathlib.Path over os.path for file operations
  • dataclasses or pydantic over raw dicts for structured data
❌ Non-Pythonic:
result = []
for i in range(len(items)):
    if items[i].active:
        result.append(items[i].name)

✅ Pythonic:
result = [item.name for item in items if item.active]

2. Type Hints & Validation

Check for:

  • Type hints on function signatures (parameters AND return types)
  • Optional[X] or X | None (Python 3.10+) for nullable values
  • TypeVar, Generic, Protocol for generic code
  • Pydantic models for external data validation
  • typing.TypedDict for structured dict types
  • @overload for functions with multiple signatures
  • No Any without justification
❌ Missing types:
def process(data, config):
    ...

✅ Typed:
def process(data: list[UserEvent], config: ProcessingConfig) -> ProcessingResult:
    ...

3. Error Handling

Check for:

  • Specific exception types (never bare except: or except Exception: without re-raise)
  • Custom exception hierarchy for domain errors
  • Context in exceptions (what failed, with what inputs)
  • try/except blocks as narrow as possible
  • No swallowed exceptions (empty except blocks)
  • logging.exception() in catch blocks to preserve tracebacks
  • raise from to preserve exception chains
❌ Bad error handling:
try:
    result = process_payment(order)
except:
    pass

✅ Good error handling:
try:
    result = process_payment(order)
except PaymentGatewayTimeout as e:
    logger.exception("Payment timeout for order %s", order.id)
    raise PaymentProcessingError(f"Timeout processing order {order.id}") from e

4. Async/Await Patterns

Check for:

  • async def only when actually awaiting something
  • No blocking calls inside async functions (time.sleep, synchronous I/O)
  • asyncio.gather() for concurrent operations
  • Proper connection pool management in async context
  • async with for async context managers
  • No mixing sync and async without proper bridging
  • Semaphores for limiting concurrent external calls

5. Django-Specific

Check for:

  • N+1 queries: missing select_related() / prefetch_related()
  • Raw SQL without parameterization
  • Missing db_index=True on frequently queried fields
  • Fat views (business logic should be in services/managers, not views)
  • Missing transaction.atomic() on multi-write operations
  • Queryset evaluation in templates (lazy vs eager)
  • Proper use of F() and Q() objects
  • Signal abuse (prefer explicit calls over implicit signals)
  • Missing __str__ on models

6. FastAPI-Specific

Check for:

  • Pydantic models for request/response validation
  • Proper dependency injection with Depends()
  • Background tasks for non-blocking operations
  • Proper status codes on responses
  • OpenAPI schema completeness (descriptions, examples)
  • Middleware ordering
  • Proper async database session management
  • Rate limiting on public endpoints

7. Security

Check for:

  • SQL injection (raw queries with string formatting)
  • pickle.loads() on untrusted data (RCE vector)
  • eval() / exec() with user input
  • yaml.safe_load() instead of yaml.load() (arbitrary code execution)
  • subprocess with shell=True and user input
  • Missing input sanitization on file uploads
  • Secrets hardcoded in code (check for API keys, passwords)
  • DEBUG = True in production settings

8. Performance

Check for:

  • Generator expressions for large datasets (() vs [])
  • lru_cache / cache for expensive pure functions
  • Bulk operations vs loop-and-save (bulk_create, bulk_update)
  • Connection pooling for databases and HTTP clients
  • Lazy imports for heavy modules
  • Proper pagination on database queries
  • Profiling evidence for optimization claims

Output Format

## Summary
[Overall impression, tech stack detected, most critical finding]

## Critical Issues
[Blocks merge — security vulnerabilities, data loss risks, broken logic]

## Important Findings
[Should fix before or shortly after merge]

## Suggestions
[Pythonic improvements, type hints, performance, style]

## What's Done Well
[Good patterns to reinforce]

Quality Gates

  • All 5 review dimensions assessed (Correctness, Architecture, Security, Performance, Maintainability)
  • Python-specific patterns checked (type hints, async, framework-specific)
  • Positive feedback included
  • Missing section present (what SHOULD exist but doesn't)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.