From python-library-distribution
Reviews and improves Python library code quality using ruff linting, mypy type checking, Pythonic refactoring idioms, and type hint patterns.
How this skill is triggered — by the user, by Claude, or both
Slash command
/python-library-distribution:code-qualityThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
| Tool | Purpose | Command |
| Tool | Purpose | Command |
|---|---|---|
| ruff | Lint + format | ruff check src && ruff format src |
| mypy | Type check | mypy src |
Minimal config in pyproject.toml:
[tool.ruff]
line-length = 88
target-version = "py310"
[tool.ruff.lint]
select = ["E", "W", "F", "I", "B", "C4", "UP"]
For full configuration options, see RUFF_CONFIG.md.
[tool.mypy]
python_version = "3.10"
disallow_untyped_defs = true
warn_return_any = true
For strict settings and overrides, see MYPY_CONFIG.md.
# Basic
def process(items: list[str]) -> dict[str, int]: ...
# Optional
def fetch(url: str, timeout: int | None = None) -> bytes: ...
# Callable
def apply(func: Callable[[int], str], value: int) -> str: ...
# Generic
T = TypeVar("T")
def first(items: Sequence[T]) -> T | None: ...
For protocols and advanced patterns, see TYPE_PATTERNS.md.
# Bad: Mutable default
def process(items: list = []): # Bug!
...
# Good: None default
def process(items: list | None = None):
items = items or []
...
# Bad: Bare except
try:
...
except:
pass
# Good: Specific exception
try:
...
except ValueError as e:
logger.error(e)
# Iteration
for item in items: # Not: for i in range(len(items))
for i, item in enumerate(items): # When index needed
# Dictionary access
value = d.get(key, default) # Not: if key in d: value = d[key]
# Context managers
with open(path) as f: # Not: f = open(path); try: finally: f.close()
# Comprehensions (simple only)
squares = [x**2 for x in numbers]
src/my_library/
├── __init__.py # Public API exports
├── _internal.py # Private (underscore prefix)
├── exceptions.py # Custom exceptions
├── types.py # Type definitions
└── py.typed # Type hint marker
Code Quality:
- [ ] ruff check passes
- [ ] mypy passes (strict mode)
- [ ] Public API has type hints
- [ ] Public API has docstrings
- [ ] No mutable default arguments
- [ ] Specific exception handling
- [ ] py.typed marker present
This skill is based on the Code Quality section of the Guide to Developing High-Quality Python Libraries by Will McGinnis. See these posts for deeper coverage:
npx claudepluginhub wdm0006/python-skills --plugin python-library-completeConfigures Ruff for linting and formatting, mypy or pyright for type checking, pre-commit hooks, lint rule sets, and modern Python typing patterns like PEP 695.
Sets up Python code quality toolchain with ruff linting/formatting, mypy type checking, complexity gating, dead code detection, pre-commit hooks, pyproject.toml config, and Makefile targets.
Configures ruff/mypy for Python linting/formatting, enforces PEP 8 naming/docstrings/type hints. Use for new projects, code reviews, or style standards.