ai-commit-msg

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

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.

agentmods
npx agentmods add skills/stephansama/packages/ai-commit-msg
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.

Per session 100 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,390 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00100 $0.01390
Opus 5 $0.00050 $0.00695
Sonnet 5 $0.00020 $0.00278
Haiku 4.5 $0.00010 $0.00139

Measured yesterday against content hash 5698e8132a75, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

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 · 209 lines

How it starts

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

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 in the environment.

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).

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.

Skip the hook for one commit

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

When skipNextRun is true, the hook logs a warning and exits immediately. Remove it from the config after the manual commit.

Common Mistakes

CRITICAL Default config uses ollama/llama2 — fails if Ollama not running

Wrong:

# No config file — hooks use default: provider: 'ollama', model: 'llama2'
# Works locally if ollama is running, fails in CI

Read the full file on GitHub · 209 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. yesterday 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 1mo ago), licensed MIT. It adds 100 tokens to every session and 1,390 once invoked, about $0.0005 per session on Opus 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

Other skills, from other repositories

opendia-harness

Install, configure, and troubleshoot OpenDia for Grok Build (and other MCP harnesses). Use when setting up the plugin, config.toml MCP entry, ports, extension disconnects, tool timeouts, or tunnel mode.

aeonfun/opendia · 52 tokens

opendia

Drive the user's real browser through OpenDia MCP (logged-in sessions, cookies, wallets, bookmarks, history). Use when automating Chrome/Firefox for social posts, form fills, multi-tab research, local webapp testing, or any task that needs the user's existing browser profile — not a disposable cloud browser.

aeonfun/opendia · 66 tokens

npm-security

Prevent JavaScript/TypeScript projects from supply-chain attacks across package managers like npm, pnpm, yarn, bun, and deno. Use whenever planning, installing, updating packages or configuring package managers.

bodadotsh/npm-security-best-practices · 43 tokens

frontmcp-extensibility

Use when extending FrontMCP beyond the core SDK by integrating external npm packages, libraries, or third-party services into providers and tools. Covers VectoriaDB for in-memory semantic and vector search (ML-based embeddings or TF-IDF keyword engines, with persistence) and the tamper-evident, hash-chained skill…

agentfront/frontmcp · 124 tokens

huly-cli

Operate Huly through the @firfi/huly-cli executable. Use when a coding agent needs to authenticate, switch Huly workspaces or projects, discover commands, query structured Huly data, or perform confirmed Huly mutations from a shell or automation workflow.

dearlordylord/huly-mcp · 56 tokens

censor_message

Automatically censor profanity in messages by replacing with asterisks.

glincker/glin-profanity · 16 tokens