commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Commit Skill

Commit Skill

Create conventional commits after task completion with user confirmation.
在完成任务后,经用户确认后创建符合规范的conventional commits。

When to Use

适用场景

  • After completing a task or logical unit of work
  • When the user requests a commit
  • After significant documentation updates
  • After implementing a feature or fix
  • 完成任务或一个逻辑工作单元后
  • 用户请求提交时
  • 完成重要文档更新后
  • 实现新功能或修复Bug后

Procedure

操作流程

Step 1: Gather Changes

步骤1:收集更改

bash
git status
git diff --stat
bash
git status
git diff --stat

Step 2: Analyze Changes

步骤2:分析更改

Identify:
  • Files modified, added, or deleted
  • Type of change (feat, fix, docs, refactor, style, test, chore)
  • Scope (which module/area affected)
  • Breaking changes (if any)
确认以下内容:
  • 已修改、新增或删除的文件
  • 更改类型(feat、fix、docs、refactor、style、test、chore)
  • 影响范围(涉及哪个模块/区域)
  • 是否存在破坏性更改(若有)

Step 3: Draft Commit Message

步骤3:草拟提交信息

Use conventional commits format:
<type>(<scope>): <short description>

<body with details>

<footer>
Types:
  • feat
    : New feature
  • fix
    : Bug fix
  • docs
    : Documentation only
  • refactor
    : Code change that neither fixes a bug nor adds a feature
  • style
    : Formatting, missing semicolons, etc.
  • test
    : Adding or updating tests
  • chore
    : Maintenance tasks, dependencies
Example:
feat(auth): add password reset flow

- Add forgot password endpoint
- Implement email verification token
- Add password reset form component

Closes #123
使用conventional commits格式:
<type>(<scope>): <简短描述>

<详细说明正文>

<页脚>
类型说明:
  • feat
    :新功能
  • fix
    :修复Bug
  • docs
    :仅更新文档
  • refactor
    :既不修复Bug也不添加新功能的代码变更
  • style
    :格式调整,如缺少分号等
  • test
    :添加或更新测试
  • chore
    :维护任务、依赖管理等
示例:
feat(auth): add password reset flow

- Add forgot password endpoint
- Implement email verification token
- Add password reset form component

Closes #123

Step 4: Show Diff and Confirm

步骤4:展示差异并确认

Before committing, ALWAYS:
  1. Show the user what will be committed:
bash
git diff --staged  # or git diff if not staged
  1. Show the proposed commit message
  2. Ask: "Ready to commit these changes? (yes/no)"
  3. Wait for explicit user approval
提交前,必须执行以下操作:
  1. 向用户展示即将提交的内容:
bash
git diff --staged  # 若未暂存则使用 git diff
  1. 展示草拟的提交信息
  2. 询问:"是否准备提交这些更改?(是/否)"
  3. 等待用户明确批准

Step 5: Execute Commit (only after approval)

步骤5:执行提交(仅在获得批准后)

bash
git add -A  # or specific files
git commit -m "<message>"
bash
git add -A  # 或指定具体文件
git commit -m "<message>"

Step 6: Verify

步骤6:验证提交

bash
git log -1 --stat
bash
git log -1 --stat

Rules

规则

  1. NEVER push — Only commit locally, never run
    git push
  2. ALWAYS confirm — Never commit without explicit user approval
  3. Show diff first — User must see changes before approving
  4. One logical unit — Each commit should represent one complete change
  5. Conventional format — Always use type(scope): description format
  1. 禁止推送 — 仅在本地提交,绝不执行
    git push
    命令
  2. 必须确认 — 未经用户明确批准,绝不提交
  3. 先展示差异 — 用户必须先查看更改内容再批准
  4. 单一逻辑单元 — 每次提交应代表一个完整的独立更改
  5. 遵循规范格式 — 始终使用 type(scope): description 格式

Output Format

输出格式

undefined
undefined

Proposed Commit

拟提交内容

Type: feat Scope: auth Files:
  • src/auth/reset.ts (new)
  • src/components/ResetForm.tsx (new)
  • src/api/routes.ts (modified)
Message:
feat(auth): add password reset flow

- Add forgot password endpoint
- Implement email verification token
- Add password reset form component

Closes #123
Diff summary: 3 files changed, 245 insertions(+)

Ready to commit these changes?
undefined
类型: feat 范围: auth 涉及文件:
  • src/auth/reset.ts (新增)
  • src/components/ResetForm.tsx (新增)
  • src/api/routes.ts (修改)
提交信息:
feat(auth): add password reset flow

- Add forgot password endpoint
- Implement email verification token
- Add password reset form component

Closes #123
差异摘要: 3 files changed, 245 insertions(+)

是否准备提交这些更改?
undefined