ai-commit-msg

ai-commit-msg is a skill for Claude Code, Codex from stephansama/packages. It costs 182 tokens per session (1,954 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 182 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,954 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.00182 $0.01954
Opus 5.5 $0.00073 $0.00782
Sonnet 5.5 $0.00036 $0.00391
Haiku 4.5 $0.00018 $0.00195

Measured 22d ago against content hash dc6e03c9eb88, 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 22d 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 · 248 lines

How it starts

The opening of the file, as written. The whole thing — 248 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

Anthropic provider

export default {
  provider: "anthropic",
  model: "claude-opus-5-5",
};

Requires ANTHROPIC_AUTH_TOKEN, ANTHROPIC_OAUTH_TOKEN, or ANTHROPIC_API_KEY in the environment (checked in that order). ANTHROPIC_AUTH_TOKEN is sent as a bearer token (or as a Claude OAuth token when it starts with sk-ant-oat), ANTHROPIC_OAUTH_TOKEN as a Claude OAuth token, and ANTHROPIC_API_KEY as an x-api-key header.

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}}",
};

Read the full file on GitHub · 248 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. 22d ago Changed · +13 lines · +31 tokens per session dc6e03c9eb88
  2. 1mo ago Changed · +26 lines · +51 tokens per session ae4655bf367f
  3. 3mo 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 11d ago), licensed MIT. It adds 182 tokens to every session and 1,954 once invoked, about $0.0007 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.

Related

ai-commit-msg compared with skills from other repositories

ai-commit-msg next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
ai-commit-msgstephansama/packagesSkill511d agoMITA182Claude Code, Codex
create-prprisma/ormSkill48ktodayApache-2.0A47Claude Code, Codex
review-implement-phaseprisma/ormSkill48ktodayApache-2.0A38Claude Code
review-triage-phaseprisma/ormSkill48ktodayApache-2.0A36Claude Code
multiline-commit-messagesprisma/ormSkill48ktodayApache-2.0A35Claude Code, Codex
pr-writeroxc-project/oxcSkill24ktodayMITA31Claude Code, Codex
stacking-prsPostHog/posthogSkill41ktodaynoneA136Claude Code, Codex