agentleFS
extractumioextractumio/extractum-skills/.cursor/rules/40-docstrings.mdc

extractum-skills / rules

Cursor rule44 starsChanged 10 months agoMITView on GitHub

Docstring and documentation standards

  • Reads credentials

The file

We split this 40-docstrings.mdc into the rules it gives an agent

6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every Python file must have a module-level docstring:

    line 13
  2. Distinctive:

    Use Google-style docstrings for functions:

    line 28
  3. Distinctive:

    Use period at the end of single-line docstrings

    line 97
  4. Distinctive:

    Use blank line after the summary in multi-line docstrings

    line 98
  5. Distinctive:

    Keep lines under 80 characters when possible

    line 99
  6. Distinctive:

    Use imperative mood ("Create...", "Return...", "Validate...")

    line 100

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
40-docstrings.mdc
---
description: "Docstring and documentation standards"
globs:
  - "**/*.py"
alwaysApply: false
priority: 5
---

# Docstring Standards

## Module Docstrings

Every Python file must have a module-level docstring:

```python
"""
Claude Code Agent SDK - RAG Agent Script.

This script demonstrates how to use the Claude Agent SDK to run an AI agent
that can interact with files and execute commands.
"""
```

---

## Function Docstrings

Use Google-style docstrings for functions:

### Simple Functions

```python
def _log_separator(logger: logging.Logger) -> None:
    """Log a separator line."""
    logger.info(SEPARATOR_CHAR * SEPARATOR_LENGTH)
```

### Functions with Arguments

```python
async def run_agent(prompt: str, logger: logging.Logger) -> AgentResultSummary:
    """
    Run the Claude agent with the given prompt.

    Args:
        prompt: The prompt/command for the agent to execute.
        logger: Logger instance for output.

    Returns:
        Dictionary containing the result summary.

    Raises:
        ValueError: If ANTHROPIC_API_KEY is not set.
        Exception: If agent execution fails.
    """
```

---

## Class and TypedDict Docstrings

```python
class AgentResultSummary(TypedDict, total=False):
    """Type definition for agent execution result summary."""
    
    prompt: str
    messages: list[dict[str, Any]]
    total_cost_usd: float
    num_turns: int
    success: bool
```

---

## Private Function Docstrings

Even private functions (prefixed with `_`) should have docstrings:

```python
def _validate_api_key() -> None:
    """Validate that the API key is available in environment."""
    ...

def _create_agent_options() -> ClaudeAgentOptions:
    """Create and return agent options with default configuration."""
    ...

def _format_tool_use(block: ToolUseBlock) -> str:
    """Format a tool use block as a readable string."""
    ...
```

---

## Docstring Formatting

- Use period at the end of single-line docstrings
- Use blank line after the summary in multi-line docstrings
- Keep lines under 80 characters when possible
- Use imperative mood ("Create...", "Return...", "Validate...")

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.