No slash command · from ceh-python-library
Load this skill when setting up a Python library's environment or code style: uv dependencies, pyproject.toml, type hints, docstrings, naming, ruff/mypy. Trigger on a pyproject.toml edit or a uv command.
Ships in ceh-python-library. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Keep a library's environment on uv, with a minimal runtime dependency set and one lint and type
config. Done when ruff and mypy pass and pyproject.toml matches the config below.
uv run, and change dependencies only with uv add / uv sync, so
every run uses the one environment uv.lock pins and a stray pip install cannot drift it..venv/ (managed by uv)pyproject.toml | Lockfile: uv.lock (never edit manually)| Action | Command |
|---|---|
| Install all dependencies | uv sync |
| Add a production dependency | uv add <package> |
| Add a dev dependency | uv add --dev <package> |
| Run any command | uv run <command> |
| Run tests | uv run pytest |
| Lint | uv run ruff check . |
| Format | uv run ruff format . |
| Type check | uv run mypy . |
Never edit uv.lock manually. Never commit .env.
Keep the runtime dependency set minimal — a library inherits onto every consumer. Do not add web-service
dependencies (fastapi, uvicorn, asyncpg); those belong to applications, not libraries.
pyproject.toml configuration:
[project]
name = "your-library"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [] # keep minimal; every dependency is imposed on consumers
[tool.ruff]
line-length = 88
[tool.ruff.lint]
select = ["E", "F", "I", "UP", "N", "B"]
[tool.ruff.lint.isort]
known-first-party = ["your_library"]
[tool.mypy]
strict = true
python_version = "3.12"
ignore_missing_imports = false
[tool.pytest.ini_options]
# Only when the library has async code, with pytest-asyncio as a dev dependency. Without the
# plugin pytest warns "Unknown config option: asyncio_mode".
# asyncio_mode = "auto"
pyproject.tomlAny only with a comment explaining whyDocstrings (Google style, required on all public symbols):
def parse_duration(text: str) -> timedelta:
"""Parses a human duration string into a timedelta.
Args:
text: Duration like "1h30m" or "45s".
Returns:
The parsed timedelta.
Raises:
ValueError: If the string cannot be parsed.
"""
One-line summary, then Args / Returns / Raises sections as needed. Omit sections that don't apply.
ruff for linting and formatting (do not add flake8, pylint, isort, or Black: one tool and one config cannot disagree with itself). mypy for type checking.
Required before every PR:
uv run ruff check .
uv run ruff format --check .
uv run mypy .
Give every # type: ignore a comment. Keep strict = true when errors appear.
Run ruff on every commit, so lint and format errors never reach a PR. Install once per clone with
uv add --dev pre-commit and uv run pre-commit install. The hooks call ruff through uv run, so
they use the version uv.lock pins rather than a second copy pinned in the hook config:
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: ruff-check
name: ruff check
entry: uv run ruff check --fix
language: system
types: [python]
- id: ruff-format
name: ruff format
entry: uv run ruff format
language: system
types: [python]
mypy stays out of the hook: it checks the whole program, which is too slow for every commit, so it
runs before the PR. A hook that rewrites a file aborts the commit: re-stage and commit again. Never
commit with --no-verify to get past a hook.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cheneeheng/ceh-claude-code-library --plugin ceh-python-library3 skills in this plugin
/publish-python-libraryLoad this skill when packaging, versioning, or publishing a Python library: build backend, src/ layout, wheels, PyPI, the public API in __init__.py / __all__, deprecations, semver. Trigger on a build config or __all__ edit, a changed public signature, or a uv build run./write-pytest-library-testsLoad this skill when writing pytest tests for a Python library: unit tests, public-API tests, fixtures, and what to mock versus test for real. Trigger on a test file created or modified.Other plugins' skills for the same job