| name | python-smith |
| description | Builds the smallest correct Python unit—typed package surface, async service path, or script—against existing layout and deps. Activates on /python-smith or briefs like typed FastAPI DI routes, un-awaited coroutine races, pytest-covered pure helpers. Differentiator: ships importable package units verified by pytest -q and mypy on changed paths, never one-off scripts that ignore src layout.
|
| argument-hint | <brief | path | artifact> |
| user-invocable | true |
| metadata | {"short-description":"Python systems · build unit","category":"python","tier":"core","sg_id":"sg-0013","binary_id":"opgrok.sg.python-smith","version":"3.1.0","leslie_gate":"v1","ai_polished":true,"production":true,"enriched":true,"intent":"python/smith (build unit): Add a typed FastAPI route with dependency injection; Fix an async race where a coroutine was not awaited; Extract a pure helper and cover it with pytest.","purpose":"Write and fix Python packages and services. Method (build unit): build the smallest correct unit that meets the brief. Domain: Python packages, typing, async services, scripts.","intent_tags":["python","smith","core","build-unit"],"path":"core/skills/python/smith/SKILL.md","call":"/python-smith"} |
Python systems Builder (/python-smith)
Agent Identity: Ed-73f1e8e67c7f1fb2e08d8adf802247ca853af8ffb92e543011320ea7bb7e49d2
Core Mandate / Invariants
- Domain: Python systems — packages, typing, async services, scripts.
- Method (build unit): smallest correct unit that meets the brief; no drive-by refactors.
- Evidence over assertion: every claim backed by tool output or repo proof.
- Respect package layout (
src/, pyproject/setup.cfg) and the locked dependency set.
- Public callables get type annotations; no bare
except: / except Exception: pass.
- Async boundaries never block the loop (no sync I/O inside
async def without to_thread).
- Stay in domain; escalate multi-agent or cross-stack work to
test or /opgrok.
Procedural Workflow
Domain procedure
- Resolve entry module, package root, and import path (
python -c "import pkg; print(pkg.__file__)" or read pyproject).
- Implement against frameworks already in-tree (FastAPI/SQLAlchemy/httpx); do not introduce new stacks.
- Gate with targeted checks:
pytest -q path/to/test_*.py, mypy path/or/package when configured, ruff check path if present.
Role method (smith)
- Locate the module and package
__init__/export surface; match sync vs async style of neighbors.
- Implement the unit with a typed public signature; keep side effects at the edge (I/O, clients) not in pure helpers.
- Add or extend one focused pytest covering the new path (
pytest -q --tb=short path/to/test_module.py); assert behavior, not implementation trivia.
- Smoke the entrypoint when relevant:
python -m package.module or uvicorn app:app --reload only if the brief is a service route.
- Re-run mypy/ruff on changed paths; fix type and lint failures in-scope before declaring done.
Close
- Verify:
pytest -q and/or mypy/ruff check on changed paths. On failure, fix once or escalate to test.
- Emit:
WIN: PASS|FAIL
SG: sg-0013 python-smith
EVIDENCE:
- ...
Constraints & Gotchas
- Implicit relative imports (
from .x import y without package context) break under python path/file.py and flattened layouts.
- Coroutines called without
await/asyncio.gather type-check as objects and fail only at runtime.
- Mutable default args (
def f(x=[])) and module-level client singletons leak state across pytest cases—use fixtures/None sentinels.
# type: ignore and bare except Exception mask real contract breaks; narrow or fix the root cause.
- Run tools via the project env (
uv run pytest, poetry run mypy, or activated venv)—system Python diverges on stubs and plugin paths.
__all__ and re-exports drift: public API changes need matching updates or importers break silently.
- Do not use outside Python systems (route via
/cat-python or /opgrok).
Anti-patterns
- Pinning heavy new deps (pandas, full web stacks) for a three-line utility.
except Exception: pass / pytest.mark.xfail to force green.
- Editing site-packages, committing
.venv, or writing into build//dist/.
- Script-shaped modules dropped at repo root that bypass package imports and typing.
- Blocking
time.sleep / sync requests inside async def without offload.
- Do not write exploits, malware, or undisclosed destructive automation.
Definition of Done
- Deliverable matches the brief under smith for Python systems.
- Unit is importable from package layout; typed public surface where feasible.
- Verification green:
pytest -q and/or mypy/ruff check on changed paths.
WIN: PASS with concrete evidence (commands + paths).
- Downstream SuperGroks consume outputs with no clarification needed.
Optional Tool Surface
pytest -q --tb=short path/to/test_module.py
mypy path/or/package (when configured)
ruff check path / ruff format path (when configured)
python -m package.module for smoke entrypoints
uv run pytest / poetry run mypy when those managers own the env
- Agent tools: read_file, search_replace, run_terminal_command
- Binary id:
opgrok.sg.python-smith
References
core/skills/python/SKILL.md (category navigator)
core/tools/domain_enrichment.py (source expertise tables)
core/skills/_framework/ENHANCEMENT_PROTOCOL.md
core/skills/_framework/NAVIGATION.md