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

aicontext-commit

v0.3.0

Published

AI commit messages that match your team's style — learns from your git history. Works with Claude, OpenAI, or free local models via Ollama

Readme

aicontext-commit

npm CI license

Commit messages that sound like your team wrote them, not a generic LLM. acc reads your last 30 commits before writing a single word — matching your style, language, and conventions automatically.

acc looks at what you have staged with git add, scans your recent commits to learn how this project writes commits, and asks an LLM (Anthropic or OpenAI) for 3 ready-to-use suggestions. Pick one, tweak it, or regenerate.

demo

Features

  • 🧠 Context-aware — uses your last 30 commits as a style reference (language, casing, format, level of detail)
  • ✍️ 3 suggestions per run — alternative phrasings for the same change, ordered most-specific first
  • 🌍 Choose the language — select a language or automatically follow your history, falling back to English
  • 📐 Conventional Commits — picks the right type from the diff (feat, fix, docs, build, ci, refactor…)
  • 🔁 Regenerate / edit / manual — you stay in control of the final message
  • 🤝 Three providers — Anthropic (Claude), OpenAI, or a free local model through Ollama
  • 💸 Token-frugal — compact diffs, a fixed budget for large commits, a locally computed style summary, and cached regenerations
  • 🛡️ Safe by design — won't run without staged changes, refuses oversized diffs, redacts common secrets, and treats history and diff as data

Installation

npm install -g aicontext-commit

Or run on demand without installing:

npx aicontext-commit

The package exposes two binaries — aicontext-commit and the shorter alias acc.

Setup

Set one of the following API keys as an environment variable:

export ANTHROPIC_API_KEY=sk-ant-...
# or
export OPENAI_API_KEY=sk-...

If both are set, Anthropic is used.

Free local mode (Ollama)

No API key? Run a local model with Ollama — free, and your code never leaves your machine:

ollama pull qwen2.5-coder:7b
export ACC_PROVIDER=ollama

ACC_PROVIDER=ollama takes precedence over any API key. Without it, Ollama is used only when no API key is set and OLLAMA_HOST is (default host: http://localhost:11434). You can also drop them into a .env file in your project root. acc reads supported configuration values from that file and does not inject the whole file into the process environment. See .env.example for the format.

Model

By default acc uses small, fast, cheap models — a commit message doesn't need more:

| Provider | Default model | Notes | |---|---|---| | Anthropic | claude-haiku-5-5 | | | OpenAI | gpt-6-luna | reasoning disabled (reasoning_effort: none) for speed | | Ollama | qwen2.5-coder:7b | runs locally, no cost |

To use a different model, set ACC_MODEL (env var or .env):

export ACC_MODEL=claude-sonnet-5-5

Usage

# stage your changes as usual
git add .

# launch the picker
acc

You'll see something like:

Reading staged changes...
? Choose the commit language: Automatic (from commit history)
Generating suggestions...
? Choose a commit message: (Use arrow keys)
❯ feat(cli): add commit picker with 3 AI suggestions
  feat: generate commit messages from staged diff using LLM
  feat(acc): scaffold CLI to draft conventional commits
  ↺ Regenerate suggestions
  ✎ Write manually

Pick a suggestion → edit it inline if you want → press Enter → commit is created. Done.

Commit language

By default, acc asks you to select a language before generating suggestions. Choose Automatic to follow the dominant language in your commit history (English if there is no history or the language is unclear).

To skip the language picker for a run:

acc --language es   # Spanish descriptions
acc -l en          # English descriptions
acc --language auto # Detect from history

Set a default in your environment or the project's .env file:

ACC_LANGUAGE=es

Supported codes: auto, en (English), es (Spanish), fr (French), de (German), it (Italian), pt (Portuguese), ca (Catalan), ja (Japanese), zh (Chinese), and ko (Korean).

Precedence: CLI option → environment variable → .env → interactive picker. An explicit language overrides the language of previous commits while preserving their style. Conventional Commit types (feat, fix, etc.) stay in English. Regenerations keep the chosen language.

Options on the picker

| Option | What it does | |---|---| | Any suggestion | Opens an editable prompt pre-filled with the message, then commits | | ↺ Regenerate suggestions | Asks the model again with the same prompt (useful if none fit) | | ✎ Write manually | Type your own message from scratch |

Press Ctrl+C at any time to abort cleanly — no commit is created.

How it works

  1. Read git — runs git diff --cached --unified=1 for the staged changes (lockfiles and generated files are summarized with --stat instead of sent in full) and the subjects of the last 30 non-merge commits.
  2. Analyze style locally — computes Conventional Commits usage, common scopes, and subject length from those 30 commits without any API call, and keeps only the 10 latest as examples.
  3. Build prompt — wraps both into a structured prompt that asks the model to summarize the entire staged diff as one commit (not one suggestion per file) and to match the repo's existing style.
  4. Call the model — Ollama if ACC_PROVIDER=ollama, otherwise claude-haiku-5-5 if ANTHROPIC_API_KEY is set, otherwise gpt-6-luna if OPENAI_API_KEY is set (override with ACC_MODEL).
  5. Parse 3 suggestions — strict format 1. … / 2. … / 3. …; if parsing fails you get a clear error, not a bad commit.
  6. Commit — runs git commit -m "<your choice>" with the message you confirmed.

Limits & safeguards

  • No staged changes → exits with a clear message before calling any API.
  • Not a git repo → exits with a clear message.
  • Lockfiles and generated files (package-lock.json, yarn.lock, Cargo.lock, go.sum, *.min.js, *.map, *.snap, …) → only a --stat summary is sent, saving tokens.
  • Large diffs → capped at ~16k characters (~4k tokens). Every file keeps its header, small files stay whole, and large files are trimmed evenly, so big commits cost the same as medium ones.
  • Regenerate → the identical prompt is cached on Anthropic, so further regenerations bill the input at ~10%.
  • Thinking off → thinking is disabled on Claude Haiku, and models where it can't be disabled run at the lowest effort.
  • Secret redaction → common API keys, bearer tokens, private keys, and credential assignments are redacted before the diff/history is sent to the model.
  • Prompt injection → instructions are placed before untrusted repo data, code fences are escaped, and the prompt tells the model to treat the diff and history as data.
  • Git hooks → git commit runs with a sanitized environment so API keys and secret-looking variables are not passed to hooks.

Development

git clone https://github.com/samuelurones28/aicontext-commit.git
cd aicontext-commit
npm install

# run from source
npm run dev

# build to dist/
npm run build

# run the test suite (builds first)
npm test

# preview what would be published
npm run smoke

The project is plain TypeScript compiled to CommonJS — no bundler. Tests use Node's built-in node:test runner against the compiled dist/ output.

Project layout

src/
  index.ts    # CLI entrypoint, picker flow, commit execution
  git.ts      # staged diff + recent commits, with safety checks
  prompt.ts   # prompt template
  ai.ts       # provider detection (Anthropic/OpenAI) + parser
  errors.ts   # CliError class + typed error codes + formatter
bin/
  index.js    # thin wrapper that requires dist/index.js
tests/
  *.test.js   # node:test suites for each module

Debugging

Set DEBUG=1 to print full stack traces for unexpected errors:

DEBUG=1 acc

Known errors come back with a code (NO_STAGED_CHANGES, MISSING_API_KEY, STAGED_DIFF_TOO_LARGE, AI_PARSE_ERROR, …) so you can grep them or wrap them in scripts.

License

MIT © Samuel Fernandez — see LICENSE.