codecontext docstring

Add AI-generated docstrings to your functions

The docstring command automatically adds comprehensive documentation comments to your functions. It analyzes your code structure and generates JSDoc comments with parameters, returns, examples, and more.

Save 2 min/function

Writing good docstrings takes time. Let AI do it instantly.

Track ROI

See exactly how much time and money you save.

Preserve Style

Maintains your code formatting and conventions.

$ codecontext docstring src/

Interactive Demo

Terminal

Before & After

Before

function processPayment(amount, currency, metadata) {
  const fee = calculateFee(amount, currency);
  return chargeCard(amount + fee, metadata);
}

After

/**
 * Processes a payment transaction with automatic fee calculation
 * @param {number} amount - Payment amount in smallest currency unit (cents/pence)
 * @param {string} currency - ISO 4217 currency code (e.g., 'USD', 'EUR')
 * @param {object} metadata - Additional payment metadata
 * @param {string} metadata.customerId - Customer identifier
 * @param {string} metadata.orderId - Associated order ID
 * @returns {Promise<PaymentResult>} Payment confirmation with transaction ID
 * @throws {PaymentError} If card charge fails or currency unsupported
 * @example
 * await processPayment(2000, 'USD', { customerId: 'cus_123', orderId: 'ord_456' })
 */
function processPayment(amount, currency, metadata) {
  const fee = calculateFee(amount, currency);
  return chargeCard(amount + fee, metadata);
}

Options

--dry, -d

Preview changes without modifying files

$ codecontext docstring src/ --dry

--pattern, -p

File pattern for directories (e.g., "*.js", "*.ts")

$ codecontext docstring src/ --pattern "*.ts"

--limit, -l

Limit number of functions to process

$ codecontext docstring src/ --limit 10

Usage Limits

Monthly Docstring Limits

Free Plan20 docstrings/month
STARTER Plan ($9/mo)200 docstrings/month
PRO Plan ($29/mo)Unlimited docstrings

Check your usage with codecontext status

What It Generates

Comprehensive JSDoc

  • • Function description based on implementation
  • • @param tags with types and descriptions
  • • @returns with type and description
  • • @throws for error conditions
  • • @example with realistic usage

Smart Analysis

  • • Detects parameter types from usage
  • • Infers return types accurately
  • • Identifies error conditions
  • • Preserves existing formatting

Language Support

  • • JavaScript (JSDoc)
  • • TypeScript (TSDoc)
  • • Python (coming soon)
  • • Go (coming soon)

Best Practices

Use --dry first

Always preview changes before applying them to ensure the generated docstrings meet your standards.

Start with critical functions

Use --limit to process your most important functions first, especially on the free plan.

Review and refine

AI-generated docstrings are a great start, but review them for accuracy and add domain-specific details.

See Also

);