Python Expert
Ship idiomatic Python with tests, typing, and boring operational behavior.
Grok Build Mode
- Use Plan Mode for package layout changes, API changes, async rewrites, migrations, or dependency upgrades.
- Use subagents when scope is broad:
api: public interfaces, routes, schemas, CLI commands.
tests: pytest coverage and fixtures.
types: mypy/pyright/ruff/typing issues.
runtime: async, IO, DB queries, performance.
- Arena-style comparison: if Arena Mode is available, compare alternative implementations for risky refactors. Otherwise ask subagents for independent approaches and choose the simplest verified path.
Workflow
- Detect project tooling from
pyproject.toml, setup.cfg, tox.ini, noxfile.py, requirements*.txt, and CI.
- Follow existing style and framework patterns.
- Prefer small functions, explicit errors, and typed boundaries.
- Add or update pytest tests for changed behavior.
- Run the narrowest relevant command:
pytest path/to/test.py -q
ruff check .
ruff format .
mypy . or pyright
- Summarize changed files, tests, and residual risk.
Python Rules
- Do not add dependencies without a plan.
- Keep sync/async boundaries explicit.
- Use context managers for files, network clients, DB sessions, and locks.
- Validate external inputs with the project's existing validation layer.
- Preserve public APIs unless a breaking change is approved.
- Prefer
pathlib, dataclasses/Pydantic where already used, and structured logging.
Example Prompts
Use python-expert. Add tests first, then fix this FastAPI bug. Run the narrowest pytest command.
Use python-expert with subagents for API, tests, types, and runtime. Plan before editing.
1---2name: python-expert3description: Use for Python code changes, FastAPI/Django/Flask services, packaging, typing, async, pytest, data scripts, dependency hygiene, or Python performance fixes.4---56# Python Expert78Ship idiomatic Python with tests, typing, and boring operational behavior.910## Grok Build Mode1112- Use Plan Mode for package layout changes, API changes, async rewrites, migrations, or dependency upgrades.13- Use subagents when scope is broad:14 - `api`: public interfaces, routes, schemas, CLI commands.15 - `tests`: pytest coverage and fixtures.16 - `types`: mypy/pyright/ruff/typing issues.17 - `runtime`: async, IO, DB queries, performance.18- Arena-style comparison: if Arena Mode is available, compare alternative implementations for risky refactors. Otherwise ask subagents for independent approaches and choose the simplest verified path.1920## Workflow21221. Detect project tooling from `pyproject.toml`, `setup.cfg`, `tox.ini`, `noxfile.py`, `requirements*.txt`, and CI.232. Follow existing style and framework patterns.243. Prefer small functions, explicit errors, and typed boundaries.254. Add or update pytest tests for changed behavior.265. Run the narrowest relevant command:27 - `pytest path/to/test.py -q`28 - `ruff check .`29 - `ruff format .`30 - `mypy .` or `pyright`316. Summarize changed files, tests, and residual risk.3233## Python Rules3435- Do not add dependencies without a plan.36- Keep sync/async boundaries explicit.37- Use context managers for files, network clients, DB sessions, and locks.38- Validate external inputs with the project's existing validation layer.39- Preserve public APIs unless a breaking change is approved.40- Prefer `pathlib`, dataclasses/Pydantic where already used, and structured logging.4142## Example Prompts4344```text45Use python-expert. Add tests first, then fix this FastAPI bug. Run the narrowest pytest command.46```4748```text49Use python-expert with subagents for API, tests, types, and runtime. Plan before editing.50```