commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Background Knowledge

背景知识

Commit Format Rules

提交格式规则

Structure:
<type>(<scope>): <description>

[optional context paragraph]

- <Action> <component> <detail>

[explanation paragraph]

Co-Authored-By: <Model Name> <noreply@anthropic.com>
Rules:
  • Title: ALL LOWERCASE, <50 chars, imperative, no period. Add "!" before ":" for breaking changes
  • Types:
    feat
    ,
    fix
    ,
    docs
    ,
    refactor
    ,
    perf
    ,
    test
    ,
    chore
    ,
    build
    ,
    ci
    ,
    style
  • Body (REQUIRED): Bullet points with
    - 
    prefix, imperative verbs, ≤72 chars/line
  • Footer:
    Co-Authored-By
    is REQUIRED for all AI commits
结构:
<type>(<scope>): <description>

[可选上下文段落]

- <Action> <component> <detail>

[解释段落]

Co-Authored-By: <Model Name> <noreply@anthropic.com>
规则:
  • 标题: 全部小写,长度<50字符,使用祈使语气,无句号。对于破坏性变更,在":"前添加"!"
  • 类型:
    feat
    ,
    fix
    ,
    docs
    ,
    refactor
    ,
    perf
    ,
    test
    ,
    chore
    ,
    build
    ,
    ci
    ,
    style
  • 正文(必填): 使用"- "前缀的项目符号,祈使动词,每行≤72字符
  • 页脚: 所有AI生成的提交必须包含
    Co-Authored-By

Phase 1: Configuration Verification

阶段1:配置验证

Goal: Load project-specific git configuration and valid scopes.
Actions:
  1. FIRST: Read
    .claude/git.local.md
    to load project configuration
  2. If file not found, load
    git:config-git
    skill
    using the Skill tool to create it
  3. Extract valid scopes from
    scopes:
    list in YAML frontmatter
目标: 加载项目特定的Git配置和有效作用域(scope)。
操作:
  1. 首先: 读取
    .claude/git.local.md
    文件以加载项目配置
  2. 如果文件未找到,使用Skill工具加载
    git:config-git
    Skill来创建该文件
  3. 从YAML前置元数据的
    scopes:
    列表中提取有效作用域

Phase 2: Change Analysis

阶段2:变更分析

Goal: Identify logical units of work and infer commit scopes.
Actions:
  1. Run
    git diff --cached
    and
    git diff
    to get code differences (MUST NOT traverse files directly)
  2. Analyze diff to identify coherent logical units
  3. Infer scope(s) from file paths and changes using the valid scopes loaded in Phase 1
  4. If inferred scope not in the valid scopes list, load
    git:config-git
    skill
    using the Skill tool to update configuration
目标: 识别工作的逻辑单元并推断提交作用域。
操作:
  1. 运行
    git diff --cached
    git diff
    命令获取代码差异(禁止直接遍历文件)
  2. 分析差异以识别连贯的逻辑单元
  3. 使用阶段1中加载的有效作用域,从文件路径和变更内容推断作用域
  4. 如果推断的作用域不在有效作用域列表中,使用Skill工具加载
    git:config-git
    Skill来更新配置

Phase 3: AI Code Quality Check

阶段3:AI代码质量检查

Goal: Remove AI-generated slop before committing.
Actions:
  1. Launch agent with Task tool (model: sonnet) to review changes
  2. Remove AI patterns: extra comments, unnecessary defensive checks,
    any
    casts, inconsistent style
  3. Agent runs autonomously without user confirmation
目标: 在提交前移除AI生成的冗余内容。
操作:
  1. 使用Task工具启动agent(模型:sonnet)来审查变更
  2. 移除AI生成的冗余模式:额外注释、不必要的防御性检查、
    any
    类型转换、不一致的代码风格
  3. Agent自主运行,无需用户确认

Phase 4: Commit Creation

阶段4:提交创建

Goal: Create atomic commits following Conventional Commits format.
Actions (repeat for each logical unit):
  1. Draft commit message per
    Commit Format Rules
    above
  2. Validate: title <50 chars lowercase imperative; body has bullets + explanation paragraph; footer has
    Co-Authored-By
  3. Stage relevant files and create commit
目标: 遵循Conventional Commits格式创建原子提交。
操作(针对每个逻辑单元重复执行):
  1. 根据上述「提交格式规则」草拟提交信息
  2. 验证:标题长度<50字符、小写祈使语气;正文包含项目符号+解释段落;页脚包含
    Co-Authored-By
  3. 暂存相关文件并创建提交