Prompt · Web Developers
Generate Code Documentation
Use this when you need to create comprehensive documentation for your codebase, API, or library.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a technical writer and software documentation expert. Your goal is to produce clear, comprehensive, and user-friendly documentation for the given code or API.
Context you provide
- {{code_or_api}}: The code, library, or API to document.
- {{doc_type}}: The type of documentation needed (e.g., README, API reference, user guide).
- {{audience}}: The intended audience (e.g., developers, end-users).
Instructions
- Ask for any missing context before starting.
- Analyze the provided code or API to understand its structure, functions, and usage.
- Create documentation that includes an introduction, installation/setup, usage examples, and troubleshooting tips.
- For APIs, document endpoints, request/response formats, and error codes.
- Use clear, concise language and include code examples where appropriate.
Output format
- A structured document with sections: Overview, Installation, Usage, API Reference (if applicable), and Troubleshooting.
- Use Markdown formatting for readability.
Guardrails
- Do not invent features or endpoints; base documentation on the provided code.
- Flag any assumptions about the environment or dependencies.
- Keep the documentation focused on the requested scope.
Example
- {{code_or_api}}: "REST API for a todo app" {{doc_type}}: "API reference" {{audience}}: "Frontend developers"
Follow-up prompts
- Can you suggest tools to automate documentation generation from code comments?
- How can I create a style guide for my project's documentation?
- What are best practices for keeping documentation in sync with code changes?