ai-commit-msg

ai-commit-msg is a skill for Claude Code, Codex from stephansama/packages. It costs 151 tokens per session (1,725 once invoked), scanned A, original, MIT.

A tool that creates a conventional Git commit message from the changes staged for commit. It runs through a Git hook and can use Google, OpenAI, or a locally running Ollama model.

In plain words
What is it for?
Use it in a Git project to generate commit messages automatically from staged changes, with the provider and model selected in its configuration.
Why use it?
It removes the need to write the first draft of a commit message manually while keeping messages in a consistent format. The staged diff remains the source for the generated message.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it in a Git project to generate commit messages automatically from staged changes, with the provider and model selected in its configuration.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/stephansama/packages/ai-commit-msg
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add stephansama/packages --skill ai-commit-msg
Clone the repo
git clone --depth 1 https://github.com/stephansama/packages

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ai-commit-msg

README.md
[![agentmods](https://agentmods.dev/badge/skills/stephansama/packages/ai-commit-msg/github.svg)](https://agentmods.dev/skills/stephansama/packages/ai-commit-msg)
Your own site
<a href="https://agentmods.dev/skills/stephansama/packages/ai-commit-msg"><img src="https://agentmods.dev/badge/skills/stephansama/packages/ai-commit-msg/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ai-commit-msg

Your own site · 80×15
<a href="https://agentmods.dev/skills/stephansama/packages/ai-commit-msg"><img src="https://agentmods.dev/badge/skills/stephansama/packages/ai-commit-msg.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 151 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,725 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00151 $0.01725
Opus 5.5 $0.00060 $0.00690
Sonnet 5.5 $0.00030 $0.00345
Haiku 4.5 $0.00015 $0.00172

Measured 8d ago against content hash ae4655bf367f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ai-commit-msg scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

core/ai-commit-msg/skills/ai-commit-msg/SKILL.md · 235 lines

How it starts

The opening of the file, as written. The whole thing — 235 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ai-commit-msg

Writes an AI-generated conventional commit message to the COMMIT_EDITMSG file via the prepare-commit-msg Git hook. Reads the staged diff and passes it to your configured AI provider through TanStack AI adapters.

Setup

  1. Install and initialise husky:
npm install --save-dev husky && npx husky init
  1. Create .husky/prepare-commit-msg:
#!/bin/sh
ai-commit-msg -o "$1"
  1. Create a config file at ai-commit-msg.config.ts (or package.json key ai-commit-msg):
// ai-commit-msg.config.ts
export default {
  provider: "google",
  model: "gemini-2.5-flash",
};
  1. Set the required environment variable:
export GOOGLE_GENERATIVE_AI_API_KEY=your-key

Core Patterns

Google provider

export default {
  provider: "google",
  model: "gemini-2.5-flash",
};

Requires GOOGLE_GENERATIVE_AI_API_KEY, GOOGLE_API_KEY, or GEMINI_API_KEY in the environment (checked in that order).

OpenAI provider

export default {
  provider: "openai",
  model: "gpt-4o-mini",
};

Requires OPENAI_API_KEY in the environment.

Ollama provider (local, no API key)

export default {
  provider: "ollama",
  model: "llama3.2",
};

Requires the Ollama server running locally (ollama serve). Set OLLAMA_HOST to use a server other than http://localhost:11434.

Custom prompt

export default {
  provider: "google",
  model: "gemini-2.5-flash",
  prompt:
    "Write a short conventional commit message in lowercase for this diff:\n\n{{diff}}",
};

The {{diff}} placeholder is replaced with the staged diff (truncated at 8000 characters). The prompt must include {{diff}} or the model receives no diff context.

Preserve an existing commit message

git commit -m "fix login redirect"
# -> fix(auth): fix login redirect after session refresh

When the output file already holds a message, it is passed to the model as the original intent and only reformatted to match the prompt and diff. Git comment lines and the verbose-diff scissors section are stripped first. Empty, punctuation-only, or n/a-style messages (N/A, na, n.a., none) are ignored and a fresh message is generated.

Read the full file on GitHub · 235 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago Changed · +26 lines · +51 tokens per session ae4655bf367f
  2. 1mo ago First seen · 209 lines · 100 tokens per session scan A 5698e8132a75

Subscribe to this mod's changes

ai-commit-msg is a skill published in the GitHub repository stephansama/packages (5 stars, last pushed 8d ago), licensed MIT. It adds 151 tokens to every session and 1,725 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.