npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-code-documenter

v0.2.0

Published

AI-powered code documentation generator for git hooks

Readme

AI Code Documenter

AI-powered documentation generator for your code that integrates with Git hooks and lint-staged.

Version License

Features

  • 🤖 Uses AI to automatically generate and update code documentation
  • 🔄 Seamlessly integrates with Git hooks via lint-staged
  • 🧰 Support for JSDoc, TSDoc, docstrings, and Markdown formats
  • ⚡ Command line interface for individual files or batch processing
  • 🛠️ Programmable API for custom integrations
  • 📝 Preserves your code while enhancing documentation
  • 🚀 Parallel processing with configurable concurrency limits

Installation

npm install --save-dev ai-code-documenter
# or
yarn add --dev ai-code-documenter

Setup with lint-staged

  1. Install the package
  2. Update your lint-staged configuration in package.json:
{
  "lint-staged": {
    "*.{js,jsx,ts,tsx}": [
      "ai-document",
      "prettier --write",
      "eslint --fix"
    ]
  }
}

For improved performance with multiple files, you can set a concurrency limit:

{
  "lint-staged": {
    "*.{js,jsx,ts,tsx}": [
      "ai-document --concurrency 3",
      "prettier --write",
      "eslint --fix"
    ]
  }
}

Command Line Usage

Document individual files:

npx ai-document src/components/Button.tsx

Document multiple files:

npx ai-document src/**/*.ts --verbose

CLI options:

--verbose         Show detailed output
--tsdoc           Use TSDoc style (default is JSDoc)
--docstring       Use docstring style (for Python-like docs)
--markdown        Use Markdown style
--config <path>   Specify config file location
--concurrency <n> Set maximum number of files to process in parallel (default: 5)
--no-colors       Disable colored output

API Usage

import { documentFile, documentFiles } from 'ai-code-documenter';

// Document a single file
const result = await documentFile('src/utils/helper.ts', {
  outputStyle: 'tsdoc',
  verbose: true
});

// Document multiple files with concurrency limit
const results = await documentFiles([
  'src/components/Button.tsx',
  'src/utils/format.ts'
], {
  model: 'gpt-4',
  verbose: true,
  maxConcurrency: 3 // Process up to 3 files at once
});

Configuration

Create a configuration file in one of the following formats:

  • .ai-documenter.json
  • .ai-documenter.js
  • .ai-documenter.ts
  • ai-documenter.config.js
  • ai-documenter.config.ts

Example JSON configuration:

{
  "apiKey": "your-openai-api-key", // Optional: can also use OPENAI_API_KEY env variable
  "model": "gpt-3.5-turbo", // Default model to use
  "outputStyle": "jsdoc", // jsdoc, tsdoc, docstring, or markdown
  "verbose": false, // Whether to show detailed logs
  "maxConcurrency": 5 // Maximum number of files to process concurrently
}

Example JavaScript/TypeScript configuration:

module.exports = {
  apiKey: process.env.MY_OPENAI_KEY,
  model: 'gpt-4',
  maxConcurrency: 3, // Process up to 3 files simultaneously
  // Other options...
};

Environment Variables

The tool supports loading environment variables from various .env files:

  • .env - Default environment variables
  • .env.local - Local overrides (not committed to git)
  • .env.development - Development environment variables
  • .env.development.local - Local overrides for development
  • .env.production - Production environment variables
  • .env.production.local - Local overrides for production
  • .env.test - Test environment variables
  • .env.test.local - Local overrides for test

Variables are loaded with the following precedence (highest to lowest):

  1. .env.[environment].local
  2. .env.local
  3. .env.[environment]
  4. .env

Required environment variables:

  • OPENAI_API_KEY: Your OpenAI API key (unless specified in configuration)

Supported Languages

  • JavaScript (.js)
  • TypeScript (.ts)
  • React (.jsx, .tsx)
  • Support for additional languages coming soon!

How It Works

  1. The tool extracts code from your files
  2. It sends the code to an AI model with specific documentation instructions
  3. The AI analyzes the code and generates appropriate documentation
  4. The tool updates your files with the enhanced documentation
  5. No code logic is changed, only comments are added or improved

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request