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

@light-cat/ai-commit-msg

v1.1.4

Published

AI-powered commit message generator for git

Downloads

430

Readme

@light-cat/ai-commit-msg

AI-powered commit message generator for git. Automatically generates conventional commit messages based on your staged changes.

Features

  • 🤖 AI-powered: Uses AI to analyze your code changes and generate meaningful commit messages
  • 📝 Conventional Commits: Follows the Conventional Commits format
  • 🔧 Easy Configuration: Simple .env setup with environment variable support
  • 🛡️ Safe: Doesn't block commit on errors - falls back gracefully
  • 🔌 OpenAI Compatible: Works with OpenAI, Azure OpenAI, and any OpenAI-compatible API
  • CLI Ready: Can be used directly with pnpm exec or installed globally

Installation

Local Installation (Recommended)

# With npm
npm install --save-dev @light-cat/ai-commit-msg

# With pnpm
pnpm add --save-dev @light-cat/ai-commit-msg

# Set up git hooks (installs simple-git-hooks if needed)
pnpm exec ai-commit setup

Global Installation

# With npm
npm install -g @light-cat/ai-commit-msg

# With pnpm
pnpm add -g @light-cat/ai-commit-msg

# Then set up git hooks in your project
cd /path/to/your/project
pnpm exec ai-commit setup

Configuration

Create a .env file in your project root or set environment variables:

# Required
AI_API_KEY=your-api-key-here

# Optional (defaults shown)
AI_API_BASE_URL=https://api.openai.com/v1
AI_MODEL=gpt-4

Supported AI Providers

| Provider | AI_API_BASE_URL | AI_MODEL | |----------|-------------------|------------| | OpenAI | https://api.openai.com/v1 | gpt-4, gpt-3.5-turbo | | Azure OpenAI | Your Azure endpoint | Your deployment name | | Local/Other | Your custom endpoint | Any OpenAI-compatible model |

Getting API Keys

Usage

Basic Usage

After setting up the git hook, simply commit your changes without providing a message:

# Stage your changes
git add .

# Commit - AI will automatically generate a commit message
git commit

The tool will:

  1. Fetch staged changes
  2. Send them to the AI service
  3. Generate a conventional commit message
  4. Write it to the commit message file

Automatic Setup

# Install hooks and configure simple-git-hooks automatically
pnpm exec ai-commit setup

Manual Setup (if you already have simple-git-hooks)

Add to your package.json:

{
  "simple-git-hooks": {
    "prepare-commit-msg": "pnpm exec ai-commit"
  }
}

Or if using lefthook:

# lefthook.yml
pre-commit:
  commands:
    generate-commit-msg:
      run: pnpm exec ai-commit

Standalone Usage

# Dry run (show message without writing)
pnpm exec ai-commit --dry-run

# Verbose mode (show debug info)
pnpm exec ai-commit --verbose

# Help
pnpm exec ai-commit --help

How It Works

  1. When you run git commit, the prepare-commit-msg hook is triggered
  2. The tool fetches:
    • Staged changes (git diff --cached)
    • Current branch name
    • Last commit message (if available)
  3. Sends this information to the AI service
  4. Generates a conventional commit message
  5. Writes it to the commit message file

Example

Given this staged change:

diff --git a/src/auth.ts b/src/auth.ts
+export function validateEmail(email: string): boolean {
+  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
+}

The tool might generate:

feat(auth): add email validation function

Troubleshooting

"AI_API_KEY is not set"

Make sure your .env file exists and contains AI_API_KEY, or set the environment variable before committing.

Commit message not being generated

  1. Check if changes are staged (git add first)
  2. Run with --verbose to see debug information
  3. Ensure your API key has sufficient credits/permissions
  4. Verify git hooks are installed: cat .git/hooks/prepare-commit-msg

Want to use a custom message?

Simply provide a commit message when running git commit -m "your message" - the tool will detect an existing message and skip generation.

Contributing

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

Local Development

Debugging

1. Direct Source Execution

Run the source code directly with tsx (recommended for ESM projects):

cd /path/to/node-ai-commit
pnpm tsx bin/ai-commit.js --help

Or using the dev script:

pnpm dev -- --help

Note: ts-node has limited ESM support. Use tsx instead for better compatibility.

2. Using npm link

Link the local package globally and test in other projects:

cd /path/to/node-ai-commit
pnpm link

# In another project
cd /path/to/your-project
pnpm link @light-cat/ai-commit-msg
pnpm exec ai-commit setup

3. Local Path Installation

In another project's package.json:

{
  "devDependencies": {
    "@light-cat/ai-commit-msg": "link:/path/to/node-ai-commit"
  }
}

Then run pnpm install or npm install in that project.

4. Build and Test

# Build the TypeScript
pnpm build

# Run locally (requires build first)
node bin/ai-commit.js --help

# Or run directly without building
pnpm tsx bin/ai-commit.js --help

Testing Setup

  1. Create a test repository:
mkdir test-ai-commit && cd test-ai-commit
git init
  1. Link the local package:
cd /path/to/node-ai-commit
pnpm link --global

cd /path/to/test-ai-commit
pnpm link --global @light-cat/ai-commit-msg
  1. Set up and test:
# Create .env with your API key
pnpm exec ai-commit setup

# Make some changes and commit (don't provide message, let AI generate it)
git add .
git commit