build-python-library
Skill4 starsChanged 6 months agoApache-2.0View on GitHub
Implements pip-installable Python libraries from scratch using src layout, pyproject.toml, and pytest. Use when the user asks to build, create, implement, or scaffold a Python library, package, pip package, middleware, SDK, or wrapper. Covers project scaffolding, proxy/wrapper patterns, provider-agnostic interfaces, async/sync support, and test infrastructure.
- Installs packages
In this repository57 other files it gives its agents.
- autopilotSkill
- build-temporalSkill
- canon-design-reviewSkill
- canon-pr-reviewSkill
- canon-reviewSkill
- ccr-modelsSkill
- ccr-runSkill
- chartSkill
- ci-health-reportSkill
- code-quality-trendsSkill
- competitive-matrixSkill
- councilSkill
- create-skillSkill
- deep-debug-ensemble-v1Skill
- deep-debugSkill
- deep-designSkill
- deep-ideaSkill
- deep-planSkill
- deep-qa-ensemble-v1Skill
- deep-qaSkill
- deep-researchSkill
- dependency-auditSkill
- deploy-status-reportSkill
- develop-board-gameSkill
- diagramSkill
- docxSkill
- dora-lite-reportSkill
- find-skillSkill
- flaky-test-diagnoserSkill
- gap-finderSkill
- gen-crash-testSkill
- gen-smokeSkill
- goal-managerSkill
- init-github-repoSkill
- loop-until-doneSkill
- magic-fetchSkill
- ml-pipeline-reportSkill
- monitorSkill
- napSkill
- pipeline-health-reportSkill
- platform-friction-detectorSkill
- pptxSkill
- prod-readinessSkill
- prompt-clash-ensembleSkill
- prompt-clashSkill
- retrospectSkill
- slack-digestSkill
- slidesSkill
- specSkill
- sprint-retroSkill
- tableSkill
- team-temporalSkill
- timelineSkill
- update-stop-gateSkill
- user-activity-reportSkill
- vc-gauntletSkill
- xlsxSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Before delivering, verify ALL:
- Very specific: line 50
Src layout always: Every project uses src/packagename/ structure.
- Very specific: line 51
Test before you proceed: Never implement module N+1 until module N has passing tests.
- Very specific: line 53
Type hints on every signature: Every function parameter and return type must have a type annotation.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Build Python Library
Implements pip-installable Python libraries by scaffolding the project structure, building core abstractions with adapters, and verifying each module with pytest before proceeding.
Workflow
- Scaffold the project — create src layout, pyproject.toml, package structure, and py.typed marker. See SCAFFOLDING.md.
- Define the public API — write
__init__.pywith explicit exports and__all__. Only types and functions users need. See SCAFFOLDING.md. - Implement core abstractions — build protocols/ABCs, data classes, and shared types that all concrete implementations depend on. See PATTERNS.md.
- Test core abstractions — write pytest tests for core types and protocols. Run
pytestand verify zero failures before proceeding. See TESTING.md. - Implement concrete modules — build one module at a time (proxy wrappers, provider clients, adapters). See PATTERNS.md.
- Test each module before the next — write tests for the module just implemented. Run
pytestand verify zero failures before starting the next module. See TESTING.md. - Install and verify — run
pip install -e ".[dev]"and verify the package imports correctly from a clean script. See TESTING.md. - Run full test suite — run
pytest -vand verify all tests pass, then runpython -c "from packagename import ..."to verify public API. See TESTING.md.
Self-review checklist
Before delivering, verify ALL:
- Project uses src layout:
src/packagename/notpackagename/at root pyproject.tomlexists with[build-system],[project], and[project.optional-dependencies]py.typedmarker file exists in the package directory__init__.pyhas explicit__all__listing only public names- Every public function and class has a type-hinted signature (all parameters and return type)
- Every module has a corresponding test file (
src/pkg/foo.py→tests/test_foo.py) pytest -vpasses with zero failurespip install -e ".[dev]"succeedspython -c "from packagename import ..."imports all public API names without error- No third-party imports in core modules that lack a corresponding optional dependency group
- Proxy/wrapper classes delegate unknown attributes via
__getattr__to the wrapped object
Golden rules
Hard rules. Never violate these.
- Src layout always. Every project uses
src/packagename/structure. Never place the package at the repository root. This prevents accidental imports from the source directory instead of the installed package. - Test before you proceed. Never implement module N+1 until module N has passing tests. Run
pytestafter each module. This catches integration errors early instead of at the end. - Explicit public API.
__init__.pymust define__all__and import only the names users need. Internal modules start with underscore (_internal.py) or live in a_private/subdirectory. Never expose implementation details. - Type hints on every signature. Every function parameter and return type must have a type annotation. Use
Protocolfor duck-typed interfaces, notABCunless you need shared implementation. - Optional dependencies in extras. Third-party framework imports (langchain, chromadb, openai) must be in
[project.optional-dependencies]groups and imported lazily with try/except at usage point, not at module top level. - Proxy delegates everything. Wrapper classes must implement
__getattr__to forward unknown attribute access to the wrapped object. Never enumerate and re-implement every method — the proxy must work with future methods the wrapped library adds.
Reference files
| File | Contents |
| SCAFFOLDING.md | Project structure template, pyproject.toml template, init.py patterns, py.typed setup |
| PATTERNS.md | Proxy/wrapper pattern, provider-agnostic interfaces, async/sync dual support, lazy imports |
| TESTING.md | pytest configuration, fixture patterns, mocking external services, test-per-module workflow, install verification |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

