google-docstring-crafter
Google Style Python Docstring
This skill provides expertise in writing Python documentation and comments according to the Google Python Style Guide. Proper documentation ensures code is understandable by both humans and automated tools like pydoc and pytype.
Core Instructions
- Prioritize Intent Over Mechanics: Focus on why a function or class exists and how it should be used. Avoid mechanically repeating the code's logic.
- Standard Format: Use the three-double-quote
"""format for all docstrings. - Structured Sections: Use explicit sections for
Args:,Returns:, andRaises:to maintain a consistent structure across the project. - Consistency is Key: Whether you choose imperative or descriptive style, ensure it's consistent within each file.
Audit Checklist
When reviewing or writing documentation, use the following checklist:
- Does every module, class, and public function have a docstring?
- Does the first line consist of a concise, one-line summary terminated by a period?
- Is there a blank line after the summary if the description continues?
- Are all parameters listed in the
Args:section with correct indentation? - Is the return value documented in
Returns:(orYields:for generators)? - Are all relevant exceptions listed in the
Raises:section? - For classes, is there an
Attributes:section for public attributes? - Are inline comments positioned at least 2 spaces from the code and descriptive of the intent?
Simple Example
def fetch_data(url: str, timeout: int = 10) -> dict:
"""Fetches data from the given URL.
Detailed explanation of fetching logic, including timeout behavior.
Args:
url: The URL to fetch data from.
timeout: The maximum time in seconds to wait for a response.
Returns:
A dictionary containing the JSON response.
Raises:
ConnectionError: If the network request fails.
Examples:
>>> fetch_data("https://google.com")
{'status': 'ok'}
"""
pass
Detailed References
Refer to these guides for specific formatting rules:
- Module Docstrings: Formatting for file headers and test modules.
- Function & Method Docstrings: Formatting for
Args,Returns, andRaises. - Class Docstrings: Formatting for class summaries and
Attributes. - Block & Inline Comments: Rules for readability and content.
Templates
Modules
Classes
Functions & Methods
More from zenless-lab/skills
python-docstring-expert
Expert methodology for evaluating, formatting, and generating Python docstrings. Use when creating or updating documentation for Python code, determining if a docstring is necessary based on API exposure, or formatting docstrings for modules, classes, and functions. Load this skill when code changes affect existing docstrings to keep them synchronized.
16cloud-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".
7