/hep-python-tools:code-quality-toolsfrom hep-python-tools
Sets up code quality tooling for HEP Python projects: pre-commit hooks, Ruff linting/formatting, mypy type checking, and CI linter debugging.
Ships in hep-python-tools. 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.
The Scientific Python community standard for code quality is:
All three are configured in pyproject.toml (ruff, mypy) and
.pre-commit-config.yaml. Run locally with pixi run pre-commit or
pre-commit run --all-files.
| Tool | Role | Config location |
|---|---|---|
| pre-commit | Orchestrates all hooks; runs in isolated envs | .pre-commit-config.yaml |
| ruff-format | Auto-formatter (Black-compatible, 30× faster) | [tool.ruff] in pyproject.toml |
| ruff-check | Linter; replaces flake8, isort, pyupgrade, etc | [tool.ruff.lint] in pyproject.toml |
| mypy | Static type checker | [tool.mypy] in pyproject.toml |
| codespell | Spell checker for code and docs | .pre-commit-config.yaml |
Hook execution order matters: put auto-fixers (ruff-format, ruff-check
--fix) before linters that may fail on unfixed code.
.pre-commit-config.yamlrepos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v5.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: name-tests-test
args: ["--pytest-test-first"]
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.0"
hooks:
- id: ruff-format
- id: ruff-check
args: ["--fix", "--show-fixes"]
- repo: https://github.com/codespell-project/codespell
rev: "v2.4.1"
hooks:
- id: codespell
additional_dependencies: ["tomli; python_version<'3.11'"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.15.0"
hooks:
- id: mypy
files: src
args: []
Keep rev: pinned to fixed tags; update with pre-commit autoupdate.
pyproject.toml[tool.ruff]
src = ["src"]
[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear — catches common bug patterns
"I", # isort — sorted imports
"UP", # pyupgrade — modernize syntax
"RUF", # Ruff-specific rules
"NPY", # NumPy-specific rules
]
ignore = [
"PLR2004", # magic value comparisons (common in HEP cuts)
]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["T20"] # allow print() in tests
pyproject.toml[tool.mypy]
files = "src"
python_version = "3.11"
strict = true
warn_unreachable = true
enable_error_codes = ["ignore-without-code", "redundant-expr", "truthy-bool"]
[[tool.mypy.overrides]]
module = ["awkward.*", "uproot.*", "hist.*", "ROOT.*"]
ignore_missing_imports = true
Start with strict = false and enable incrementally if adding mypy to a large
existing codebase. Add [[tool.mypy.overrides]] blocks for HEP libraries that
lack type stubs.
# With pixi
pixi run pre-commit run --all-files
# Without pixi
pre-commit run --all-files
# Update all hook versions
pre-commit autoupdate
ruff-format first so the
formatter fixes style before the linter sees the code.ignore_missing_imports = true
per package.--fix in ruff-check is safe: it makes changes that you review via
git diff; --show-fixes explains what it changed.rev: pins weekly — worth enabling at pre-commit.ci for shared projects.PLR2004)
frequently false-positive on physics cuts like pt > 30; add to ignore or
suppress per line with # noqa: PLR2004.hist, gaus, Eta may be
flagged. Suppress with [tool.codespell] ignore-words-list = ["hist", "gaus"]
in pyproject.toml.pixi run pre-commit wraps the hook runner; define a task in
pixi.toml so contributors don't need to install pre-commit globallynox -s lint is an alternative entry point for CI that doesn't
require pre-commit to be installedpre-commit run --all-files directly, or use
the managed pre-commit.ci serviceWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub usatlas/marketplace --plugin hep-python-tools6 skills in this plugin
/cli-creatorUse when building a Python command-line interface with Typer: adding arguments and options to a script, creating subcommands, wiring an entry point into pyproject.toml, validating CLI inputs with callbacks, or adding a CLI layer to an existing analysis script or HEP workflow./pytest-speedupUse when a pytest suite is slow and needs speeding up: profiling slow tests, reducing collection time, parallelizing with pytest-xdist or pytest-split, selecting a subset of tests to run, blocking inadvertent network or large-file disk access in HEP tests, or optimizing CI test run time./python-packagingUse when creating a new Python package, adding pyproject.toml to an existing project, choosing a build backend, setting up src layout, configuring VCS-based versioning, or managing a development environment with pixi or uv for a HEP Python project.