git-cm

A command that examines Git changes and suggests a commit message, with optional task or bug references and Chinese-language output. Git is a version-control system that records changes to a codebase; the command shows a preview and asks for confirmation before committing and pushing.

In plain words
What is it for?
Preparing commits from staged or working files, following existing commit rules, adding task or bug identifiers, and pushing the result to a remote repository.
Why use it?
It reduces the manual work of checking changed files and writing a project-appropriate commit message. Its checks and confirmation step help prevent committing the wrong files or sending an unintended change.

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-cm
Clone the repo
git clone --depth 1 https://github.com/ysicing/code-pilot
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,393 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.00017 $0.04393
Opus 5 $0.00009 $0.02197
Sonnet 5 $0.00003 $0.00879
Haiku 4.5 $0.00002 $0.00439

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

Security

Grade A, and why

git-cm 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-cm.md · 517 lines

How it starts

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

使用方法

/git-cm [提交信息或附加信息] [--zh]

参数说明

  • --zh: 中文模式,生成中文提交信息

使用模式

默认行为: 分析代码变更,生成提交信息,预览操作并等待用户确认 智能附加: 支持在智能生成的提交信息后附加任务号、Bug号等信息 多语言支持: 默认英文,使用 --zh 参数生成中文

上下文

  • 提交信息:$ARGUMENTS(可以是完整提交信息或附加信息)
  • 智能生成: 分析代码变更,生成符合 Conventional Commit 规范的提交信息
  • 附加信息支持: 支持任务号、Bug号等格式,使用逗号分隔多个信息
  • 语言模式: 默认英文,使用 --zh 参数生成中文提交信息
  • 安全确认: 显示操作预览,等待用户确认后执行

流程

1. 检查和分析阶段

  • 检查工作区状态和变更文件
  • Git状态检测:优先检查已暂存文件,避免重复add操作
  • 项目规范检测:自动检测CommitLint配置和现有提交历史模式
  • 安全验证:文件数量检查、目录过滤、敏感文件检测
  • 智能选择:优先使用已暂存文件,仅在需要时暂存工作区文件

2. 智能生成阶段

  • 输入分析:判断完整提交信息 vs 附加信息
  • 项目规范适配:检测并遵循现有CommitLint配置和提交历史模式
  • 智能生成:基于文件变更生成具体的 Conventional Commit 信息
  • 语言智能判定:基于代码内容、注释、历史提交自动选择中英文
  • 信息组合:将附加信息(如 task#123,bug#456)组合到生成的提交信息中
  • 语言处理:根据 --zh 参数或自动判定选择中文模式

3. 预览和执行阶段

  • 显示变更文件列表和最终提交信息
  • 展示将要执行的 git 命令
  • 等待用户确认后执行 commit + push

您的角色

您是 Git 操作执行助手,负责分析代码变更、生成提交信息并执行 git commit + push 操作。您的主要职责是简化用户的版本控制流程。

核心能力

  • 智能检测工作区状态和分支信息
  • Git状态感知:优先使用已暂存文件,智能决定是否执行add操作
  • 生成具体的 Conventional Commit 格式提交信息
  • 智能附加信息处理(任务号、Bug号等)
  • 多语言支持(英文/中文)
  • 安全检查和用户确认机制

核心特性

项目规范自动检测

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

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. 现有提交历史分析
# 从最近的提交学习使用模式
git log --oneline -50 --pretty=format:"%s"

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

Read the full file on GitHub · 517 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 · 517 lines · 17 tokens per session scan A ba9d80d69457

Subscribe to this mod's changes

git-cm is a command published in the GitHub repository ysicing/code-pilot (38 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 17 tokens to every session and 4,393 once invoked, about $0.0001 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-30.