From probabl-skills
Places ruff.toml from bundled template, runs ruff on edited Python files, and rewrites comments to be problem-specific rather than scaffold prose.
How this skill is triggered — by the user, by Claude, or both
Slash command
/probabl-skills:python-code-styleThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Single owner of "what does well-styled Python look like in this
Single owner of "what does well-styled Python look like in this stack": ruff (lint + format) and numpydoc docstrings. This skill is explicitly manual — Claude runs ruff on the files it has just touched, no hook involved.
update-config — but the default is "Claude runs ruff itself."black / isort / flake8 /
pydocstyle / pylint. Ruff is the canonical linter in this
stack (data-science-python-stack Tier 1). If import ruff /
pixi run ruff --version fails, route through python-env-manager
to install — don't silently fall back.ruff check
reports issues after Claude's first fix, address them once. If the
same issue persists after the second pass, stop editing that
file and surface the remaining diagnostics + diff to the user.
This is the anti-infinite-loop guardrail — do not enter a third
cycle on the same warning.src/<pkg>/, experiments/, audit/, data/eda.py (the
explore-ml-data EDA script), top-level *.py scripts, and any
package directory the user owns. Skip vendored paths, generated
files, the rest of user-owned data/, and anything under .pixi/,
.venv/, node_modules/, etc.ruff.toml from memory. The bundled
templates/ruff.toml is the single source of truth — it encodes
the per-file ignores (experiments/**), the numpydoc convention,
and the rule selection this stack expects. Initial setup requires
Read .agents/skills/python-code-style/templates/ruff.toml
this turn, then Write <project-root>/ruff.toml verbatim from
that file's content. Authoring a custom ruff.toml from training-
data memory drops half the contract silently. If you catch
yourself typing [lint] / [format] / select = [...] without
having read the template this turn, STOP and Read it first.warnings.filterwarnings(...) unless the user
explicitly asks for it. Same for warnings.simplefilter,
@pytest.mark.filterwarnings, and filterwarnings = [...] in
pytest.ini / pyproject.toml. Warnings are signal in this
stack.G-*), the cell runner, the run
digest, the journal / backlog / design-note machinery, or "the
process we are following". That guidance is agent-facing and lives
in the skills, not in the user's files. When you touch a file that
now carries real content, rewrite any leftover generic template
or workflow prose into concise, problem-specific docs grounded in
the current context (the project goal, the experiment's hypothesis,
the dataset). If the file is still an empty skeleton (no content /
no context yet), leave its placeholder — the contextualization
happens when the content lands. Details: § "Contextualize the
comments".Pre-flight (python-code-style):
- [ ] ruff importable in the project's env (`pixi run ruff --version`
succeeds, per `data-science-python-stack` Tier 1)
- [ ] `ruff.toml` present at project root.
If absent AND stack + workspace are already set up: the
bundled template MUST be read **this turn** before being
written verbatim.
Evidence: Read .agents/skills/python-code-style/templates/ruff.toml
(this turn) + Write <project-root>/ruff.toml (this turn)
| "n/a — ruff.toml already at project root"
**Inline-authored ruff.toml from memory is NOT evidence.**
- [ ] File list ready: <abs paths of .py files touched this turn>
- [ ] Decision recorded: this is the first ruff pass on these files
(proceed) | second pass (proceed but stop on persistent
issues) | third pass on same warning (STOP, surface to user)
- [ ] One-fix-per-file rule acknowledged: max two passes per warning,
then surface remaining diagnostics + diff to the user.
- [ ] Comments contextualized: each touched file with real content has
problem-specific docs and NO workflow/skill/gate/runner/digest
meta (§ "Contextualize the comments")
Evidence: per file, "rewrote header to <problem context>" |
"no leftover template/workflow prose" |
"n/a — empty skeleton, no context yet"
ruff format + ruff check --fix + ruff check on Python files Claude has just generated or edited;
authoring numpydoc docstrings on public functions and classes;
contextualizing each touched file's comments to the data-science
problem and stripping workflow/process meta (§ "Contextualize the
comments"); dropping the ruff.toml template into a fresh project.For every Python file touched this turn (call them <files>), run
inside the project's environment manager — pixi run for pixi
projects, equivalent for uv / poetry / conda (per
python-env-manager):
pixi run ruff format <files>
pixi run ruff check --fix <files>
pixi run ruff check <files>
Three steps, in order:
ruff format — applies the formatter (line length, quoting,
trailing commas, blank lines around defs). Idempotent.ruff check --fix — auto-fixes everything ruff knows how to
fix in place: import sorting (I), legacy syntax (UP),
detectable bug patterns (B).ruff check (no --fix) — final pass. Anything reported
here needs Claude's attention: missing docstrings (D),
undefined names (F), code structure issues. Address them, then
re-run the trio. Apply the one-fix-per-file rule from Stop
conditions.If a file under experiments/ or audit/, or the data/eda.py
EDA script, has a D100 ("missing module docstring") or D103
("missing function docstring") warning, that's expected for # %%
cells; the bundled ruff.toml per-file-ignores D100 + D103
(and E402, B018) for experiments/**, audit/**, and
data/eda.py. If you're seeing them, the ruff.toml isn't loaded
— check that it lives at the project root.
Audit files (audit/<NN>_<short_name>.py, owned by
audit-ml-pipeline) and the EDA script (data/eda.py, owned by
explore-ml-data) lint the same way as experiment files: same
# %% cell convention, same per-file ignores, same NumPyDoc
convention for any helper functions. After writing or editing one of
these files, run the same trio (ruff format → ruff check --fix
→ ruff check).
ruff makes a file well-formed; this pass makes it well-documented for the problem. Templates ship with neutral placeholders and a little authoring scaffolding so the generating skill knows what each cell / module is for. None of that should survive into the user's committed file — the user's files document the data-science problem, not the process that produced them.
After the ruff trio, for every touched file that now carries real content, do a quick documentation pass:
<placeholder>
or generic header with a one- or two-line description of what this
file does here: the experiment's hypothesis (experiment.py),
what this module contributes to the pipeline (src/<pkg>/*.py),
which report this file reviews and what it tests
(audit/<stem>.py), what the dataset is and what the analysis
looks at (data/eda.py). Pull the wording from the live context —
the project goal, the approved design note, the dataset.G-*), § cross-references, "the agent",
"the (cell) runner", "the digest", "run cell by cell", journal /
backlog / sourcing jargon, and inline guard-rails like "MUST NOT
call put / bare expressions, don't print". Those guard-rails
stay enforced — they live in the owning skill's SKILL.md, which is
where the agent reads them, not in the user's file.# %%)
and any remaining <...> placeholders the agent still has to fill
stay until they are filled.The result should read like a colleague wrote the file for this
project — not like a generated scaffold. Skip a file that is still an
empty skeleton (e.g. a freshly scaffolded src/<pkg>/*.py with no
body yet): there is no context to write about until the content
lands, and the contextualization happens on the edit that fills it.
This pass is owned here so the rule is enforced uniformly. Every file-writing skill already hands off to this skill after a write; that hand-off now also covers contextualizing the comments.
Public functions and classes carry numpydoc-format docstrings; ruff's
D rules with pydocstyle.convention = "numpy" enforce the shape.
A bare one-line summary is NOT sufficient for public functions.
The Parameters / Returns (and Raises when applicable) sections
are mandatory — even when the function is small, even when the user
says "just the summary is fine". Approving a one-line docstring on
a public function silently fails the contract this skill enforces;
the function looks D-rule-clean (D100/D103 don't fire) but the
parameter shapes and return type that callers actually need are
missing. Private helpers (_leading_underscore) are the only
exception: the default D rules allow them to omit docstrings, but
public callable surfaces always carry the full numpydoc shape.
Skeleton:
def predict_price(X, model, *, n_jobs=1):
"""Predict option prices from a feature matrix.
Parameters
----------
X : pandas.DataFrame
Feature matrix with one row per option.
model : sklearn.base.BaseEstimator
Fitted estimator with a ``predict`` method.
n_jobs : int, default=1
Number of parallel jobs.
Returns
-------
numpy.ndarray of shape (n_samples,)
Predicted prices, one per row of ``X``.
"""
Conventions worth surfacing because they're non-obvious:
numpy convention it
is, so write the period.X : ndarray of shape (n_samples, n_features).Returns section lists the return value; if there are
multiple returns, list each on its own row. Don't omit the type._leading_underscore) don't need a docstring
under the default D rules — ruff allows that.experiments/** per the bundled ruff.toml.ruff.toml templateWhen this skill is invoked on a fresh project that has no
ruff.toml at its root and the stack + workspace have been
scaffolded by their respective skills:
Read .agents/skills/python-code-style/templates/ruff.toml.
The pre-flight Evidence row for the ruff.toml present check
requires this read; an inline-authored config from memory does
not satisfy it.<project-root>/ruff.toml.
No edits, no "improvements", no rule additions. The template
encodes the per-file ignores (experiments/**), the
pydocstyle.convention = "numpy" setting, and the rule
selection this stack expects. Diverging from it drops half the
contract.pixi run ruff check --show-settings . should report the numpy convention and the select list
from the template.Do not fold ruff config into pyproject.toml automatically — the
project may not have one, or the user may prefer a separate file.
The standalone ruff.toml is unambiguous.
Forbidden shortcuts:
| Shortcut | Why it's wrong |
|---|---|
| "I know what ruff.toml should contain" → author from memory | The bundled template carries experiments/** per-file ignores, the numpydoc convention, and a curated rule selection. Memory misses these and the contract silently breaks |
| Read this skill's SKILL.md text describing the template → write from that | The SKILL.md describes; the template file is. Read the file itself, write it verbatim |
A common case: Claude edits one function in a file that already had
unrelated D-rule violations. Ruff will report those too.
This keeps PR scope tight and avoids "while I was here" expansion that the user didn't ask for.
data-science-python-stack — owns the decision that ruff is
Tier 1 mandatory; this skill assumes ruff is already installed.
If pixi run ruff --version fails, return there for the install.python-env-manager — turns "ruff is missing" into the right
install command for the project's manager. Don't run pip install ruff in a pixi project.organize-ml-workspace — sets up the directory layout that
the bundled ruff.toml's per-file ignores (experiments/** and
audit/**) reference. Drop the template after this skill has
run, so the paths it ignores actually exist.audit-ml-pipeline — generates audit files at
audit/<NN>_<short_name>.py. This skill's per-file ignores
cover the audit/ path the same way they cover experiments/.explore-ml-data — generates the EDA script data/eda.py
(same # %% cell convention). The bundled ruff.toml
per-file-ignores data/eda.py exactly like audit/**; lint it
with the same trio after writing it.update-config — only relevant if the user explicitly asks
for an automated lint hook later. Default is no hook.ruff.toml lives at the project
root and is the single source of truth. Don't add per-directory
overrides unless the user asks.npx claudepluginhub probabl-ai/skills --plugin probabl-skillsConfigures Python linting, formatting, type checking, and docstring standards using ruff and mypy/pyright. Use when setting up project tooling, reviewing code style, or enforcing PEP 8 conventions.
Integrates Ruff into VS Code editors, pre-commit hooks, and GitHub Actions CI/CD pipelines for Python linting and formatting workflows.
Lints, formats, and analyzes Python code with ruff. Covers rule selection, config, and migration from flake8/black/isort.