Generate API documentation
✓Works with OpenClaudeYou are a documentation engineer specializing in automated API documentation generation. The user wants to generate comprehensive API documentation from code annotations, comments, and type definitions.
What to check first
- Run
npm listto verify you have a documentation generator installed (jsdoc, typedoc, swagger-jsdoc, or similar) - Check if your project has TypeScript definitions or JSDoc comments already in place with
grep -r "@param\|@returns\|interface\|type " src/
Steps
- Install a documentation generator like
npm install --save-dev typedocfor TypeScript ornpm install --save-dev jsdocfor JavaScript - Create a config file:
typedoc.jsonfor TypeScript or.jsdocrc.jsonfor JSDoc with output directory and entry points - Add JSDoc comments to all function signatures using
/** @param {type} name - description */and/** @returns {type} description */ - For TypeScript, ensure type annotations are explicit:
function getName(id: string): Promise<User> - Run the generator with
npx typedoc --out ./docs src/ornpx jsdoc -c .jsdocrc.json - Configure output template in config file using
"theme": "default"or install a custom theme liketypedoc-material-theme - Add API endpoint documentation by creating OpenAPI/Swagger specs in JSON or YAML format
- Generate static HTML and optionally publish to GitHub Pages by adding
"deploy": "typedoc && git add docs && git commit -m 'docs' && git push"to package.json
Code
/**
* User API documentation generator
* Generates markdown and HTML docs from JSDoc comments
*/
const path = require('path');
const fs = require('fs');
/**
* Generate API documentation from source files
* @param {string} sourceDir - Directory containing source files
* @param {string} outputDir - Output directory for generated docs
* @param {Object} options - Configuration options
* @returns {Promise<void>}
*/
async function generateAPIDocs(sourceDir, outputDir, options = {}) {
const { format = 'html', theme = 'default', includePrivate = false } = options;
// Create output directory
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
// Generate documentation config
const docConfig = {
out: outputDir,
name: options.projectName || 'API Documentation',
readme: 'README.md',
theme,
includeDeclarations: true,
excludePrivate: !includePrivate,
excludeProtected: false,
stripInternal: true,
categorizeByGroup: true,
defaultCategory: 'Other',
};
// Write config file
fs.writeFile
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Documentation Skills
Other Claude Code skills in the same category — free to download.
README Generator
Generate comprehensive README.md
JSDoc Generator
Add JSDoc comments to functions and classes
Architecture Doc
Generate architecture documentation with diagrams
Contributing Guide
Create CONTRIBUTING.md with guidelines
Code of Conduct
Generate CODE_OF_CONDUCT.md
License Picker
Choose and add appropriate LICENSE file
Env Example
Generate .env.example from existing .env files
Migration Guide
Create migration/upgrade guide for breaking changes
Want a Documentation skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.