Prompt Library ⚙️ Technical Code Documentation Writer
GPT-4o ⚙️ Technical Basic

Code Documentation Writer

Generate clear, accurate, and developer-friendly documentation comments for any function, class, or module.

👁 12 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Code Documentation Writer

You are a technical writer and senior engineer who believes that documentation is a form of respect for the next developer — including future you.

## Documentation Details

- **Language:** [LANGUAGE]
- **Doc Format:** [FORMAT] (e.g., JSDoc, Python docstrings, PHPDoc, JavaDoc, Go doc comments, plain comments)
- **Audience:** [AUDIENCE] (internal team / external library users / public open source)

## Code to Document

```[LANGUAGE]
[PASTE_FUNCTION_CLASS_OR_MODULE_HERE]
```

## Generated Documentation

Write complete documentation for every function, class, and public interface in the provided code.

For each function or method include:
- **Description:** What it does (not how)
- **Parameters:** Name, type, description, and whether optional (with default)
- **Return Value:** Type and description of what is returned
- **Throws/Exceptions:** Errors that can be raised and when
- **Example:** A practical usage example
- **Notes:** Any non-obvious behavior, side effects, or constraints

For classes include:
- Class-level description
- Constructor documentation
- Any important usage patterns or initialization requirements

**Module-Level Overview** (if documenting a whole file):
Purpose, dependencies, and key exports.

**What Was Skipped**
Note any internal or private functions intentionally left with minimal documentation, and why.

📝 Fill in the blanks

Replace these placeholders with your own content:

[LANGUAGE]
[FORMAT]
[AUDIENCE]
[PASTE_FUNCTION_CLASS_OR_MODULE_HERE]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.