Document Code with JSDoc/TSDoc
Generate professional and complete JSDoc/TSDoc documentation for your functions and classes with concrete examples.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
You are an expert in software technical documentation. I need to document my [JavaScript/TypeScript] code in a professional and complete way so that my colleagues can use it easily.
Code to document:
[paste the code]
Context:
- Audience: [e.g. internal developers, open-source contributors, library users]
- Documentation style: [e.g. standard JSDoc, TSDoc for TypeScript, specific format]
- Generation tool: [e.g. TypeDoc, JSDoc, Storybook]
- Level of detail required: [e.g. minimal for internal use, complete for public API]
Generate the complete documentation with:
- General description: a one-sentence summary followed by a detailed paragraph explaining the role, the context of use, and important limitations.
- Parameters: document each parameter with its type, whether it is required/optional, its default value, and a clear description.
- Return value: exact type and description of what is returned, including special cases (null, undefined, rejected Promise).
- Exceptions: list the errors that can be thrown along with the conditions that trigger them.
- Code examples: provide 2-3 concrete examples covering basic usage and more complex cases.
- Special annotations: @deprecated, @since, @see, @internal as needed.
Make sure the documentation is precise enough that a developer can use the function without reading its implementation.
Personalize this prompt with Léa · AI assistant
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why this prompt works
This prompt is centered on the final goal of documentation: enabling a developer to use a function without reading its implementation. This constraint forces the AI to produce exhaustive documentation rather than a simple code paraphrase. Requesting 2-3 concrete examples is the most valuable element of this prompt: documentation with examples has a much higher adoption rate than textual documentation alone. Examples drastically reduce the learning curve for new API users. Adapting to context (internal use vs public API) is important as it calibrates the appropriate level of detail: over-documenting simple internal code is a waste of time, while under-documenting a public API creates support debt.
Use Cases
Expected Output
Complete JSDoc/TSDoc comments with descriptions, types, documented parameters, return values, and code examples.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
Be the first to comment on this prompt.
Glossary Terms
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Improve this prompt with the Optimizer
Analyze the prompt, strengthen the context and get a more precise version.
Prompt Engineering
Cross-model principles for writing more reliable prompts.
AI prompts for web developers
Code review and debugging, keeping API keys and secrets out of the prompt.
Security, GDPR & Business Plans
ChatGPT Business, Claude Team, Gemini Workspace and Mistral Vibe compared from vendor sources: training, EU hosting and a GDPR checklist.
Similar Prompts
Task brief for Claude Code: frame a feature end to end
Brief template to delegate a complete feature to Claude Code: goal, starting point, constraints, definition of done, working rules and recap format.
Write a project's CLAUDE.md: the brief Claude Code reads at every session
Turns your project description into a dense CLAUDE.md: commands, structure, conventions, pitfalls, off-limits areas and situations where the agent must ask before acting.
Design a Secure Webhook API
Design a webhook API with event subscriptions, signed deliveries, retry limits, and a delivery log your support team can inspect.
Generate Storybook Stories for UI Components
Generate Storybook stories for a UI component, with visual variants, interactive controls, interaction tests, and MDX documentation.