docstring
Skill441 starsChanged 3 months agoApache-2.0View on GitHub
Write or review docstrings for public modules, classes, and functions in sdm/. Use when adding or reviewing docstrings to follow repo best practices (Args sections, paper citations, tensor shape notation).
We split this skill into the rules it gives an agent
11 rules. 0 are common, 4 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Use this when writing or reviewing docstrings for public modules, classes, and functions in sdm/.
- Distinctive: line 9
Follow these best practices up front to keep docstrings consistent across the codebase.
- Distinctive: line 13
Keep docstrings as minimal as possible and avoid documenting implementation details.
- Very specific: line 14
Do not add module-level docstrings to individual modules.
- Very specific: line 15
Every public class and function has a docstring, a one-line summary, then an Args: section.
- Distinctive: line 16
When a class or function implements functionality proposed in an academic paper, cite it in the first sentence of its docstring.
- Very specific: line 17
Document every public parameter, especially, constructor parameters.
- Very specific: line 18
Use r"""...""" whenever the docstring contains math, LaTeX, or backslashes (e.g., a ..
- Very specific: line 20
If splitting a long line leads to a line-too-long error, put # noqa: <code> to ignore the error.
- Distinctive: line 21
Document non-obvious behavior: implicit caps, defaults, transformations, or side effects that affect results.
- Very specific: line 102
Run uv run ruff check. This is a structural backstop only: it flags missing public class/method/function docstrings, capitalization, end …
“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Docstring Writing and Reviewing Guide
Use this when writing or reviewing docstrings for public modules, classes, and functions in sdm/.
Follow these best practices up front to keep docstrings consistent across the codebase.
General Principles
- Keep docstrings as minimal as possible and avoid documenting implementation details.
- Do not add module-level docstrings to individual modules; keep only a short package summary in the package
__init__.py. - Every public class and function has a docstring, a one-line summary, then an
Args:section. - When a class or function implements functionality proposed in an academic paper, cite it in the first sentence of its docstring.
- Document every public parameter, especially, constructor parameters. Document them in the class docstring's
Args:, not in__init__. - Use
r"""..."""whenever the docstring contains math, LaTeX, or backslashes (e.g., a.. math::block). - Describe tensor parameters with their shape in double-backtick notation, using a leading
...for the batch dimensions (e.g.,[..., S, H, C]). Spell out each remaining dimension letter, and keep the notation consistent across related processors/modules. - If splitting a long line leads to a line-too-long error, put
# noqa: <code>to ignore the error. - Document non-obvious behavior: implicit caps, defaults, transformations, or side effects that affect results. If it would surprise a caller, state it.
- Do not add docstrings to methods that already have one in superclass's methods even if the class/methods are public. For example,
Processor.transform()already has a general docstring that's applicable to its subclasses. In this case, put a comment# noqa: D102to ignore the linter error.
Example
class MyClass:
r"""My Class from the `"My Paper" <https://arxiv.org/abs/2602.11139>`_ paper.
.. math::
y = \frac{x}{\sqrt{d}}
Args:
fill_value: Value written into masked positions. Capped at ``1.0``;
larger values are silently clamped.
"""
def __init__(self, fill_value: float) -> None:
...
def forward(self, x: Tensor) -> Tensor:
"""Normalize ``x`` along its last dimension.
Args:
x: Input tensor with shape ``[..., S, C]``.
Returns:
Tensor with shape ``[..., S, C]``.
"""
def citation(self) -> str:
"""Return the key from :func:`sdm.refs.resolve_default_citation_key`.""" # noqa: E501Sphinx Cross-Referencing Reference
The same roles resolve internal sdm targets and external ones. Prefer
cross-reference roles over plain literals, e.g.,
""":class:`pandas.DataFrame`"""over
"""``pandas.DataFrame``"""whenever the target lives in an intersphinx-mapped project (python, torch, numpy,
pandas, pyarrow, cudf, typing_extensions; see intersphinx_mapping
in docs/source/conf.py).
r"""
- :mod:`sdm.nn`: Module reference.
- :class:`~sdm.nn.Module`: Class reference. External targets use the same
role: :class:`pandas.DataFrame`, :class:`torch.nn.Module`, :class:`dict`,
:class:`TypeError`, :class:`collections.abc.Mapping`.
- :class:`~pyarrow.Array`: Leading ``~`` renders only ``Array``. Use it in
summary lines; keep the full path in ``Args:`` entries.
- :meth:`~sdm.nn.Module.forward`: Method reference.
- :func:`torch.nn.functional.scaled_dot_product_attention`: Function
reference. Use :func: for free functions and :meth: only for methods.
- :attr:`attribute`: Attribute reference.
- :math:`equation`: Inline math.
- :ref:`label`: Internal label reference.
- :ref:`calling convention <torch-dispatch-calling-convention>`: External
label reference with custom link text, resolved through intersphinx.
- :external+torch:ref:`torch.int32 <dtype-doc>`: Label reference pinned to a
specific project's inventory. Use for targets without their own API entry
(e.g., dtypes like ``torch.int32`` resolve to the ``dtype-doc`` label).
Never guess label names: search the linked documentation for a fitting
target by dumping the project's inventory, e.g.
``uv run --no-default-groups --group doc python -m sphinx.ext.intersphinx https://docs.pytorch.org/docs/stable/objects.inv | grep -i dtype``.
"""Verification
Run uv run ruff check. This is a structural backstop only: it flags missing public class/method/function docstrings, capitalization, end punctuation, r""" for backslashes, and Args:/signature mismatches.
It does not require an Args: section to exist, or verify citations, shape notation, or behavior notes — confirm those by hand against the principles above.
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- pytorch/pytorch★ 105ksame name
- pipecat-ai/pipecat★ 17ksame name
- nilecui/SkillsBase★ 27same name
- Pradnyeshp/Claude-Skills★ 2same name
- Jinbae10/skills★ 0same name
- llp-dev/claude-skills★ 0same name
- llp42/claude-skills★ 0same name
- sissc0731/claude-code-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use lint-fix, changelog and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SentrySkilllint-fix
Fix violations of an eslintPluginScraps rule across the codebase. Use when asked to "fix lint violations", "apply a lint rule", "fix scraps rule errors", "roll out a lint rule", "enforce a rule codebase-wide", or "fix design system lint". Covers manual fixes, autofix, batching, and codemod strategies for large-scale rollouts.
Also in 3 projects that use this
HashiCorpSkillchangelog
Add a `.changelog/<PR_NUMBER>.txt` entry for a GitHub Pull Request, commit, and push.
Also in 5 projects that use this
SentrySkillcommit
Create commit messages following Sentry conventions. Use when committing code changes, writing commit messages, or formatting git history. Follows conventional commits with Sentry-specific issue references.
Also in 3 projects that use this
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- port-external-modelsSkill
- processor-developmentSkill
- recipe-developmentSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

