Create clear, comprehensive code documentation using language-specific standards like JSDoc, Python docstrings, JavaDoc, and inline comments.
When to Use
Function and class documentation
JSDoc for JavaScript/TypeScript
Python docstrings
JavaDoc for Java
Inline code comments
API documentation from code
Type definitions
Usage examples in code
Quick Start
Minimal working example:
/**
* Calculates the total price including tax and discount.
*
* @param {number} basePrice - The base price before tax and discount
* @param {number} taxRate - Tax rate as a decimal (e.g., 0.08 for 8%)
* @param {number} [discount=0] - Optional discount amount
* @returns {number} The final price after tax and discount
* @throws {Error} If basePrice or taxRate is negative
*
* @example
* const price = calculateTotalPrice(100, 0.08, 10);
* console.log(price); // 98
*
* @example
* // Without discount
* const price = calculateTotalPrice(100, 0.08);
* console.log(price); // 108
*/
function calculateTotalPrice(basePrice, taxRate, discount = 0) {
if (basePrice < 0 || taxRate < 0) {
throw new Error("Price and tax rate must be non-negative");
}
return basePrice * (1 + taxRate) - discount;
}
// ... (see reference guides for full implementation)
Reference Guides
Detailed implementations in the references/ directory:
Guide
Contents
Function Documentation
Function Documentation
Class Documentation
Class Documentation
Type Definitions
Type Definitions
Function Documentation
Function Documentation
Class Documentation
Class Documentation
Module Documentation
Module Documentation
Best Practices
✅ DO
Document public APIs thoroughly
Include usage examples
Document parameters and return values
Specify thrown exceptions/errors
Use language-specific standards (JSDoc, docstrings, etc.)
Keep comments up-to-date
Document "why" not "what"
Include edge cases and gotchas
Add links to related functions
Document type definitions
Use consistent formatting
❌ DON'T
State the obvious in comments
Leave commented-out code
Write misleading comments
Skip examples for complex functions
Use vague parameter descriptions
Forget to update docs when code changes
Over-comment simple code
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: aj-geddes-useful-ai-prompts-code-documentation3description: Code Documentation4---56# Code Documentation78## Table of Contents910- [Overview](#overview)11- [When to Use](#when-to-use)12- [Quick Start](#quick-start)13- [Reference Guides](#reference-guides)14- [Best Practices](#best-practices)1516## Overview1718Create clear, comprehensive code documentation using language-specific standards like JSDoc, Python docstrings, JavaDoc, and inline comments.1920## When to Use2122- Function and class documentation23- JSDoc for JavaScript/TypeScript24- Python docstrings25- JavaDoc for Java26- Inline code comments27- API documentation from code28- Type definitions29- Usage examples in code3031## Quick Start3233Minimal working example:3435```javascript36/**37 * Calculates the total price including tax and discount.38 *39 * @param {number} basePrice - The base price before tax and discount40 * @param {number} taxRate - Tax rate as a decimal (e.g., 0.08 for 8%)41 * @param {number} [discount=0] - Optional discount amount42 * @returns {number} The final price after tax and discount43 * @throws {Error} If basePrice or taxRate is negative44 *45 * @example46 * const price = calculateTotalPrice(100, 0.08, 10);47 * console.log(price); // 9848 *49 * @example50 * // Without discount51 * const price = calculateTotalPrice(100, 0.08);52 * console.log(price); // 10853 */54function calculateTotalPrice(basePrice, taxRate, discount = 0) {55 if (basePrice < 0 || taxRate < 0) {56 throw new Error("Price and tax rate must be non-negative");57 }58 return basePrice * (1 + taxRate) - discount;59}6061// ... (see reference guides for full implementation)62```6364## Reference Guides6566Detailed implementations in the `references/` directory:6768| Guide | Contents |69|---|---|70| [Function Documentation](references/function-documentation.md) | Function Documentation |71| [Class Documentation](references/class-documentation.md) | Class Documentation |72| [Type Definitions](references/type-definitions.md) | Type Definitions |73| [Function Documentation](references/function-documentation-2.md) | Function Documentation |74| [Class Documentation](references/class-documentation-2.md) | Class Documentation |75| [Module Documentation](references/module-documentation.md) | Module Documentation |7677## Best Practices7879### ✅ DO8081- Document public APIs thoroughly82- Include usage examples83- Document parameters and return values84- Specify thrown exceptions/errors85- Use language-specific standards (JSDoc, docstrings, etc.)86- Keep comments up-to-date87- Document "why" not "what"88- Include edge cases and gotchas89- Add links to related functions90- Document type definitions91- Use consistent formatting9293### ❌ DON'T9495- State the obvious in comments96- Leave commented-out code97- Write misleading comments98- Skip examples for complex functions99- Use vague parameter descriptions100- Forget to update docs when code changes101- Over-comment simple code102103---104> Converted and distributed by [TomeVault](https://tomevault.io/claim/aj-geddes) — claim your Tome and manage your conversions.105<!-- tomevault:4.0:skill_md:2026-04-11 -->
Run npx skillmds@latest add tomevault-io/aj-geddes-useful-ai-prompts-code-documentation in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Code Documentation It is listed under Docs & Writing on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.