agentleFS
npownpow/claude-skills/build-python-library/SKILL.md

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

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
  1. Distinctive:

    Before delivering, verify ALL:

    line 32
  2. Very specific:

    Src layout always: Every project uses src/packagename/ structure.

    line 50
  3. Very specific:

    Test before you proceed: Never implement module N+1 until module N has passing tests.

    line 51
  4. Very specific:

    Type hints on every signature: Every function parameter and return type must have a type annotation.

    line 53

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Scaffold the project — create src layout, pyproject.toml, package structure, and py.typed marker. See SCAFFOLDING.md.
  2. Define the public API — write __init__.py with explicit exports and __all__. Only types and functions users need. See SCAFFOLDING.md.
  3. Implement core abstractions — build protocols/ABCs, data classes, and shared types that all concrete implementations depend on. See PATTERNS.md.
  4. Test core abstractions — write pytest tests for core types and protocols. Run pytest and verify zero failures before proceeding. See TESTING.md.
  5. Implement concrete modules — build one module at a time (proxy wrappers, provider clients, adapters). See PATTERNS.md.
  6. Test each module before the next — write tests for the module just implemented. Run pytest and verify zero failures before starting the next module. See TESTING.md.
  7. Install and verify — run pip install -e ".[dev]" and verify the package imports correctly from a clean script. See TESTING.md.
  8. Run full test suite — run pytest -v and verify all tests pass, then run python -c "from packagename import ..." to verify public API. See TESTING.md.

Self-review checklist

Before delivering, verify ALL:

  • Project uses src layout: src/packagename/ not packagename/ at root
  • pyproject.toml exists with [build-system], [project], and [project.optional-dependencies]
  • py.typed marker file exists in the package directory
  • __init__.py has 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 -v passes with zero failures
  • pip install -e ".[dev]" succeeds
  • python -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.

  1. 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.
  2. Test before you proceed. Never implement module N+1 until module N has passing tests. Run pytest after each module. This catches integration errors early instead of at the end.
  3. Explicit public API. __init__.py must 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.
  4. Type hints on every signature. Every function parameter and return type must have a type annotation. Use Protocol for duck-typed interfaces, not ABC unless you need shared implementation.
  5. 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.
  6. 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

FileContents
SCAFFOLDING.mdProject structure template, pyproject.toml template, init.py patterns, py.typed setup
PATTERNS.mdProxy/wrapper pattern, provider-agnostic interfaces, async/sync dual support, lazy imports
TESTING.mdpytest configuration, fixture patterns, mocking external services, test-per-module workflow, install verification

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.