commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Commit

Commit

Goals

目标

  • Produce a commit that reflects the actual code changes and the session context.
  • Follow common git conventions (type prefix, short subject, wrapped body).
  • Include both summary and rationale in the body.
  • 生成能够反映实际代码变更和会话上下文的commit。
  • 遵循通用git规范(类型前缀、简短主题、自动换行的正文)。
  • 在正文中同时包含摘要和变更理由。

Inputs

输入

  • Codex session history for intent and rationale.
  • git status
    ,
    git diff
    , and
    git diff --staged
    for actual changes.
  • Repo-specific commit conventions if documented.
  • 用于获取意图和变更理由的Codex会话历史。
  • 用于获取实际变更的
    git status
    git diff
    git diff --staged
    输出。
  • 仓库自身记录的专属commit规范(如果有文档说明)。

Steps

步骤

  1. Read session history to identify scope, intent, and rationale.
  2. Inspect the working tree and staged changes (
    git status
    ,
    git diff
    ,
    git diff --staged
    ).
  3. Stage intended changes, including new files (
    git add -A
    ) after confirming scope.
  4. Sanity-check newly added files; if anything looks random or likely ignored (build artifacts, logs, temp files), flag it to the user before committing.
  5. If staging is incomplete or includes unrelated files, fix the index or ask for confirmation.
  6. Choose a conventional type and optional scope that match the change (e.g.,
    feat(scope): ...
    ,
    fix(scope): ...
    ,
    refactor(scope): ...
    ).
  7. Write a subject line in imperative mood, <= 72 characters, no trailing period.
  8. Write a body that includes:
    • Summary of key changes (what changed).
    • Rationale and trade-offs (why it changed).
    • Tests or validation run (or explicit note if not run).
  9. Append a
    Co-authored-by
    trailer for Codex using
    Codex <codex@openai.com>
    unless the user explicitly requests a different identity.
  10. Wrap body lines at 72 characters.
  11. Create the commit message with a here-doc or temp file and use
    git commit -F <file>
    so newlines are literal (avoid
    -m
    with
    \n
    ).
  12. Commit only when the message matches the staged changes: if the staged diff includes unrelated files or the message describes work that isn't staged, fix the index or revise the message before committing.
  1. 读取会话历史,确定变更范围、意图和理由。
  2. 检查工作区和暂存变更(
    git status
    git diff
    git diff --staged
    )。
  3. 确认范围后,暂存目标变更,包括新增文件(
    git add -A
    )。
  4. 对新增文件做合理性检查:如果存在看起来异常、大概率应被忽略的文件(构建产物、日志、临时文件),提交前要向用户标记提示。
  5. 如果暂存不完整或者包含无关文件,修正暂存区或者向用户请求确认。
  6. 选择符合变更内容的规范类型和可选范围(例如
    feat(scope): ...
    fix(scope): ...
    refactor(scope): ...
    )。
  7. 用祈使语气编写主题行,长度不超过72字符,末尾不加句号。
  8. 编写正文,包含以下内容:
    • 关键变更摘要(改了什么)。
    • 变更理由和权衡(为什么改)。
    • 已执行的测试或验证(如果未执行要明确注明)。
  9. 追加
    Co-authored-by
    尾部信息,标注Codex为共同作者,内容为
    Codex <codex@openai.com>
    ,除非用户明确要求使用其他身份。
  10. 正文每行长度限制在72字符,超出自动换行。
  11. 使用here-doc或者临时文件生成commit信息,使用
    git commit -F <file>
    提交以保留换行符(避免使用带
    \n
    -m
    参数)。
  12. 仅当commit信息和暂存变更匹配时才执行提交:如果暂存diff包含无关文件,或者信息描述的内容未被暂存,先修正暂存区或者修改提交信息再提交。

Output

输出

  • A single commit created with
    git commit
    whose message reflects the session.
  • 通过
    git commit
    创建的单个commit,其提交信息与会话内容匹配。

Template

模板

Type and scope are examples only; adjust to fit the repo and changes.
<type>(<scope>): <short summary>

Summary:
- <what changed>
- <what changed>

Rationale:
- <why>
- <why>

Tests:
- <command or "not run (reason)">

Co-authored-by: Codex <codex@openai.com>
类型和范围仅为示例,请根据仓库和变更内容调整。
<type>(<scope>): <short summary>

Summary:
- <what changed>
- <what changed>

Rationale:
- <why>
- <why>

Tests:
- <command or "not run (reason)">

Co-authored-by: Codex <codex@openai.com>