Python Ecosystem Review
Review one thing: how a Python repository actually uses important ecosystem
libraries. Apply technology-appropriate evidence, version and effective-
configuration precedence, disproof, uncertainty, official-source, and read-only
rules together with the Python-specific discovery and checks below.
Do not modify code unless the user explicitly asks for fixes. If fixes are allowed, complete the review first, then make only the requested or clearly justified library-usage changes.
Boundaries
- Do not perform broad architecture review. Discuss architecture only when concrete library usage creates unclear boundaries, lifecycle risk, or cross-library coupling.
- Do not perform broad agent-legibility review. Discuss Codex legibility only when library usage makes integration behavior hard to find, verify, or safely modify.
- Do not perform general Python backend review. Discuss Python fundamentals only when they directly affect a reviewed library's usage.
- Do not review every dependency. Ignore tooling, packaging-only dependencies, formatters, simple utilities, and transitive libraries unless the user asks or the code shows architectural use.
- Prefer automatic discovery. User-specified libraries are priority hints, not required inputs.
Review Principles
- Every finding is a hypothesis. Before reporting it, actively attempt to disprove it. A finding should only survive if the available repository evidence does not invalidate it.
- Prefer the repository's actual library versions, local conventions, and integration tests over generic best-practice assumptions.
- Recommend changes only when they improve correctness, maintainability, operational safety, migration safety, or safe modification enough to justify migration, review, testing, and rollback cost.
Reuse Versus Focused Custom Implementation
Do not assume that reuse is better merely because a library or repository
component exists, and do not assume that locally generated code is simpler
merely because it is quicker to write. Evaluate the concrete semantic and
integration fit:
- Compare the requested behavior with the smallest relevant public capability
or extension point, not only with a library's bundled high-level components.
- Prefer direct reuse when it matches the required semantics and keeps the
integration, change, and test surface smaller.
- Prefer a thin adapter when the library owns a standard or general mechanism
and its public extension points can express the required selection or policy.
- A focused custom implementation can be the better choice when available
components force unrelated behavior that cannot be disabled, impose broader
coupling, lifecycle, or side effects, or cost more to integrate and verify
than a small domain-local implementation.
- Apply a stronger reuse bias to semantically deep concerns such as standards,
protocols, schema engines, cryptography, concurrency, parsing, and framework
lifecycle behavior. Small-looking replacements in these areas often inherit
a large hidden edge-case surface.
- When substantial custom machinery is proposed around a library-owned
concern, require evidence from the detected version and public API, a concise
explanation of why exact reuse or thin adaptation does not fit, and tests for
both required behavior and explicitly unwanted bundled behavior.
During the disproof pass, reject a finding based only on the existence of an
equivalent-looking library feature. Verify that it matches the repository's
actual semantics without introducing behavior, coupling, or validation cost
that the task does not require.
Inputs
Support these optional inputs:
priority_libraries: library names the user wants emphasized.
languages: accept auto or an explicit list when supplied; this adapter reviews Python and should identify material non-Python components as adjacent ecosystem boundaries rather than silently treating a polyglot repository as Python-only.
allow_web_research: whether to check official sources when version-specific claims may be stale; default true.
review_only: default true.
Discovery Workflow
Discover Python dependency evidence.
- Inspect
pyproject.toml, requirements.txt, requirements/*.txt, poetry.lock, uv.lock, Pipfile, setup.py, setup.cfg, tox/nox config, Docker files, CI files, and README/deployment notes when relevant.
- Record declared versions, version ranges, lockfile versions, extras, dependency groups, and runtime/dev separation.
- Use imports and configured registrations to prove library use; prefer fresh runtime evidence for executed version or configuration, then lock evidence, then declarations when they conflict. Treat mismatches as review evidence.
Build the library candidate list.
- Search imports and integration points, not only dependency files.
- Use
rg for imports, decorators, config keys, entrypoints, fixtures, app factories, migration env files, task registration, dependency providers, clients, middleware, plugins, and test helpers.
- Include libraries used through framework strings, settings, plugin config, CLI entrypoints, or generated migration/task files even when imports are indirect.
Classify review priority.
Must review: libraries that define the app framework, request/response boundary, validation/serialization, ORM/persistence, migrations, task queues, workflow engines, dependency injection, or major runtime lifecycle.
Review if used heavily: libraries that affect important execution paths when used broadly or at boundaries, such as HTTP clients, Redis clients, cache layers, structured logging, tracing, test frameworks, fixture systems, serialization helpers, or client SDKs.
Ignore unless user asks: formatters, linters, build backends, packaging-only tools, type checkers used only as tools, tiny utilities, or libraries with trivial localized use.
Use examples as hints, not a closed list:
| Priority |
Examples |
| Must review |
FastAPI, Django, Flask, Litestar, SQLAlchemy, SQLModel, Tortoise ORM, Pydantic, Alembic, Celery, Dramatiq, RQ, LangChain, LangGraph |
| Review if used heavily |
httpx, aiohttp, requests, redis, pytest, structlog, loguru, dependency-injector, opentelemetry, tenacity |
| Ignore unless user asks |
black, ruff, isort, build, wheel, twine, packaging-only plugins, small local utility dependencies |
Inspect actual usage for each reviewed library.
- Check imports, public interfaces, adapter layers, app setup, lifecycle hooks, middleware, dependency providers, model/schema definitions, repositories, migrations, clients, tasks, workers, tests, configuration, and error handling.
- Identify where library concepts cross project boundaries, such as framework objects entering business logic, ORM sessions crossing task boundaries, schemas doubling as domain models, or clients instantiated without lifecycle control.
- Compare usage against the project's own established patterns before recommending new patterns.
Verify freshness before strong claims.
- If the detected version is newer than reliable model knowledge, the API is version-sensitive, or the code uses recently changed/deprecated patterns, check official documentation, changelogs, migration guides, or release notes before making strong claims.
- Prefer official documentation, official changelogs, official migration guides, and official release notes.
- Do not rely on generic blog posts for version-specific best-practice claims unless official sources are unavailable.
- Cite official sources when web research is used.
- If current verification or network access is unavailable, continue the review, state the uncertainty, and downgrade version-specific claims.
Review Dimensions
For each important library, evaluate:
- idiomatic usage for the detected version
- compatibility with declared and locked versions
- deprecated APIs, legacy patterns, or migration hazards
- fit with the repository's architecture and local conventions
- clear boundaries between library/framework code and business logic
- lifecycle management for apps, sessions, clients, workers, event loops, connections, and background tasks
- error handling at the correct layer
- explicit configuration and environment assumptions
- test coverage for integration points, not only isolated helpers
- whether usage makes the repository easier or harder for Codex to understand and modify
Finding Rules
Report findings only when they are concrete and location-backed. Every high-priority finding should include:
- the library or cross-library boundary involved
- the exact file, module, function, class, config, test, or repo-wide location
- the observed usage pattern
- why it matters for correctness, maintainability, operations, or safe modification
- a small, testable recommendation
- the risk if unchanged
Use this priority scale:
- P0: likely correctness, data integrity, deployability, or serious operational failure.
- P1: high-risk library misuse, version incompatibility, lifecycle leak, boundary violation, or missing integration test.
- P2: meaningful maintainability, explicitness, testing, or migration-risk issue.
- P3: low-risk improvement worth noting because it removes a real future trap.
Finding Disproof Pass
Generate candidate findings first, then challenge each one against repository and library evidence before reporting it.
For each candidate:
- Search for counter-evidence in detected versions, lock files, official documentation, tests, local wrappers, lifecycle helpers, config, and established project usage.
- Ask whether this is a true compatibility, correctness, lifecycle, or integration issue, or only optional modernization.
- Check whether the project intentionally avoids a newer library pattern or preserves an older pattern for compatibility.
- Verify that current library versions or official documentation support the claim before making version-sensitive recommendations.
- Ask whether the recommendation would increase migration, review, testing, rollback, or operational cost without improving correctness or maintainability.
- Downgrade or reject findings when counter-evidence is strong; preserve uncertainty instead of overstating best-practice claims.
- Avoid letting the same reasoning path both create and validate the finding without challenge.
When useful, list rejected candidates under "Non-Issues / Intentionally Not Flagged".
Cross-library Patterns To Check
When relevant, inspect cross-library boundaries such as:
- web framework response models plus validation/serialization schemas
- ORM session lifecycle plus request dependencies, workers, or tests
- migration metadata drifting from ORM models
- task queues plus database sessions, transactions, retries, and idempotency
- HTTP clients plus async runtime, timeouts, retries, and dependency lifecycle
- workflow engines plus state schemas, persistence, validation, and replay behavior
- test fixtures masking framework, database, task, or client integration failures
- logging/tracing losing request, job, workflow, or external-call context
Output Format
Use this structure unless the user asks for a different format.
1. Dependency Discovery Summary
List detected dependency files and important libraries found. Note major version conflicts, missing lock evidence, or uncertainty.
2. Library Review Scope
| Library |
Detected Version |
Category |
Review Priority |
Reason |
3. High-priority Findings
Include P0/P1/P2 findings here. Omit the table if there are no high-priority findings.
| Priority |
Library |
Location |
Issue |
Why it matters |
Recommendation |
Risk if unchanged |
4. Per-library Review
For each reviewed library:
#### <Library Name>
- Detected version:
- Main usage locations:
- Current usage pattern:
- What is good:
- Issues found:
- Best-practice concerns:
- Codex-legibility concerns:
- Recommended changes:
5. Cross-library Integration Issues
Identify issues involving multiple libraries. If none were found, say so and name the boundaries inspected.
6. Explicitness Improvements
List rules or assumptions that should be made explicit in type definitions, schemas, enums, dependency providers, config files, tests, .manifest, or documentation.
7. Recommended Follow-up Prompts
Provide 3-5 small, low-risk Codex prompts. Each prompt must target one library or one integration boundary, be easy to review and revert, and include a clear acceptance criterion.
Example:
Review the SQLAlchemy session lifecycle used by FastAPI dependencies and background jobs. Acceptance criterion: produce a location-backed finding list and one minimal test or documentation change proposal for any lifecycle gap.
8. Non-Issues / Intentionally Not Flagged
Use only when it adds signal. Briefly list candidate findings rejected by the disproof pass and the version, test, convention, or official-documentation evidence that invalidated them.
1---2name: python-ecosystem-review3description: Review how Python repositories use important ecosystem libraries and integration boundaries, automatically discovering concrete usage and evaluating it against version-appropriate practices. Use when Codex needs a Python review of framework, validation, ORM, migration, dependency injection, async, background job, HTTP client, testing, LLM/agent, observability, or runtime-library integration points. Review-only by default; do not use for broad architecture, generic Python style, full agent-legibility, security, performance, or framework-only reviews.4---56# Python Ecosystem Review78Review one thing: how a Python repository actually uses important ecosystem9libraries. Apply technology-appropriate evidence, version and effective-10configuration precedence, disproof, uncertainty, official-source, and read-only11rules together with the Python-specific discovery and checks below.1213Do not modify code unless the user explicitly asks for fixes. If fixes are allowed, complete the review first, then make only the requested or clearly justified library-usage changes.1415## Boundaries1617- Do not perform broad architecture review. Discuss architecture only when concrete library usage creates unclear boundaries, lifecycle risk, or cross-library coupling.18- Do not perform broad agent-legibility review. Discuss Codex legibility only when library usage makes integration behavior hard to find, verify, or safely modify.19- Do not perform general Python backend review. Discuss Python fundamentals only when they directly affect a reviewed library's usage.20- Do not review every dependency. Ignore tooling, packaging-only dependencies, formatters, simple utilities, and transitive libraries unless the user asks or the code shows architectural use.21- Prefer automatic discovery. User-specified libraries are priority hints, not required inputs.2223## Review Principles2425- Every finding is a hypothesis. Before reporting it, actively attempt to disprove it. A finding should only survive if the available repository evidence does not invalidate it.26- Prefer the repository's actual library versions, local conventions, and integration tests over generic best-practice assumptions.27- Recommend changes only when they improve correctness, maintainability, operational safety, migration safety, or safe modification enough to justify migration, review, testing, and rollback cost.2829### Reuse Versus Focused Custom Implementation3031Do not assume that reuse is better merely because a library or repository32component exists, and do not assume that locally generated code is simpler33merely because it is quicker to write. Evaluate the concrete semantic and34integration fit:3536- Compare the requested behavior with the smallest relevant public capability37 or extension point, not only with a library's bundled high-level components.38- Prefer direct reuse when it matches the required semantics and keeps the39 integration, change, and test surface smaller.40- Prefer a thin adapter when the library owns a standard or general mechanism41 and its public extension points can express the required selection or policy.42- A focused custom implementation can be the better choice when available43 components force unrelated behavior that cannot be disabled, impose broader44 coupling, lifecycle, or side effects, or cost more to integrate and verify45 than a small domain-local implementation.46- Apply a stronger reuse bias to semantically deep concerns such as standards,47 protocols, schema engines, cryptography, concurrency, parsing, and framework48 lifecycle behavior. Small-looking replacements in these areas often inherit49 a large hidden edge-case surface.50- When substantial custom machinery is proposed around a library-owned51 concern, require evidence from the detected version and public API, a concise52 explanation of why exact reuse or thin adaptation does not fit, and tests for53 both required behavior and explicitly unwanted bundled behavior.5455During the disproof pass, reject a finding based only on the existence of an56equivalent-looking library feature. Verify that it matches the repository's57actual semantics without introducing behavior, coupling, or validation cost58that the task does not require.5960## Inputs6162Support these optional inputs:6364- `priority_libraries`: library names the user wants emphasized.65- `languages`: accept `auto` or an explicit list when supplied; this adapter reviews Python and should identify material non-Python components as adjacent ecosystem boundaries rather than silently treating a polyglot repository as Python-only.66- `allow_web_research`: whether to check official sources when version-specific claims may be stale; default `true`.67- `review_only`: default `true`.6869## Discovery Workflow70711. Discover Python dependency evidence.72 - Inspect `pyproject.toml`, `requirements.txt`, `requirements/*.txt`, `poetry.lock`, `uv.lock`, `Pipfile`, `setup.py`, `setup.cfg`, tox/nox config, Docker files, CI files, and README/deployment notes when relevant.73 - Record declared versions, version ranges, lockfile versions, extras, dependency groups, and runtime/dev separation.74 - Use imports and configured registrations to prove library use; prefer fresh runtime evidence for executed version or configuration, then lock evidence, then declarations when they conflict. Treat mismatches as review evidence.75762. Build the library candidate list.77 - Search imports and integration points, not only dependency files.78 - Use `rg` for imports, decorators, config keys, entrypoints, fixtures, app factories, migration env files, task registration, dependency providers, clients, middleware, plugins, and test helpers.79 - Include libraries used through framework strings, settings, plugin config, CLI entrypoints, or generated migration/task files even when imports are indirect.80813. Classify review priority.82 - `Must review`: libraries that define the app framework, request/response boundary, validation/serialization, ORM/persistence, migrations, task queues, workflow engines, dependency injection, or major runtime lifecycle.83 - `Review if used heavily`: libraries that affect important execution paths when used broadly or at boundaries, such as HTTP clients, Redis clients, cache layers, structured logging, tracing, test frameworks, fixture systems, serialization helpers, or client SDKs.84 - `Ignore unless user asks`: formatters, linters, build backends, packaging-only tools, type checkers used only as tools, tiny utilities, or libraries with trivial localized use.8586Use examples as hints, not a closed list:8788| Priority | Examples |89|---|---|90| Must review | FastAPI, Django, Flask, Litestar, SQLAlchemy, SQLModel, Tortoise ORM, Pydantic, Alembic, Celery, Dramatiq, RQ, LangChain, LangGraph |91| Review if used heavily | httpx, aiohttp, requests, redis, pytest, structlog, loguru, dependency-injector, opentelemetry, tenacity |92| Ignore unless user asks | black, ruff, isort, build, wheel, twine, packaging-only plugins, small local utility dependencies |93944. Inspect actual usage for each reviewed library.95 - Check imports, public interfaces, adapter layers, app setup, lifecycle hooks, middleware, dependency providers, model/schema definitions, repositories, migrations, clients, tasks, workers, tests, configuration, and error handling.96 - Identify where library concepts cross project boundaries, such as framework objects entering business logic, ORM sessions crossing task boundaries, schemas doubling as domain models, or clients instantiated without lifecycle control.97 - Compare usage against the project's own established patterns before recommending new patterns.98995. Verify freshness before strong claims.100 - If the detected version is newer than reliable model knowledge, the API is version-sensitive, or the code uses recently changed/deprecated patterns, check official documentation, changelogs, migration guides, or release notes before making strong claims.101 - Prefer official documentation, official changelogs, official migration guides, and official release notes.102 - Do not rely on generic blog posts for version-specific best-practice claims unless official sources are unavailable.103 - Cite official sources when web research is used.104 - If current verification or network access is unavailable, continue the review, state the uncertainty, and downgrade version-specific claims.105106## Review Dimensions107108For each important library, evaluate:109110- idiomatic usage for the detected version111- compatibility with declared and locked versions112- deprecated APIs, legacy patterns, or migration hazards113- fit with the repository's architecture and local conventions114- clear boundaries between library/framework code and business logic115- lifecycle management for apps, sessions, clients, workers, event loops, connections, and background tasks116- error handling at the correct layer117- explicit configuration and environment assumptions118- test coverage for integration points, not only isolated helpers119- whether usage makes the repository easier or harder for Codex to understand and modify120121## Finding Rules122123Report findings only when they are concrete and location-backed. Every high-priority finding should include:124125- the library or cross-library boundary involved126- the exact file, module, function, class, config, test, or repo-wide location127- the observed usage pattern128- why it matters for correctness, maintainability, operations, or safe modification129- a small, testable recommendation130- the risk if unchanged131132Use this priority scale:133134- P0: likely correctness, data integrity, deployability, or serious operational failure.135- P1: high-risk library misuse, version incompatibility, lifecycle leak, boundary violation, or missing integration test.136- P2: meaningful maintainability, explicitness, testing, or migration-risk issue.137- P3: low-risk improvement worth noting because it removes a real future trap.138139## Finding Disproof Pass140141Generate candidate findings first, then challenge each one against repository and library evidence before reporting it.142143For each candidate:144145- Search for counter-evidence in detected versions, lock files, official documentation, tests, local wrappers, lifecycle helpers, config, and established project usage.146- Ask whether this is a true compatibility, correctness, lifecycle, or integration issue, or only optional modernization.147- Check whether the project intentionally avoids a newer library pattern or preserves an older pattern for compatibility.148- Verify that current library versions or official documentation support the claim before making version-sensitive recommendations.149- Ask whether the recommendation would increase migration, review, testing, rollback, or operational cost without improving correctness or maintainability.150- Downgrade or reject findings when counter-evidence is strong; preserve uncertainty instead of overstating best-practice claims.151- Avoid letting the same reasoning path both create and validate the finding without challenge.152153When useful, list rejected candidates under "Non-Issues / Intentionally Not Flagged".154155## Cross-library Patterns To Check156157When relevant, inspect cross-library boundaries such as:158159- web framework response models plus validation/serialization schemas160- ORM session lifecycle plus request dependencies, workers, or tests161- migration metadata drifting from ORM models162- task queues plus database sessions, transactions, retries, and idempotency163- HTTP clients plus async runtime, timeouts, retries, and dependency lifecycle164- workflow engines plus state schemas, persistence, validation, and replay behavior165- test fixtures masking framework, database, task, or client integration failures166- logging/tracing losing request, job, workflow, or external-call context167168## Output Format169170Use this structure unless the user asks for a different format.171172### 1. Dependency Discovery Summary173174List detected dependency files and important libraries found. Note major version conflicts, missing lock evidence, or uncertainty.175176### 2. Library Review Scope177178| Library | Detected Version | Category | Review Priority | Reason |179|---|---|---|---|---|180181### 3. High-priority Findings182183Include P0/P1/P2 findings here. Omit the table if there are no high-priority findings.184185| Priority | Library | Location | Issue | Why it matters | Recommendation | Risk if unchanged |186|---|---|---|---|---|---|---|187188### 4. Per-library Review189190For each reviewed library:191192```markdown193#### <Library Name>194195- Detected version:196- Main usage locations:197- Current usage pattern:198- What is good:199- Issues found:200- Best-practice concerns:201- Codex-legibility concerns:202- Recommended changes:203```204205### 5. Cross-library Integration Issues206207Identify issues involving multiple libraries. If none were found, say so and name the boundaries inspected.208209### 6. Explicitness Improvements210211List rules or assumptions that should be made explicit in type definitions, schemas, enums, dependency providers, config files, tests, `.manifest`, or documentation.212213### 7. Recommended Follow-up Prompts214215Provide 3-5 small, low-risk Codex prompts. Each prompt must target one library or one integration boundary, be easy to review and revert, and include a clear acceptance criterion.216217Example:218219```text220Review the SQLAlchemy session lifecycle used by FastAPI dependencies and background jobs. Acceptance criterion: produce a location-backed finding list and one minimal test or documentation change proposal for any lifecycle gap.221```222223### 8. Non-Issues / Intentionally Not Flagged224225Use only when it adds signal. Briefly list candidate findings rejected by the disproof pass and the version, test, convention, or official-documentation evidence that invalidated them.