python-docstring-expert
Python Docstring Expert
You are an expert in determining when and how to write Python docstrings. Your primary goal is to ensure documentation adds value without creating noise or redundant "over-documentation".
Core Guidelines
- Check Project Guidelines: Always adhere to
AGENTS.mdor project-specific instruction documents first. - Keep Sync: If you modify code, updating the associated docstrings is the highest priority. Contradictory docstrings are worse than no docstrings at all. Outdated docstrings are harmful.
- Evaluate Necessity (Do not over-document):
- Public APIs (exported modules, classes, functions, public methods) and Complex Logic require docstrings.
- Private APIs and Simple/Self-Documenting Code should omit docstrings or use standard inline comments (
#). If a single-line docstring just repeats the function name, delete it. Code clarity through good naming always takes precedence over docstrings.
- Component Rules:
- Modules: Provide a high-level overview. Do NOT list members unless required. Often unnecessary unless using code-as-documentation.
- Classes: Summarize behavior. Document constructor (
__init__) parameters in the class docstring, NOT in__init__. - Functions/Methods: Summarize behavior, detail args, returns, and exceptions.
- Formatting:
- Single-line:
"""Summary on one line."""(Keep"""on the same line, end with period). - Multi-line: Start with a summary line, a blank line, then details, and close with
"""on its own line.
- Single-line:
- Tone & Doctests:
- Match existing codebase tone (declarative vs. imperative) or fallback to PEP 257 (imperative mood, e.g., "Return X", not "Returns X").
- Doctests are for illustration, not comprehensive edge-case testing.
Advanced References & Templates
Only load these references if you need deeper guidance on a specific topic.
- references/evaluation.md: Detailed criteria for when to write docstrings based on exposure and complexity.
- references/components.md: Detailed rules on what to document for modules, classes, and functions.
- references/formatting_and_tone.md: Detailed rules for single/multi-line formats, doctest philosophy, and voice/tone.
Templates
- assets/module_templates.py: Examples of module-level docstrings.
- assets/class_templates.py: Examples of class docstrings, including
__init__parameter placement. - assets/function_templates.py: Examples of single-line, multi-line, and private function docstrings/comments.
More from zenless-lab/skills
cloud-init-crafter
Expert assistant for creating, modifying, and debugging cloud-init scripts. Supports multiple formats (YAML, shell, MIME archives), Jinja templating with instance-data, and multi-platform validation.
9readme-crafter
Use this skill when you need to write, refactor, or improve a project's README.md file. Trigger this anytime the user wants to create documentation, project overviews, or profile pages following best practices and modern aesthetics.
8skill-expert
Comprehensive master guide for designing, creating, editing, updating, and refactoring Agent Skills according to the official agentskills.io specification. Use this when you need to build or modify capabilities for an AI agent.
8agents-md-crafter
Use this skill when you need to create, update, or improve AI agent instruction files like AGENTS.md, GEMINI.md, or copilot-instructions.md. Trigger this anytime the user wants to set up standard AI rules, document project context for LLMs, or add repository-wide guidelines for AI agents.
8skill-crafter
Use this skill when creating a new skill or when modifying, updating, refactoring, restructuring, or reviewing an existing skill. Trigger it for framework-specific and framework-agnostic skill work, including SKILL.md design, folder layout, scripts, references, assets, metadata, and description optimization, even if the user only says "make a skill", "improve this skill", or "refactor the skill".
7secret-scanner
Use this skill when instructed to perform a security scan, find leaked secrets, or check for PII in the codebase or git diffs. Trigger this even if the user broadly asks to check for security issues, leaked credentials, passwords, API tokens, emails, or sensitive data before committing.
7