commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Commit

提交

Quick start

快速开始

When user triggers
/commit
or asks to commit:
  1. Run
    git add -A
    to stage all changes
  2. Run
    git status
    and
    git diff --staged
    to review changes
  3. Draft a conventional commit message (
    type(scope): subject
    )
  4. Present summary + commit message to user
  5. Ask for confirmation via
    question
    tool
  6. If confirmed:
    git commit -m "message"
当用户触发
/commit
或请求提交时:
  1. 运行
    git add -A
    暂存所有更改
  2. 运行
    git status
    git diff --staged
    查看更改
  3. 起草符合规范的提交信息(
    type(scope): subject
    格式)
  4. 向用户展示更改摘要和提交信息
  5. 通过
    question
    工具请求用户确认
  6. 若确认:执行
    git commit -m "message"

Workflow

工作流

1. Stage all changes

1. 暂存所有更改

Run
git add -A
to stage all modified, added, and deleted files.
运行
git add -A
暂存所有已修改、新增和删除的文件。

2. Review changes

2. 查看更改

Run in parallel:
  • git status
  • git diff --staged
  • git log --oneline -5
    (for context)
Identify:
  • Modified, added, deleted files
  • The nature of changes (feature, fix, refactor, docs, test, chore)
并行运行以下命令:
  • git status
  • git diff --staged
  • git log --oneline -5
    (用于获取上下文)
确认以下内容:
  • 已修改、新增、删除的文件
  • 更改的类型(功能新增、Bug修复、代码重构、文档更新、测试修改、杂项任务)

3. Draft commit message

3. 起草提交信息

  • feat: new feature
  • fix: bug fix
  • docs: documentation changes
  • style: formatting, missing semicolons, etc.
  • refactor: code change that neither fixes a bug nor adds a feature
  • test: adding or correcting tests
  • chore: build process, dependencies, tooling
Format:
type(scope): subject
Rules:
  • Subject is lowercase, no trailing period
  • Max 50 chars for subject line
  • Include body only if change needs explanation
  • NEVER mention AI-generated, drafted by AI, or similar
遵循Conventional Commits规范:
  • feat: 新增功能
  • fix: Bug修复
  • docs: 文档变更
  • style: 格式调整(如缺失分号等)
  • refactor: 既不修复Bug也不新增功能的代码变更
  • test: 添加或修正测试
  • chore: 构建流程、依赖项、工具相关变更
格式:
type(scope): subject
规则:
  • 主题部分小写,末尾不加句号
  • 主题行最多50个字符
  • 仅当变更需要额外说明时才添加正文
  • 绝对不要提及AI生成、由AI起草等相关内容

4. Present to user

4. 向用户展示

Show:
undefined
展示内容如下:
undefined

Changes to be committed

待提交的更改

<git status output>
<git status输出内容>

Proposed commit message

建议的提交信息

<type>(<scope>): <subject>
<type>: <description of why>
undefined
<type>(<scope>): <subject>
<type>: <变更原因说明>
undefined

5. Ask for confirmation

5. 请求确认

Use the
question
tool with options:
  • "Yes, commit" (Recommended)
  • "Edit message first"
  • "Cancel"
If user chooses "Edit message first", ask them to provide the new message, then re-present.
使用
question
工具提供以下选项:
  • "确认提交"(推荐)
  • "先编辑提交信息"
  • "取消"
若用户选择"先编辑提交信息",请让用户提供新的提交信息,然后重新展示。

6. Execute

6. 执行提交

On confirmation, run
git commit -m "message"
. If commit fails, show error and offer to fix.
用户确认后,运行
git commit -m "message"
。 若提交失败,显示错误信息并提供修复建议。

Safety rules

安全规则

  • NEVER use
    git push
    unless explicitly requested
  • NEVER use
    --no-verify
    or skip hooks unless user asks
  • NEVER commit
    .env
    , credentials, or secrets (warn user if detected)
  • If working tree is clean, inform user there's nothing to commit
  • 除非用户明确要求,否则绝对不要使用
    git push
  • 除非用户要求,否则绝对不要使用
    --no-verify
    或跳过钩子
  • 绝对不要提交
    .env
    文件、凭证或机密信息(若检测到此类内容,需提醒用户)
  • 若工作区无更改,告知用户没有可提交的内容