/scientific-python-development:code-quality-tools runs instead · from scientific-python-development
Configures ruff, mypy, and pre-commit for scientific Python projects. Covers linting rules, type checking, formatting, and CI integration.
This skill never runs in Claude Code
It ships in scientific-python-development at skills/, but /scientific-python-development:code-quality-tools (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
pixi add --feature dev ruff mypy pre-commit # recommended
pip install ruff mypy pre-commit # pip fallback
# Ruff
ruff check . # lint
ruff check --fix . # lint + auto-fix
ruff format . # format
ruff check --fix . && ruff format . # full quality pass
# MyPy
mypy src/ # type-check project
mypy --strict src/ # strict mode
# Pre-commit
pre-commit install # register git hook (once per clone)
pre-commit run --all-files # run on whole repo
pre-commit autoupdate # bump hook versions
pyproject.toml (scientific Python)[tool.ruff]
target-version = "py310"
line-length = 88
[tool.ruff.lint]
select = ["E", "F", "I", "B", "UP", "NPY"]
ignore = ["E501"]
fixable = ["ALL"]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
[tool.ruff.lint.pydocstyle]
convention = "numpy"
[tool.mypy]
python_version = "3.10"
check_untyped_defs = true
warn_return_any = true
show_error_codes = true
[[tool.mypy.overrides]]
module = ["scipy.*", "matplotlib.*", "numpy.*"]
ignore_missing_imports = true
.pre-commit-config.yamlrepos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.0
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
hooks:
- id: mypy
args: [--ignore-missing-imports]
See assets/pyproject-ruff-mypy.toml and assets/pre-commit-config.yaml for complete annotated templates (including nbstripout, check-yaml, check-toml, pandas-vet rules, etc.).
| Reference | Contents |
|---|---|
references/configuration-patterns.md | Ruff rule selection for scientific Python (NPY, PD, D, ANN); mypy strictness ladder; per-file ignores; fixing common warnings (F401, B006, NPY002) |
references/type-hints.md | Gradual adoption strategy; NDArray[np.float64] patterns; Optional/Union; TypedDict for structured returns |
references/common-issues.md | ruff vs black conflicts; mypy missing imports; pre-commit slow on large repos; too many legacy errors; CI failures |
Non-obvious gotchas:
E501 (line too long): disable it — ruff format manages line length and they conflict if both are active.NPY002: flags np.random.rand() as legacy; the fix is np.random.default_rng(seed=...).random(). Worth enabling for reproducibility in scientific code.ignore_missing_imports: set per-module in [[tool.mypy.overrides]], not globally — global ignores hide real errors in your own code.--ignore-missing-imports in pre-commit args or keep mypy in CI only.ruff check --add-noqa . to baseline all existing violations with # noqa comments, then enforce clean code going forward. Remove # noqa comments incrementally.from __future__ import annotations: required as the first import for any file using forward references or X | Y union syntax on Python < 3.10.A sequenced checklist with validation steps.
pixi add --feature dev ruff mypy pre-commit
Verify: ruff --version && mypy --version && pre-commit --version
pyproject.tomlCopy the minimal config from the Quick Reference Card above, adjusting target-version to match your Python support floor.
Verify:
ruff check . # should report errors (not crash)
mypy src/ # should report errors or "Success"
ruff check --fix . # auto-fix what ruff can
ruff format . # apply formatting
For a legacy codebase with many errors: ruff check --add-noqa . to baseline, then commit.
Verify: ruff check . returns zero errors.
.pre-commit-config.yaml and install hook# Create the file (use asset template or minimal snippet above)
pre-commit install
pre-commit run --all-files # first-run check of entire repo
Verify: running git commit on a dirty file now triggers ruff automatically.
# .github/workflows/quality.yml
- name: Lint
run: ruff check .
- name: Format check
run: ruff format --check .
- name: Type check
run: mypy src/
Verify: CI passes on a clean branch; a branch with a deliberate type error fails the mypy step.
Start with check_untyped_defs = true only. Add type hints to new functions. Once coverage is reasonable, enable disallow_untyped_defs = true. See references/type-hints.md for NumPy array annotation patterns.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
5 skills in this plugin
/pixi-package-managerUse when the user works with pixi (pixi.toml, pixi.lock, pixi add/run/task/global/exec) or wants a reproducible scientific Python environment that mixes conda-forge and PyPI packages: creating environments, adding dependencies, defining tasks, multi-platform lockfiles, or migrating from conda environment.yml / requirements.txt. Not for pure uv/pip projects or for building and publishing packages to PyPI (use python-packaging)./python-packagingCreate and publish distributable scientific Python packages following Scientific Python community best practices. Covers pyproject.toml, src layout, Hatchling, metadata, CLI entry points, and PyPI publishing. Use when the user wants to create a new Python package, set up pyproject.toml, configure Hatchling, publish to PyPI, or follow Scientific Python packaging standards./python-testingUse when writing or organizing tests for scientific Python code, or when the user mentions pytest, test fixtures, parametrization, numerical assertions, or property-based testing. Write and organize tests for scientific Python packages using pytest. Covers fixtures, parametrization, numerical testing with NumPy utilities, property-based testing with Hypothesis, and CI integration.Generated from the plugin's indexed repository (uw-ssec/savvy) — no native marketplace selected
npx claudepluginhub p/uw-ssec-scientific-python-development-plugins-scientific-python-developmentOther plugins' skills for the same job