Docstring AI — Python Docstrings, Offline + AI
autoDocstring-compatible skeletons — plus AI that actually fills them in.

Docstring AI generates Python docstrings in VS Code two ways:
- Skeleton mode — instant, fully offline. Type
""" under a function and
get a correctly structured skeleton built from the signature and body:
parameters, types, defaults, returns/yields, raised exceptions.
- AI mode — optional, bring your own API key. One command sends the
function to your model (Anthropic or any OpenAI-compatible endpoint) and
inserts a docstring with real descriptions, formatted in your chosen style.
If you used autoDocstring (unmaintained for years), this is the drop-in
workflow you already know — same trigger, same styles, same skeleton behavior —
under active maintenance, with AI as a strictly opt-in extra.
Before / after
def fetch_rows(query: str, limit: int = 100, *, retries: int = 3) -> list[dict]:
if not query:
raise ValueError("empty query")
return _run(query, limit, retries)
Type """ on the line below the signature, accept Generate Docstring, and
skeleton mode inserts (Google style):
def fetch_rows(query: str, limit: int = 100, *, retries: int = 3) -> list[dict]:
"""_summary_
Args:
query (str): _description_
limit (int, optional): _description_. Defaults to 100.
retries (int, optional): _description_. Defaults to 3.
Returns:
list[dict]: _description_
Raises:
ValueError: _description_
"""
if not query:
raise ValueError("empty query")
return _run(query, limit, retries)
Every _summary_ / _description_ / _type_ is a snippet tabstop — Tab
through and fill them in. Or run Docstring AI: Generate with AI and the
placeholders arrive already written.
Skeleton mode vs AI mode
|
Skeleton mode |
AI mode |
| Trigger |
""" below a signature, command, or context menu |
Command or context menu |
| Network |
None — fully offline |
Your configured provider only |
| API key |
Not needed |
Your own key (Anthropic or OpenAI-compatible) |
| Output |
Structured skeleton with tabstops |
Complete docstring with real descriptions |
| Types |
From your type hints — never invented |
From your type hints — never invented |
| Cost |
Free |
Whatever your provider charges (a short haiku-class call) |
Both modes support Google, NumPy, and Sphinx formats, functions,
async functions, methods, and classes (attributes are collected from
__init__ assignments and class-level annotations).
Commands
| Command |
What it does |
Docstring AI: Generate Docstring |
Skeleton for the definition under the cursor (replaces an existing docstring) |
Docstring AI: Generate with AI |
AI-written docstring for the definition under the cursor |
Docstring AI: Choose AI Provider & Model |
Pick a provider/model preset — writes the AI settings for you |
Docstring AI: Set API Key |
Store your key in VS Code Secret Storage |
Docstring AI: Clear API Key |
Remove the stored key |
Settings
| Setting |
Default |
Description |
docstringAi.style |
google |
Docstring format: google, numpy, or sphinx |
docstringAi.includeTypes |
true |
Include types from type hints. Unhinted params get a _type_ placeholder — types are never invented |
docstringAi.quoteStyle |
""" |
Docstring delimiter: """ or ''' |
docstringAi.aiProvider |
anthropic |
anthropic or openai-compatible |
docstringAi.aiModel |
claude-haiku-4-5 |
Model id sent to the provider |
docstringAi.aiBaseUrl |
https://api.openai.com/v1 |
Base URL for openai-compatible (ignored for anthropic) |
You rarely need to edit the three AI settings by hand: run Docstring AI:
Choose AI Provider & Model and pick a preset — it writes them for you
(globally) and offers to store your API key if none is set yet.
| Preset |
Writes |
| Anthropic — Claude Haiku 4.5 · fast & cheap |
anthropic / claude-haiku-4-5 |
| Anthropic — Claude Sonnet 5 · highest quality |
anthropic / claude-sonnet-5 |
| Google — Gemini 3.7 Flash · current default |
openai-compatible / gemini-3.7-flash @ https://generativelanguage.googleapis.com/v1beta/openai |
| Google — Gemini 3.5 Flash-Lite · cheapest |
openai-compatible / gemini-3.5-flash-lite @ same base URL |
| OpenAI — enter a model id |
openai-compatible @ https://api.openai.com/v1, model id you type |
| Custom OpenAI-compatible endpoint… |
Base URL + model id you type (Ollama, OpenRouter, vLLM, LM Studio, …) |
Privacy — where your code goes
- Skeleton mode never touches the network. Parsing and generation run
entirely inside the extension host. You can use it on an air-gapped machine.
- Code leaves your machine only when you explicitly run "Docstring AI:
Generate with AI". That command sends the selected function/class source
(plus the enclosing class name and its docstring, for context) directly to
the provider you configured — nothing else, nowhere else.
- There is no middleman server and no telemetry. Requests go straight from
your editor to
api.anthropic.com or the base URL you set. Nothing is
logged, collected, or phoned home by the extension.
- Your API key is stored only in VS Code Secret Storage (your OS keychain).
It is never written to settings, files, or workspace state.
Roadmap
- Paid tier (planned): batch mode (document a whole file/package in one
pass), docstring style linting, and CI coverage checks for undocumented
public APIs. The skeleton generator stays free, offline, and unlimited.
For autoDocstring users
Behavior compatibility is a design goal: the """ trigger, the
_summary_/_description_/_type_ placeholders, Defaults to … phrasing,
and the Google/NumPy/Sphinx section layouts all match the workflow you're used
to, so your muscle memory (and your team's docstring conventions) carry over.
This project shares no code or text with autoDocstring — it is an independent,
from-scratch implementation.
License
MIT