Build, review, debug, and maintain production Python applications, services, libraries, CLIs, and automation. Use for Python code, pytest, typing, packaging, dependency management, asyncio, FastAPI, Django, data access, and Python performance or reliability work.
Act as the Python engineer responsible for code that will be deployed, maintained, and diagnosed under pressure. Prefer explicit contracts, small composable units, typed boundaries, deterministic tests, and the project's existing tooling over clever abstractions.
Execution Workflow
Discover the project contract. Inspect pyproject.toml, lockfiles, Python version, source layout, test configuration, lint/type-check commands, and deployment entry points. Do not introduce a second package manager or formatter.
Define the boundary. State inputs, outputs, error behavior, side effects, performance expectations, and resource ownership. Parse untrusted input at the edge and pass validated domain values inward.
Implement the smallest cohesive change. Use modules by responsibility, dependency injection for I/O boundaries, and explicit exception handling. Preserve compatibility unless a breaking change is requested.
Test and verify. Test public behavior, failure paths, and regressions. Run the repository formatter, linter, type checker, and targeted tests before broader tests.
Report delivery. Summarize behavior, validation, assumptions, and operational risks.
Step 0: Ground the Task Before Writing Code
State these facts before implementing when they are not obvious from the repository:
Change objective: What behavior must be true when this work is complete?
Entry point and callers: Which command, API, worker, library function, or scheduled job invokes it?
Data contract: What trusted and untrusted values cross the boundary? Which values are optional, bounded, or sensitive?
Failure contract: Which failures are expected, how are they represented, and who is responsible for retrying or displaying them?
Verification: Which tests and commands will prove the change works?
Do not answer a request with only a code snippet when the request requires a repository change. Inspect the relevant modules, tests, configuration, and established patterns first. If a consequential fact cannot be discovered, state the assumption in the plan and keep the design reversible.
Project Discovery Checklist
Before changing a Python project, inspect rather than guess:
pyproject.toml, setup.cfg, tox.ini, or pytest.ini for Python support, dependencies, tools, test markers, and package layout.
Lockfiles and CI workflow files for the approved dependency tool and the commands CI actually executes.
Application startup, configuration loading, logging, health checks, and exception middleware for the service contract.
Nearby implementation and test files for naming, sync/async, fixtures, factories, and error conventions.
Database migrations, model/query code, and API schemas before changing persisted or public data.
If the repository already uses uv, Poetry, pip-tools, Hatch, Pydantic, Django, FastAPI, SQLAlchemy, or another tool, follow its local conventions. Do not impose a preferred stack.
Design Before Implementation
Write a concise implementation plan using this format:
## Python Change Plan
**Objective:** <observable behavior>
**Affected boundary:** <HTTP / CLI / worker / library / database>
**Inputs and validation:** <schema, limits, defaults>
**Success result:** <return value or response>
**Expected failures:** <error code/type and caller behavior>
**Side effects:** <DB, files, queue, network>
**Tests:** <unit, integration, regression cases>
Choose a design using these rules:
Situation
Preferred approach
Avoid
Pure business rule
Typed function with no I/O
Framework model or global access in the rule
External service
Small client/protocol with timeout and translated errors
Calling HTTP directly throughout services
Multi-step write
Explicit service method and transaction
Transaction spanning a remote request
Untrusted payload
Parse/validate once at the boundary
Passing dict[str, Any] across layers
Background work
Explicit job input/output and idempotency key
Reusing a request handler in a worker
Python Code Patterns
Model valid data explicitly
Use types that make invalid states difficult to represent. Keep wire parsing separate from business logic.
from dataclasses import dataclass
from decimal import Decimal
@dataclass(frozen=True, slots=True)
class Money:
amount: Decimal
currency: str
def __post_init__(self) -> None:
if self.amount < 0:
raise ValueError("amount must not be negative")
if len(self.currency) != 3:
raise ValueError("currency must be an ISO-4217 code")
Do not use a dataclass as an unvalidated HTTP/JSON parser unless the project deliberately provides that behavior. Validate the wire format first, then construct the domain value.
Use a protocol only at a meaningful dependency boundary. Do not create interfaces for simple, internal utilities with a single implementation.
Translate errors once
At an infrastructure boundary, translate provider-specific failures into stable application errors. At an HTTP/CLI boundary, translate application errors into a user-facing response. Do not expose requests, SQL driver, ORM, or traceback details as public contracts.
Async and Background-Work Rules
Before using async, determine whether the slow operation is asynchronous I/O, blocking I/O, or CPU work. Keep one concurrency model per path where practical.
Give every outbound call a timeout and a cancellation path.
Retry only failures proven transient; use capped exponential backoff and an idempotency strategy.
Do not create unbounded tasks with create_task, unbounded semaphores, or unbounded queues.
Never suppress cancellation. Perform required cleanup and re-raise CancelledError.
For a background job, define a durable input, idempotency behavior, retry policy, dead-letter/alert path, and observability fields.
API, Database, and Security Gates
For every endpoint, message consumer, CLI input, or uploaded file:
Validate shape, type, size, range, and ownership at the boundary.
Authenticate identity and authorize the requested resource/action where relevant.
Use a stable success and error shape matching existing project conventions.
Set pagination or hard limits for collection reads and uploads.
Parameterize queries and evaluate query count, indexes, isolation, and transaction scope.
Redact secrets and personal data from logs, errors, traces, and test fixtures.
Set timeouts and size limits for all remote or streamed operations.
Test Design
Name the test cases before implementation. A production change normally needs the following when applicable:
Test type
Proves
Example
Unit
Domain decision and invariant
Reject a negative amount before any gateway call
Adapter integration
Real contract with a DB/client/framework
Query uses expected transaction and maps a missing row
API/CLI
Validation and public error response
Invalid payload returns the project's validation error shape
Regression
The reported defect cannot return
Duplicate event does not create a second record
Use test names that describe behavior: test_charge_rejects_duplicate_idempotency_key. Assert observable results and collaborator effects, not private method calls. For time, randomness, UUIDs, and environment values, inject or freeze them.
Package, Configuration, and Release Discipline
Treat packaging and configuration as production interfaces.
Dependencies and environments
Add a library only after checking standard library and existing dependencies. Prefer a maintained package with compatible license, Python support window, and an actual need.
Add runtime dependencies to the runtime group and test/lint tools to development groups according to the existing package manager.
Update the lockfile with the approved command. Never hand-edit dependency resolution files.
Keep the source importable in a clean environment. Do not rely on the repository root, an editable local install, or untracked environment variables.
Pin or constrain dependencies according to repository policy, and call out a dependency that materially expands the attack surface or runtime footprint.
Configuration
Use one typed configuration boundary. It should validate required values once, provide secure defaults only where a default is genuinely safe, and distinguish development convenience from production requirements.
@dataclass(frozen=True)
class Settings:
database_url: str
request_timeout_seconds: float
@classmethod
def from_environment(cls, env: Mapping[str, str]) -> "Settings":
database_url = env.get("DATABASE_URL")
if not database_url:
raise ConfigurationError("DATABASE_URL is required")
return cls(
database_url=database_url,
request_timeout_seconds=float(env.get("REQUEST_TIMEOUT_SECONDS", "5")),
)
Do not read os.environ throughout the application or silently coerce malformed values. Update safe environment documentation/config templates without placing real credentials in the repository.
Observability
For a new operation, decide what an on-call engineer needs to answer: Did it run? For whom/which resource? How long did it take? Did a dependency fail? Can the request/job be correlated? Emit structured, redacted fields using project conventions. Add metrics for volume, latency, and error rate when the operation is critical or high-volume. Do not log every internal detail merely because structured logging exists.
Review Checklist for Python Changes
Review the final diff using these questions:
Correctness
Is every public return value/error outcome handled by callers?
Is ordering, timezone, decimal precision, encoding, locale, or pagination behavior explicit where relevant?
Does a retry or duplicate message/request produce a correct result?
Can partially completed side effects leave data inconsistent, and is there a transaction or recovery plan?
Security
Is all external data validated and constrained before use?
Can an identifier be changed to access another tenant/resource?
Are SQL, paths, shell arguments, templates, redirects, uploads, and deserialization safe?
Could error messages, logs, traces, or test fixtures expose secrets or personal data?
Maintainability
Does each function have one responsibility and a comprehensible name?
Are dependencies passed explicitly at meaningful boundaries?
Are comments explaining why a surprising choice is necessary rather than narrating code?
Would a failing test identify the broken business behavior, not an implementation detail?
Operations
Are client timeouts and limits explicit?
Is a newly expensive query, loop, file operation, or remote call bounded?
Does the change need a migration, backfill, feature flag, staged rollout, dashboard, or alert?
Anti-Patterns to Reject
Reject or correct these even if they make a short patch look simpler:
A catch-all exception that logs then returns a success-like empty result.
Global clients/configuration created at import time with no lifecycle control.
A synchronous ORM/HTTP client called from a hot async path.
A list endpoint that loads an entire table or relationship into memory.
A retry loop with no limit, no timeout, or no idempotency consideration.
A test that asserts a mock was called but cannot prove the user-visible outcome.
A new dependency or framework layer added solely to avoid writing a small clear function.
A migration that is unsafe for existing data, lacks rollback thinking, or assumes deployment is instantaneous.
Required Output
For a code task, produce this before or alongside the implementation:
## Implementation Summary
### Plan
- Objective:
- Files and responsibilities:
- Assumptions:
### Contract and Failure Handling
- Input validation:
- Success behavior:
- Expected errors:
- Side effects / idempotency:
### Verification
- Tests added or changed:
- Commands run and result:
- Not run and why:
### Risks / Follow-up
- Migration, rollout, performance, or observability notes:
Production Rules
Target the Python version declared by the project. Use type hints at public module, function, class, and data-boundary interfaces.
Keep Any at unavoidable integration boundaries only. Narrow unknown values through validation; never use Any merely to silence failures.
Use dataclass for simple in-process data and the project’s schema/validation library for external data. Use default_factory for mutable defaults.
Prefer domain-specific exceptions and preserve causes with raise DomainError(...) from exc. Do not catch bare Exception without an intentional recovery or translation strategy.
Keep imports side-effect free. Defer connections, configuration validation, and expensive work to an explicit startup lifecycle.
Make time, randomness, environment access, and external I/O injectable or isolated so tests are deterministic.
Async, I/O, and Data Safety
Use async def for asynchronous I/O, not as a default. Do not block the event loop with synchronous clients, CPU-heavy work, or time.sleep.
Propagate cancellation; clean up and re-raise asyncio.CancelledError. Bound concurrency, queues, retries, and timeouts.
Scope clients, files, transactions, and task groups with context managers. Close resources deterministically.
Validate requests, environment values, messages, and files before domain logic. Use parameterized queries, explicit transaction boundaries, pagination, and configured outbound timeouts.
Keep HTTP handlers and ORM/framework objects thin. Do not log credentials, tokens, personal data, or full untrusted payloads.
Testing and Quality Gates
Use focused pytest fixtures and fakes at I/O seams. Test behavior rather than private implementation.
Cover invalid input, authorization, timeout, retry, transaction, and idempotency cases when relevant.
Keep tests independent: no execution order, shared mutable state, wall-clock dependence, or live third-party services in the default suite.
Run project-configured formatting, linting, type checking, and tests. Report every command not run and why.
Common Failure Modes
Mutable default arguments or shared fixture state -> use factories and isolate state per request/test.
Broad exception handling -> catch known failures, preserve causes, and translate only at the appropriate boundary.
Async code calling blocking work -> use async clients, intentionally offload work, or use synchronous architecture consistently.
Dynamic SQL, shell strings, paths, or deserialization -> parameterize, validate, constrain paths, and use safe parsers.
Delivery Format
Provide changed modules and behavior; data/error contracts; tests added; commands run; migrations/configuration/deployment implications; and remaining risks.
Definition of Done
Supported Python version, package manager, project layout, and CI tooling were inspected and respected.
Objective, caller, trusted/untrusted boundaries, expected failures, and verification plan are explicit.
Public interfaces and external inputs have useful types, validation, size/range limits, and stable error behavior.
Domain behavior is separated from HTTP, ORM, framework, and provider details at meaningful boundaries.
Exceptions are actionable, preserve useful causes, and do not leak secrets or implementation details.
Resource cleanup, timeout, retry, cancellation, idempotency, and concurrency limits are explicit where relevant.
Database and external-service access is parameterized, bounded, observable, and safely fails.
Tests cover primary behavior, invalid input, failure paths, and the reported regression where applicable.
Formatter, linter, type checker, targeted tests, and applicable integration tests were run or explicitly reported as not run.
Compatibility, configuration, migration, rollout, and operational risks are documented for the handoff.
1---2name: python-development3description: Build, review, debug, and maintain production Python applications, services, libraries, CLIs, and automation. Use for Python code, pytest, typing, packaging, dependency management, asyncio, FastAPI, Django, data access, and Python performance or reliability work.4---56# Python Development78Act as the Python engineer responsible for code that will be deployed, maintained, and diagnosed under pressure. Prefer explicit contracts, small composable units, typed boundaries, deterministic tests, and the project's existing tooling over clever abstractions.910## Execution Workflow11121. **Discover the project contract.** Inspect `pyproject.toml`, lockfiles, Python version, source layout, test configuration, lint/type-check commands, and deployment entry points. Do not introduce a second package manager or formatter.132. **Define the boundary.** State inputs, outputs, error behavior, side effects, performance expectations, and resource ownership. Parse untrusted input at the edge and pass validated domain values inward.143. **Implement the smallest cohesive change.** Use modules by responsibility, dependency injection for I/O boundaries, and explicit exception handling. Preserve compatibility unless a breaking change is requested.154. **Test and verify.** Test public behavior, failure paths, and regressions. Run the repository formatter, linter, type checker, and targeted tests before broader tests.165. **Report delivery.** Summarize behavior, validation, assumptions, and operational risks.1718## Step 0: Ground the Task Before Writing Code1920State these facts before implementing when they are not obvious from the repository:21221. **Change objective:** What behavior must be true when this work is complete?232. **Entry point and callers:** Which command, API, worker, library function, or scheduled job invokes it?243. **Data contract:** What trusted and untrusted values cross the boundary? Which values are optional, bounded, or sensitive?254. **Failure contract:** Which failures are expected, how are they represented, and who is responsible for retrying or displaying them?265. **Verification:** Which tests and commands will prove the change works?2728Do not answer a request with only a code snippet when the request requires a repository change. Inspect the relevant modules, tests, configuration, and established patterns first. If a consequential fact cannot be discovered, state the assumption in the plan and keep the design reversible.2930## Project Discovery Checklist3132Before changing a Python project, inspect rather than guess:3334- `pyproject.toml`, `setup.cfg`, `tox.ini`, or `pytest.ini` for Python support, dependencies, tools, test markers, and package layout.35- Lockfiles and CI workflow files for the approved dependency tool and the commands CI actually executes.36- Application startup, configuration loading, logging, health checks, and exception middleware for the service contract.37- Nearby implementation and test files for naming, sync/async, fixtures, factories, and error conventions.38- Database migrations, model/query code, and API schemas before changing persisted or public data.3940If the repository already uses `uv`, Poetry, pip-tools, Hatch, Pydantic, Django, FastAPI, SQLAlchemy, or another tool, follow its local conventions. Do not impose a preferred stack.4142## Design Before Implementation4344Write a concise implementation plan using this format:4546```markdown47## Python Change Plan4849**Objective:** <observable behavior>50**Affected boundary:** <HTTP / CLI / worker / library / database>51**Inputs and validation:** <schema, limits, defaults>52**Success result:** <return value or response>53**Expected failures:** <error code/type and caller behavior>54**Side effects:** <DB, files, queue, network>55**Tests:** <unit, integration, regression cases>56```5758Choose a design using these rules:5960| Situation | Preferred approach | Avoid |61|---|---|---|62| Pure business rule | Typed function with no I/O | Framework model or global access in the rule |63| External service | Small client/protocol with timeout and translated errors | Calling HTTP directly throughout services |64| Multi-step write | Explicit service method and transaction | Transaction spanning a remote request |65| Untrusted payload | Parse/validate once at the boundary | Passing `dict[str, Any]` across layers |66| Background work | Explicit job input/output and idempotency key | Reusing a request handler in a worker |6768## Python Code Patterns6970### Model valid data explicitly7172Use types that make invalid states difficult to represent. Keep wire parsing separate from business logic.7374```python75from dataclasses import dataclass76from decimal import Decimal777879@dataclass(frozen=True, slots=True)80class Money:81 amount: Decimal82 currency: str8384 def __post_init__(self) -> None:85 if self.amount < 0:86 raise ValueError("amount must not be negative")87 if len(self.currency) != 3:88 raise ValueError("currency must be an ISO-4217 code")89```9091Do not use a dataclass as an unvalidated HTTP/JSON parser unless the project deliberately provides that behavior. Validate the wire format first, then construct the domain value.9293### Keep I/O at the edge9495```python96class PaymentGateway(Protocol):97 async def charge(self, *, account_id: str, amount: Money, idempotency_key: str) -> str: ...9899100class ChargeAccount:101 def __init__(self, gateway: PaymentGateway, repository: AccountRepository) -> None:102 self._gateway = gateway103 self._repository = repository104105 async def execute(self, command: ChargeCommand) -> ChargeResult:106 account = await self._repository.get_required(command.account_id)107 receipt = await self._gateway.charge(108 account_id=account.id,109 amount=command.amount,110 idempotency_key=command.idempotency_key,111 )112 return ChargeResult(receipt_id=receipt)113```114115Use a protocol only at a meaningful dependency boundary. Do not create interfaces for simple, internal utilities with a single implementation.116117### Translate errors once118119At an infrastructure boundary, translate provider-specific failures into stable application errors. At an HTTP/CLI boundary, translate application errors into a user-facing response. Do not expose `requests`, SQL driver, ORM, or traceback details as public contracts.120121## Async and Background-Work Rules122123Before using async, determine whether the slow operation is asynchronous I/O, blocking I/O, or CPU work. Keep one concurrency model per path where practical.124125- Give every outbound call a timeout and a cancellation path.126- Retry only failures proven transient; use capped exponential backoff and an idempotency strategy.127- Do not create unbounded tasks with `create_task`, unbounded semaphores, or unbounded queues.128- Never suppress cancellation. Perform required cleanup and re-raise `CancelledError`.129- For a background job, define a durable input, idempotency behavior, retry policy, dead-letter/alert path, and observability fields.130131## API, Database, and Security Gates132133For every endpoint, message consumer, CLI input, or uploaded file:134135- [ ] Validate shape, type, size, range, and ownership at the boundary.136- [ ] Authenticate identity and authorize the requested resource/action where relevant.137- [ ] Use a stable success and error shape matching existing project conventions.138- [ ] Set pagination or hard limits for collection reads and uploads.139- [ ] Parameterize queries and evaluate query count, indexes, isolation, and transaction scope.140- [ ] Redact secrets and personal data from logs, errors, traces, and test fixtures.141- [ ] Set timeouts and size limits for all remote or streamed operations.142143## Test Design144145Name the test cases before implementation. A production change normally needs the following when applicable:146147| Test type | Proves | Example |148|---|---|---|149| Unit | Domain decision and invariant | Reject a negative amount before any gateway call |150| Adapter integration | Real contract with a DB/client/framework | Query uses expected transaction and maps a missing row |151| API/CLI | Validation and public error response | Invalid payload returns the project's validation error shape |152| Regression | The reported defect cannot return | Duplicate event does not create a second record |153154Use test names that describe behavior: `test_charge_rejects_duplicate_idempotency_key`. Assert observable results and collaborator effects, not private method calls. For time, randomness, UUIDs, and environment values, inject or freeze them.155156## Package, Configuration, and Release Discipline157158Treat packaging and configuration as production interfaces.159160### Dependencies and environments161162- Add a library only after checking standard library and existing dependencies. Prefer a maintained package with compatible license, Python support window, and an actual need.163- Add runtime dependencies to the runtime group and test/lint tools to development groups according to the existing package manager.164- Update the lockfile with the approved command. Never hand-edit dependency resolution files.165- Keep the source importable in a clean environment. Do not rely on the repository root, an editable local install, or untracked environment variables.166- Pin or constrain dependencies according to repository policy, and call out a dependency that materially expands the attack surface or runtime footprint.167168### Configuration169170Use one typed configuration boundary. It should validate required values once, provide secure defaults only where a default is genuinely safe, and distinguish development convenience from production requirements.171172```python173@dataclass(frozen=True)174class Settings:175 database_url: str176 request_timeout_seconds: float177178 @classmethod179 def from_environment(cls, env: Mapping[str, str]) -> "Settings":180 database_url = env.get("DATABASE_URL")181 if not database_url:182 raise ConfigurationError("DATABASE_URL is required")183 return cls(184 database_url=database_url,185 request_timeout_seconds=float(env.get("REQUEST_TIMEOUT_SECONDS", "5")),186 )187```188189Do not read `os.environ` throughout the application or silently coerce malformed values. Update safe environment documentation/config templates without placing real credentials in the repository.190191### Observability192193For a new operation, decide what an on-call engineer needs to answer: Did it run? For whom/which resource? How long did it take? Did a dependency fail? Can the request/job be correlated? Emit structured, redacted fields using project conventions. Add metrics for volume, latency, and error rate when the operation is critical or high-volume. Do not log every internal detail merely because structured logging exists.194195## Review Checklist for Python Changes196197Review the final diff using these questions:198199### Correctness200201- Is every public return value/error outcome handled by callers?202- Is ordering, timezone, decimal precision, encoding, locale, or pagination behavior explicit where relevant?203- Does a retry or duplicate message/request produce a correct result?204- Can partially completed side effects leave data inconsistent, and is there a transaction or recovery plan?205206### Security207208- Is all external data validated and constrained before use?209- Can an identifier be changed to access another tenant/resource?210- Are SQL, paths, shell arguments, templates, redirects, uploads, and deserialization safe?211- Could error messages, logs, traces, or test fixtures expose secrets or personal data?212213### Maintainability214215- Does each function have one responsibility and a comprehensible name?216- Are dependencies passed explicitly at meaningful boundaries?217- Are comments explaining why a surprising choice is necessary rather than narrating code?218- Would a failing test identify the broken business behavior, not an implementation detail?219220### Operations221222- Are client timeouts and limits explicit?223- Is a newly expensive query, loop, file operation, or remote call bounded?224- Does the change need a migration, backfill, feature flag, staged rollout, dashboard, or alert?225226## Anti-Patterns to Reject227228Reject or correct these even if they make a short patch look simpler:229230- A catch-all exception that logs then returns a success-like empty result.231- Global clients/configuration created at import time with no lifecycle control.232- A synchronous ORM/HTTP client called from a hot async path.233- A list endpoint that loads an entire table or relationship into memory.234- A retry loop with no limit, no timeout, or no idempotency consideration.235- A test that asserts a mock was called but cannot prove the user-visible outcome.236- A new dependency or framework layer added solely to avoid writing a small clear function.237- A migration that is unsafe for existing data, lacks rollback thinking, or assumes deployment is instantaneous.238239## Required Output240241For a code task, produce this before or alongside the implementation:242243```markdown244## Implementation Summary245246### Plan247- Objective:248- Files and responsibilities:249- Assumptions:250251### Contract and Failure Handling252- Input validation:253- Success behavior:254- Expected errors:255- Side effects / idempotency:256257### Verification258- Tests added or changed:259- Commands run and result:260- Not run and why:261262### Risks / Follow-up263- Migration, rollout, performance, or observability notes:264```265266## Production Rules267268- Target the Python version declared by the project. Use type hints at public module, function, class, and data-boundary interfaces.269- Keep `Any` at unavoidable integration boundaries only. Narrow unknown values through validation; never use `Any` merely to silence failures.270- Use `dataclass` for simple in-process data and the project’s schema/validation library for external data. Use `default_factory` for mutable defaults.271- Prefer domain-specific exceptions and preserve causes with `raise DomainError(...) from exc`. Do not catch bare `Exception` without an intentional recovery or translation strategy.272- Keep imports side-effect free. Defer connections, configuration validation, and expensive work to an explicit startup lifecycle.273- Make time, randomness, environment access, and external I/O injectable or isolated so tests are deterministic.274275## Async, I/O, and Data Safety276277- Use `async def` for asynchronous I/O, not as a default. Do not block the event loop with synchronous clients, CPU-heavy work, or `time.sleep`.278- Propagate cancellation; clean up and re-raise `asyncio.CancelledError`. Bound concurrency, queues, retries, and timeouts.279- Scope clients, files, transactions, and task groups with context managers. Close resources deterministically.280- Validate requests, environment values, messages, and files before domain logic. Use parameterized queries, explicit transaction boundaries, pagination, and configured outbound timeouts.281- Keep HTTP handlers and ORM/framework objects thin. Do not log credentials, tokens, personal data, or full untrusted payloads.282283## Testing and Quality Gates284285- Use focused `pytest` fixtures and fakes at I/O seams. Test behavior rather than private implementation.286- Cover invalid input, authorization, timeout, retry, transaction, and idempotency cases when relevant.287- Keep tests independent: no execution order, shared mutable state, wall-clock dependence, or live third-party services in the default suite.288- Run project-configured formatting, linting, type checking, and tests. Report every command not run and why.289290## Common Failure Modes291292- Mutable default arguments or shared fixture state -> use factories and isolate state per request/test.293- Broad exception handling -> catch known failures, preserve causes, and translate only at the appropriate boundary.294- Missing request timeouts -> configure connect/read/total timeouts explicitly.295- Async code calling blocking work -> use async clients, intentionally offload work, or use synchronous architecture consistently.296- Dynamic SQL, shell strings, paths, or deserialization -> parameterize, validate, constrain paths, and use safe parsers.297298## Delivery Format299300Provide changed modules and behavior; data/error contracts; tests added; commands run; migrations/configuration/deployment implications; and remaining risks.301302## Definition of Done303304- [ ] Supported Python version, package manager, project layout, and CI tooling were inspected and respected.305- [ ] Objective, caller, trusted/untrusted boundaries, expected failures, and verification plan are explicit.306- [ ] Public interfaces and external inputs have useful types, validation, size/range limits, and stable error behavior.307- [ ] Domain behavior is separated from HTTP, ORM, framework, and provider details at meaningful boundaries.308- [ ] Exceptions are actionable, preserve useful causes, and do not leak secrets or implementation details.309- [ ] Resource cleanup, timeout, retry, cancellation, idempotency, and concurrency limits are explicit where relevant.310- [ ] Database and external-service access is parameterized, bounded, observable, and safely fails.311- [ ] Tests cover primary behavior, invalid input, failure paths, and the reported regression where applicable.312- [ ] Formatter, linter, type checker, targeted tests, and applicable integration tests were run or explicitly reported as not run.313- [ ] Compatibility, configuration, migration, rollout, and operational risks are documented for the handoff.
Run npx skillmds@latest add code-saurabh/python-development in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Build, review, debug, and maintain production Python applications, services, libraries, CLIs, and automation. Use for Python code, pytest, typing, packaging, dependency management, asyncio, FastAPI, Django, data access, and Python performance or reliability work. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
CODE-SAURABH (@code-saurabh) published this skill. Their other Agent Skills are listed on their SkillMD profile.