commit-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit Workflow
提交工作流
Use this skill when the user asks to create a commit from current repository changes.
当用户要求基于当前仓库变更创建提交时,使用本Skill。
Output Goal
输出目标
Create exactly one local git commit that includes only intended files and uses a concise Conventional Commits-style subject. Do not push.
创建恰好一个本地git提交,仅包含指定文件,并使用简洁的Conventional Commits风格的主题。不要执行推送操作。
Commit Message Format
Commit信息格式
<type>(<scope>): <summary>- REQUIRED.
type- Use for new user-facing features.
feat - Use for bug fixes.
fix - Common alternatives: ,
docs,refactor,chore,test,perf,build.ci
- Use
- OPTIONAL. Keep it short and noun-like (examples:
scope,api,parser,ui).git - REQUIRED.
summary- Imperative mood.
- <= 72 chars.
- No trailing period.
<type>(<scope>): <summary>- 为必填项。
type- 新增面向用户的功能时使用。
feat - 修复Bug时使用。
fix - 常见替代类型:、
docs、refactor、chore、test、perf、build。ci
- 新增面向用户的功能时使用
- 为可选项。需简短且为名词形式(示例:
scope、api、parser、ui)。git - 为必填项。
summary- 使用祈使语气。
- 长度不超过72个字符。
- 末尾不加句号。
Rules
规则
- Body is optional. If needed, insert a blank line after the subject.
- Do not add breaking-change markers/footers.
- Do not add sign-offs.
- Commit only. Never push.
- If file inclusion is ambiguous, ask the user which files to include before committing.
- Never include likely secrets (, key files, credentials) unless user explicitly requests it.
.env
- 正文为可选项。若需要,在主题后插入一个空行。
- 不要添加破坏性变更标记/页脚。
- 不要添加签署信息。
- 仅执行提交操作,绝不推送。
- 若文件包含范围不明确,在提交前询问用户应包含哪些文件。
- 除非用户明确要求,否则绝不包含可能的敏感文件(如、密钥文件、凭证)。
.env
Procedure
操作步骤
- Inspect repository state:
git statusgit diffgit diff --staged
- Optionally inspect recent subject style:
git log -n 50 --pretty=format:%s
- Decide the file set to commit:
- If unambiguous, proceed.
- If ambiguous, ask user which files to include.
- Stage only intended files.
- Draft a concise subject reflecting why the change exists.
- Create one commit.
- Verify final state with and report:
git status- commit hash
- subject
- staged/unstaged leftovers (if any)
- 检查仓库状态:
git statusgit diffgit diff --staged
- (可选)检查近期提交主题风格:
git log -n 50 --pretty=format:%s
- 确定要提交的文件集:
- 若范围明确,直接继续。
- 若范围不明确,询问用户应包含哪些文件。
- 仅暂存指定文件。
- 撰写简洁的主题,说明变更的原因。
- 创建一个提交。
- 使用验证最终状态并报告:
git status- 提交哈希值
- 提交主题
- 暂存/未暂存的剩余变更(若有)
Failure Handling
故障处理
- If commit fails due to hooks, inspect hook output and fix the issue.
- After fixing, create a new commit (do not amend unless user asked to amend).
- If there are no changes to commit, report that clearly and do not create an empty commit.
- 若提交因钩子失败,检查钩子输出并修复问题。
- 修复后创建新的提交(除非用户要求修改,否则不要使用amend)。
- 若没有可提交的变更,清晰告知用户,不要创建空提交。
Quick Reference
快速参考
bash
git status
git diff
git diff --staged
git log -n 50 --pretty=format:%s
git add <paths>
git commit -m "<type>(<scope>): <summary>"
git statusbash
git status
git diff
git diff --staged
git log -n 50 --pretty=format:%s
git add <paths>
git commit -m "<type>(<scope>): <summary>"
git status