| name | python-development |
| description | Implement, refactor, or fix Python code in Digital Life using the repository's Python 3.11 coding standards, layer boundaries, security rules, and risk-based pytest workflow. Use whenever a task creates or changes Python production code or Python tests. |
Python Development Workflow
Use the project-owned rules below.
Load
- Read
docs/development/python-coding-standards.md.
- Read
docs/development/python-testing-and-review.md.
- Read
docs/architecture/current-system.md when ownership or dependencies matter.
- Read only the target modules, their callers or consumers, and related tests.
Implement
- Confirm the requested behavior, affected contracts, and owning layer.
- Preserve unrelated work and mutable
apps/{id}/data/.
- Add or update a focused behavior or regression test when behavior changes.
- Implement the smallest coherent change using existing project patterns.
- Type new or changed public interfaces and validate external data at boundaries.
- Synchronize affected contract consumers and durable documentation.
- Run focused tests first, then expand according to risk.
- Review the changed Python against the security and completion checklists.
Mandatory Rules
- Keep domain rules free of HTTP, CLI, UI, and concrete persistence details.
- Use parameterized SQL, safe path handling, safe parsing, and existing secret paths.
- Do not silently swallow exceptions. Broad catches require a deliberate boundary
and defined fallback.
- Avoid hidden shared mutation; use immutable domain contracts where appropriate.
- Do not block async paths or leak instance context.
- Do not mass-format or refactor unrelated legacy Python.
Verification
Run relevant available commands:
python3 -m pytest path/to/relevant_test.py
python3 -m compileall -q path/to/changed_module.py
ruff check path/to/changed.py
ruff format --check path/to/changed.py
Do not claim optional tools passed when they are unavailable. Report focused tests,
broader checks, documentation updates, and remaining risks.