meta-pytorch/torchrec/docstring
Claude Code and agent skill by meta-pytorch/torchrec
- community
Checking that the SKILL.md file is still in the repository.
Write docstrings for TorchRec functions and methods following PyTorch conventions. Use when writing or updating docstrings in TorchRec code.
Install
npx vskill@latest install meta-pytorch/torchrec/docstringSKILL.md
The same SKILL.md was published earlier as meta-pytorch/torchrec/docstring.
TorchRec Docstring Writing Guide
This skill describes how to write docstrings for functions and methods in the TorchRec project, following PyTorch conventions.
General Principles
- Use raw strings (
r"""...""") for all docstrings to avoid issues with LaTeX/math backslashes - Follow Sphinx/reStructuredText (reST) format for documentation
- Be concise but complete - include all essential information
- Always include examples when possible
- Use cross-references to related functions/classes
Docstring Structure
1. Function Signature (First Line)
Start with the function signature showing all parameters:
Notes:
- Include the function name
- Show positional and keyword-only arguments (use
*separator) - Include default values
- Show return type annotation
- This line should NOT end with a period
2. Brief Description
Provide a one-line description of what the function does:
3. Mathematical Formulas (if applicable)
Use Sphinx math directives for mathematical expressions:
Or inline math: :math:\x^2\``
4. Cross-References
Link to related classes and functions using Sphinx roles:
:class:\~torchrec.modules.EmbeddingBagCollection\`` - Link to a class:func:\torchrec.distributed.sharding.shard\`` - Link to a function:meth:\~Module.forward\`` - Link to a method:attr:\attribute_name\`` - Reference an attribute- The
~prefix shows only the last component
Example:
5. Notes and Warnings
Use admonitions for important information:
6. Args Section
Document all parameters with type annotations and descriptions:
Formatting rules:
- Parameter name in lowercase
- Type in parentheses:
(Type),(Type, optional)for optional parameters - Description follows the type
- For optional parameters, include "Default: `
value`" at the end - Use double backticks for inline code: ``
None`` - Indent continuation lines by 4 spaces
7. Returns Section
Document the return value:
8. Raises Section (if applicable)
Document exceptions that may be raised:
9. Examples Section
Always include examples when possible:
Formatting rules:
- Use
Examples::with double colon - Use
>>>prompt for Python code - Include comments with
#when helpful - Show actual output when it helps understanding
TorchRec-Specific Patterns
Embedding Configuration
Sharding-Related
KeyedJaggedTensor
Complete Example
Quick Checklist
When writing a TorchRec docstring, ensure:
- [ ] Use raw string (
r""") - [ ] Include function signature on first line
- [ ] Provide brief description
- [ ] Document all parameters in Args section with types
- [ ] Include default values for optional parameters
- [ ] Use Sphinx cross-references (
:func:,:class:,:meth:) - [ ] Add mathematical formulas if applicable
- [ ] Include at least one example in Examples section
- [ ] Add warnings/notes for experimental APIs
- [ ] Document any exceptions in Raises section
- [ ] Use proper math notation for tensor shapes
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtorchrec/.claude/skills/docstring/SKILL.md
Popularity
- Repository stars
- 2,570
- Repository forks
- 661
- 7-day trend score
- 39
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/meta-pytorch/torchrec/docstring)