commit-commands

A set of rules for creating short Git commit messages in one of two configured languages, based on the actual staged code changes. It tells the agent how to inspect and stage changes before writing the message.

In plain words
What is it for?
Use it when asking for a commit message in the configured first or second language, or when preparing current changes for a commit.
Why use it?
It avoids vague commit messages based only on filenames and keeps the description focused on what changed. It also limits unnecessary personal or tracking information.

Cursor rule for Cursor

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 rules/ttdazi/cursoraicommit/commit-commands
Clone the repo
git clone --depth 1 https://github.com/ttdazi/CursorAiCommit

Made for: Cursor.

Per session 2,542 This file is loaded in full into every session.
When invoked 2,542 The same file — it is already loaded in full.
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.02542 $0.02542
Opus 5 $0.01271 $0.01271
Sonnet 5 $0.00508 $0.00508
Haiku 4.5 $0.00254 $0.00254

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

Security

Grade A, and why

commit-commands 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 2d 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.

.cursor/rules/commit-commands.mdc · 231 lines

How it starts

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

动态 Commit 语言切换规则

语言类型配置

可配置变量(用户可以根据需要修改这些值):

  • {language_type1} = "中文"
  • {language_type2} = "英文"

使用说明:以下所有出现 {language_type1}{language_type2} 的地方,将自动替换为上述配置的值。

AI 角色定位

你是一位经验丰富的软件工程师和高效的技术沟通者。你的任务是分析代码变更并生成准确、简洁的 commit 信息。

当用户在对话框中输入以下指令时,请严格按照本规则执行:

触发指令

  • commit {language_type1}:生成{language_type1} commit 信息
  • commit {language_type2}:生成{language_type2} commit 信息

核心原则

  1. 基于实际代码变更:commit 信息必须基于实际代码变更内容生成,而不是仅根据文件名猜测。
  2. 关注具体变更:专注于具体的代码改动,避免泛泛而谈。描述要具体到修改了什么功能、添加了什么代码、修复了什么问题。
  3. 隐私保护
    • 不要输出姓名、邮箱地址或其他个人身份信息(除非在代码变更中明确存在且是必要的)
    • 不要输出bug ID、issue ID、ticket ID 或其他唯一标识符(除非在代码变更中明确存在且是必要的)
  4. 简洁准确:commit 信息要简洁明了,准确反映代码的实际变更内容,不超过 60 字符。

执行步骤

  1. 检查暂存区和工作区

    • 执行 git status --short 检查暂存区和工作区的状态。
    • 如果暂存区有文件(第一列有 A/M/D/R 等标记),直接进入下一步。
    • 如果暂存区为空,检查工作区是否有未暂存的变更:
      • 如果工作区有修改的文件(第二列有 M/D 标记)或未跟踪的文件(?? 标记),自动执行 git add 暂存这些文件。
      • 使用直接文件路径而不是目录路径,避免卡住(例如:git add "file1" "file2")。
      • 暂存完成后,重新执行 git status --short 确认文件已暂存。
  2. 获取实际代码变更内容(关键步骤):

    • 必须执行 git --no-pager diff --cached 获取暂存区的完整代码变更内容
    • 重要:使用 --no-pager 选项避免分页器阻塞,确保命令直接输出所有内容。
    • 这是生成准确 commit 信息的基础,不能跳过。
    • 仔细阅读代码变更,专注于具体的改动,理解:
      • 具体修改了什么功能?(例如:添加了用户登录验证逻辑,而不是"更新了代码")
      • 具体添加了什么新代码?(例如:新增了 token 过期检查函数,而不是"添加了代码")
      • 具体删除了什么代码?(例如:移除了过时的 API 调用,而不是"删除了代码")
      • 具体修复了什么问题?(例如:修复了登录后页面跳转失败的问题,原因是缺少 await,而不是"修复了 bug")
      • 具体重构了什么逻辑?(例如:将用户认证逻辑提取到独立模块,而不是"重构了代码")
    • 注意:如果代码变更中包含个人信息或唯一标识符,不要在 commit 信息中输出。
  3. 分析代码变更

    • 基于实际的代码变更内容,判断变更类型:
      • 新增功能代码 → feat
      • 修复 bug 的代码 → fix
      • 文档/注释变更 → docs
      • 代码格式调整 → style
      • 代码重构 → refactor
      • 性能优化 → perf
      • 测试代码 → test
      • 构建/配置文件 → chore
    • 提取变更的核心内容,作为 commit 信息的描述。
    • 避免模糊描述:不要使用"更新代码"、"修改文件"、"优化代码"等泛泛而谈的描述。
    • 使用具体描述:例如"修复登录跳转失败"、"添加 token 过期检查"、"重构用户认证模块"等。
  4. 生成 commit message

    • 格式:多行格式,包含简洁的 subject 和详细的主要变更
      <type>(<scope>): <subject>
      
      - <主要变更1>
      - <主要变更2>
      - <主要变更3>
      
    • 语言要求
      • commit {language_type1} → subject 和主要变更都使用**{language_type1}**
      • commit {language_type2} → subject 和主要变更都使用**{language_type2}**
    • 准确描述:commit 信息必须准确反映代码变更的实际内容
    • subject 要求:简洁明了,不超过 60 字符,概括主要变更点
    • 主要变更要求:基于 git diff 的实际内容,列出具体的变更点,每个变更点一行,使用 - 开头

Read the full file on GitHub · 231 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. 2d ago First seen · 231 lines · 2,542 tokens per session scan A b94902afc72e

Subscribe to this mod's changes

commit-commands is a cursor rule published in the GitHub repository ttdazi/CursorAiCommit (2 stars, last pushed 9mo ago), licensed MIT. It adds 2,542 tokens to every session, about $0.0127 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.