$ recombobulate _
home / tips / use-claude-to-document-a-function-as-you-write-it
0

Use Claude to Document a Function as You Write It

bagwaa @bagwaa · Mar 25, 2026 · Workflows
use-claude-to-document-a-function-as-you-write-it

Documentation is one of those things everyone knows matters but always defers until later. Claude makes it easy to do it right now, in the same breath as writing the code.

After writing a function, ask Claude to document it:

Add PHPDoc to this method. Include @param and @return types,
a one-line summary, and a @throws annotation if applicable.

public function processRefund(Order $order, float $amount): RefundResult
{
    // ...
}

Claude will produce a complete block that matches the conventions of your language and framework — including edge cases in the description that it infers from reading the implementation.

You can document a whole file at once:

Add docstrings to every public function in this file.
Use Google-style Python docstrings with Args, Returns, and Raises sections.
Don't change any of the implementation code.

This constraint — "don't change the implementation" — is important to include so Claude stays focused on documentation only.

For TypeScript, you can ask Claude to infer @example blocks based on how the function is called elsewhere in the file, or to flag functions whose signatures are ambiguous enough that the docs need a usage note.

Writing the code and the docs together is always faster than going back later — and Claude makes it nearly effortless.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 1 hour ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 1 hour ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago