astroville/sprout / .claude/skills/python-stack
python-stack
UnverifiedPython implementation guidance for project structure, type safety, dependency management, testing, and operational correctness.
Focus areas
- Use type hints consistently (PEP 484/526/604). Prefer
str | NoneoverOptional[str]in Python 3.10+. - Structure projects with clear package boundaries:
src/layout or flat layout, consistent__init__.pyusage. - Prefer
pyproject.tomloversetup.py/setup.cfgfor project metadata and build configuration. - Use virtual environments (
venv,uv, orpoetry) — never install into the system Python. - Handle errors explicitly: catch specific exceptions, avoid bare
except:, use custom exception hierarchies when the domain warrants it.
Dependency management
- Pin dependencies for applications (lock files via
pip-compile,poetry.lock, oruv.lock). - Use version ranges for libraries.
- Prefer standard library when it covers the need adequately.
- Audit transitive dependencies when adding new packages.
Testing
- Use
pytestas the default test runner. - Prefer fixtures over setup/teardown methods.
- Use
unittest.mockorpytest-mockfor mocking — mock at boundaries, not internals. - Structure tests to mirror source layout:
tests/parallel tosrc/. - Use
parametrizefor data-driven tests rather than duplicating test functions.
Async
- Use
asynciofor I/O-bound concurrency. Do not use threads for I/O unless interacting with blocking libraries. - Prefer
async/awaitover callback patterns. - Use
asyncio.TaskGroup(3.11+) orasyncio.gatherfor concurrent tasks. - Avoid mixing sync and async code — use
asyncio.to_threadwhen calling blocking functions from async context.
Guardrails
- Avoid mutable default arguments (
def f(x=[])is a classic bug). - Avoid global mutable state.
- Prefer
dataclassesorpydanticmodels over raw dicts for structured data. - Use
pathlib.Pathoveros.pathfor file system operations. - Prefer f-strings over
%formatting or.format(). - Watch for import cycles — restructure packages rather than using lazy imports as a workaround.
- Use
loggingmodule, notprint(), for operational output. - Be explicit about encoding when reading/writing files (
open(..., encoding="utf-8")).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |