git-msg

A command that reads the changes already placed in Git’s staging area—the files selected with git add—and suggests a commit message. It can follow common message formats, choose English or Japanese, and flag breaking changes.

In plain words
What is it for?
Use it before committing staged work to generate a conventional, Gitmoji, or Angular-style message, select a language, or record a breaking change.
Why use it?
It removes the need to write a commit message from memory and keeps the message based on the exact changes about to be committed. It only prepares and copies the message; it does not run Git commands.

Command

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 commands/ysicing/code-pilot/git-msg
Clone the repo
git clone --depth 1 https://github.com/ysicing/code-pilot
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,220 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.00000 $0.02220
Opus 5 $0.00000 $0.01110
Sonnet 5 $0.00000 $0.00444
Haiku 4.5 $0.00000 $0.00222

Measured yesterday against content hash 1f1977b1e76c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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

commands/git-msg.md · 349 lines

How it starts

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

提交消息

从暂存的更改(git diff --staged)生成合适的提交消息。仅生成消息并复制到剪贴板,不执行 git 命令。

使用方法

/git-msg [选项]

选项

  • --format <格式> : 指定消息格式(conventional, gitmoji, angular)
  • --lang <语言> : 强制指定消息语言(en, ja)
  • --breaking : 检测并记录 Breaking Change

基本示例

# 从暂存的更改生成消息(自动判定语言)
# 主要候选会自动复制到剪贴板
/git-msg

# 强制指定语言
/git-msg --lang ja
/git-msg --lang en

# 检测 Breaking Change
/git-msg --breaking

前提条件

重要: 此命令仅分析暂存的更改。需要先使用 git add 暂存更改。

# 如果没有暂存更改,会显示警告
$ /git-msg
没有暂存的更改。请先执行 git add。

自动剪贴板功能

生成的主要候选会以 git commit -m "消息" 的完整格式自动复制到剪贴板。可以直接在终端粘贴执行。

实现注意事项:

  • 将提交命令传递给 pbcopy 时,应与消息输出分开执行
  • 使用 printf 而不是 echo 以避免末尾换行

项目规范自动检测

重要: 如果存在项目特有的规范,将优先使用。

1. CommitLint 配置检查

从以下文件自动检测配置:

  • commitlint.config.js
  • commitlint.config.mjs
  • commitlint.config.cjs
  • commitlint.config.ts
  • .commitlintrc.js
  • .commitlintrc.json
  • .commitlintrc.yml
  • .commitlintrc.yaml
  • package.jsoncommitlint 部分
# 搜索配置文件
find . -name "commitlint.config.*" -o -name ".commitlintrc.*" | head -1
2. 自定义类型检测

项目特有类型示例:

// commitlint.config.mjs
export default {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'type-enum': [
      2,
      'always',
      [
        'feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore',
        'wip',      // 进行中
        'hotfix',   // 紧急修复
        'release',  // 发布
        'deps',     // 依赖更新
        'config'    // 配置更改
      ]
    ]
  }
}
3. 语言设置检测
// 项目使用中文消息时
export default {
  rules: {
    'subject-case': [0],  // 为支持中文而禁用
    'subject-max-length': [2, 'always', 72]  // 为中文调整字符数限制
  }
}
4. 现有提交历史分析
# 从最近的提交学习使用模式
git log --oneline -50 --pretty=format:"%s"

# 使用类型统计
git log --oneline -100 --pretty=format:"%s" | \
grep -oE '^[a-z]+(\([^)]+\))?' | \
sort | uniq -c | sort -nr

语言自动判定

根据以下条件自动切换中文/英文:

  1. CommitLint 配置中的语言设置
  2. git log 分析的自动判定
  3. 项目文件的语言设置
  4. 更改文件中的注释和字符串分析

Read the full file on GitHub · 349 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 · 349 lines · 0 tokens per session scan A 1f1977b1e76c

Subscribe to this mod's changes

git-msg is a command published in the GitHub repository ysicing/code-pilot (38 stars, last pushed 5mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 2,220 tokens. 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-30.