ci-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCommit Changes
提交更改
Treat explicit invocation as authorization to create commits now. Use the
conversation as the ownership ledger: commit the changes produced for the
current task, preserve unrelated work, and finish without asking for another
confirmation.
Pushing, amending existing commits, bypassing hooks, and destructive cleanup are
separate operations and require explicit user authorization.
将显式调用视为立即创建提交的授权。以对话记录作为变更归属台账:提交为当前任务产生的更改,保留无关工作,并在结束时不再请求确认。
推送(push)、修改已有提交(amend)、绕过 hooks 和破坏性清理属于独立操作,需要用户明确授权。
1. Reconstruct the owned change set
1. 重建所属变更集
Review the conversation, repository instructions, and commands already run.
Then inspect all worktree states:
bash
git status --short
git diff --stat
git diff
git diff --cached --stat
git diff --cachedInspect the contents of relevant untracked files because omits them.
Classify every changed path as one of:
git diff- owned: created or changed for the current task;
- required consequence: generated or lockfile output that repository convention requires for an owned source change;
- unrelated: pre-existing user work, another agent's work, or a change whose ownership the session cannot establish;
- debris: scratch files, dummy data, temporary test scripts, debug output, or incidental generated files.
Production tests written for the task are owned changes, not temporary test
scripts. Keep unrelated and debris paths out of every commit. Exclude workflow
scratch and control artifacts identified by repository configuration or
, including when present. Retain required production
outputs even when the workflow produces them.
.gitignore.agent-work/If the repository is in a merge, rebase, cherry-pick, or revert, or if already
staged content overlaps unrelated work, read
before
proceeding.
references/commit-edge-cases.mdCompletion criterion: every staged, unstaged, and relevant untracked path is
accounted for; each proposed commit contains only owned changes and required
consequences; no proposed commit contains excluded workflow artifacts,
unrelated work, or debris.
回顾对话、仓库说明以及已经执行过的命令。
然后检查所有 worktree 状态:
bash
git status --short
git diff --stat
git diff
git diff --cached --stat
git diff --cached检查相关未跟踪文件的内容,因为 不会显示这些文件。
将每个发生更改的路径归类为以下类别之一:
git diff- 所属(owned):为当前任务创建或修改的变更;
- 必需附带变更(required consequence):仓库约定要求随所属源代码变更一并生成的产物或 lockfile 输出;
- 无关(unrelated):用户预先存在的工作、其他 Agent 的工作,或本次会话无法确定归属的变更;
- 残留物(debris):临时文件、虚拟数据、临时测试脚本、调试输出或偶然生成的文件。
为任务编写的生产测试属于所属变更,而不是临时测试脚本。无关路径和残留物路径不得包含在任何提交中。排除由仓库配置或 标识的工作流临时文件及控制产物,包括存在时的 。即使工作流生成了这些文件,也应保留必需的生产输出。
.gitignore.agent-work/如果仓库当前处于 merge、rebase、cherry-pick 或 revert 状态,或者已暂存的内容与无关工作重叠,请在继续之前阅读
。
references/commit-edge-cases.md完成标准: 每个已暂存、未暂存及相关未跟踪路径都已被归类;每个拟议提交仅包含所属变更和必需附带变更;任何拟议提交均不包含被排除的工作流产物、无关工作或残留物。
2. Design the commit series
2. 设计提交序列
Partition the owned change set by intent. Use one commit when all changes serve
one coherent outcome; use multiple commits when a reviewer could understand,
revert, or reuse the groups independently. Keep coupled implementation, tests,
documentation, migrations, and required generated outputs together when
separating them would leave an invalid or misleading intermediate state.
For each commit, define:
- the exact files or hunks it owns;
- the reason those changes belong together;
- an imperative subject that states the outcome;
- an optional body when the motivation or non-obvious tradeoff is not clear from the diff.
Follow repository-specific commit conventions when present. Message text should
explain the reason or outcome rather than narrate filenames.
Completion criterion: every owned change and required consequence appears in
exactly one planned commit, every group is coherent on its own, dependency order
is valid, and each commit has a final message before staging begins.
按照变更意图划分所属变更集。当所有变更共同实现一个连贯结果时,使用一个提交;当评审者可以独立理解、回退或复用各个分组时,使用多个提交。若拆分后会留下无效或具有误导性的中间状态,则应将相互依赖的实现、测试、文档、迁移及必需生成产物放在同一提交中。
对于每个提交,明确:
- 其负责的确切文件或 hunks;
- 这些变更需要放在一起的原因;
- 描述结果的祈使式主题;
- 当 diff 无法清楚说明动机或非显而易见的权衡时,可选择添加正文。
如果仓库存在特定的提交约定,应遵循这些约定。提交信息应说明变更的原因或结果,而不是逐个叙述文件名。
完成标准: 每项所属变更和必需附带变更都恰好出现在一个计划提交中;每个分组本身都是连贯的;依赖顺序有效;暂存开始前,每个提交都已确定最终信息。
3. Stage one exact commit
3. 暂存一个精确的提交
Stage only the current group, naming exact paths:
bash
git add -- path/to/file another/pathUse patch staging when a file mixes intents:
bash
git add -p -- path/to/fileNever use broad staging forms such as , , or an
unreviewed glob. Preserve pre-existing staged work that does not belong to the
current commit. For partial staging, pre-existing staged content, rename/delete
handling, or submodules, follow
.
git add .git add -Areferences/commit-edge-cases.mdAudit the exact candidate commit:
bash
git diff --cached --stat
git diff --cachedCheck for accidental credentials, unrelated formatting churn, debugging code,
conflict markers, debris, and excluded workflow scratch or control paths.
Correct the index with path-specific or patch-based staging and repeat the audit
until it matches the planned group exactly.
Completion criterion: the complete cached diff has been read; it matches
one and only one planned commit; every staged line is intentional; the cached
path list contains no excluded or unowned path.
仅暂存当前分组,并明确指定具体路径:
bash
git add -- path/to/file another/path当一个文件混合了不同意图时,使用补丁暂存:
bash
git add -p -- path/to/file切勿使用 、 或未经审查的 glob 等宽泛的暂存方式。保留不属于当前提交的既有暂存工作。对于部分暂存、既有暂存内容、重命名或删除处理,以及 submodules,请遵循
。
git add .git add -Areferences/commit-edge-cases.md审查确切的候选提交:
bash
git diff --cached --stat
git diff --cached检查是否意外包含凭据、无关的格式变更、调试代码、冲突标记、残留物,以及被排除的工作流临时文件或控制路径。使用按路径暂存或基于补丁的暂存方式修正暂存区,并重复审查,直至其与计划分组完全一致。
完成标准: 已完整阅读所有暂存 diff;其仅匹配一个计划提交;每一行暂存内容都有明确意图;暂存路径列表中不包含任何被排除或无所属权的路径。
4. Create and verify the commit
4. 创建并验证提交
Create the commit with the planned message:
bash
git commit -m "<imperative subject>"Allow configured hooks to run. Never add unless the user
explicitly authorized bypassing hooks. When a hook fails or mutates files, read
the matching branch in
, repair the
candidate safely, and re-audit the cached diff before retrying.
--no-verifyreferences/commit-edge-cases.mdAfter success, inspect the created object and current worktree:
bash
git show --stat --patch --no-ext-diff HEAD
git status --shortRepeat steps 3 and 4 for every remaining planned commit.
Completion criterion: every planned commit exists with the intended message
and content, all configured hooks completed successfully, and the remaining
status contains no owned change that was planned for this invocation.
使用计划好的提交信息创建提交:
bash
git commit -m "<imperative subject>"允许已配置的 hooks 运行。除非用户明确授权绕过 hooks,否则切勿添加 。当 hook 执行失败或修改文件时,阅读
中对应的分支,安全地修复候选提交,并在重试前重新审查暂存 diff。
--no-verifyreferences/commit-edge-cases.md成功后,检查创建的提交对象和当前 worktree:
bash
git show --stat --patch --no-ext-diff HEAD
git status --short对每个剩余的计划提交重复步骤 3 和步骤 4。
完成标准: 每个计划提交都已使用预期的信息和内容创建;所有已配置的 hooks 均成功完成;剩余状态中不包含原计划在本次调用中提交的所属变更。
5. Report the result
5. 报告结果
Return:
- each new commit hash and subject, in creation order;
- the intent of each commit;
- hook or repository check results that ran during commit creation;
- every remaining changed path, classified as intentionally untouched; or an explicit statement that the worktree is clean.
If no owned changes exist, say that no commit was created. If Git cannot safely
create the requested commits after the recovery paths in the edge-case
reference are exhausted, report the exact blocking state and the evidence used
to identify it; do not claim completion.
Completion criterion: the report accounts for every commit created and
every remaining worktree change, and its hashes and status agree with Git's
current state.
返回:
- 按创建顺序排列的每个新提交哈希及主题;
- 每个提交的意图;
- 创建提交期间运行的 hook 或仓库检查结果;
- 每个剩余变更路径,并说明其为有意保留;如果 worktree 干净,则明确说明。
如果不存在所属变更,请说明未创建提交。如果在耗尽边界情况参考文档中的恢复路径后,Git 仍无法安全创建所请求的提交,请报告具体的阻塞状态及用于识别该状态的证据;不要声称任务已经完成。
完成标准: 报告涵盖每个已创建的提交和每项剩余的 worktree 变更,并且其中的哈希和状态与 Git 当前状态一致。