commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBackground 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,cistyle - Body (REQUIRED): Bullet points with prefix, imperative verbs, ≤72 chars/line
- - Footer: is REQUIRED for all AI commits
Co-Authored-By
结构:
<type>(<scope>): <description>
[可选上下文段落]
- <Action> <component> <detail>
[解释段落]
Co-Authored-By: <Model Name> <noreply@anthropic.com>规则:
- 标题: 全部小写,长度<50字符,使用祈使语气,无句号。对于破坏性变更,在":"前添加"!"
- 类型: ,
feat,fix,docs,refactor,perf,test,chore,build,cistyle - 正文(必填): 使用"- "前缀的项目符号,祈使动词,每行≤72字符
- 页脚: 所有AI生成的提交必须包含
Co-Authored-By
Phase 1: Configuration Verification
阶段1:配置验证
Goal: Load project-specific git configuration and valid scopes.
Actions:
- FIRST: Read to load project configuration
.claude/git.local.md - If file not found, load skill using the Skill tool to create it
git:config-git - Extract valid scopes from list in YAML frontmatter
scopes:
目标: 加载项目特定的Git配置和有效作用域(scope)。
操作:
- 首先: 读取文件以加载项目配置
.claude/git.local.md - 如果文件未找到,使用Skill工具加载Skill来创建该文件
git:config-git - 从YAML前置元数据的列表中提取有效作用域
scopes:
Phase 2: Change Analysis
阶段2:变更分析
Goal: Identify logical units of work and infer commit scopes.
Actions:
- Run and
git diff --cachedto get code differences (MUST NOT traverse files directly)git diff - Analyze diff to identify coherent logical units
- Infer scope(s) from file paths and changes using the valid scopes loaded in Phase 1
- If inferred scope not in the valid scopes list, load skill using the Skill tool to update configuration
git:config-git
目标: 识别工作的逻辑单元并推断提交作用域。
操作:
- 运行和
git diff --cached命令获取代码差异(禁止直接遍历文件)git diff - 分析差异以识别连贯的逻辑单元
- 使用阶段1中加载的有效作用域,从文件路径和变更内容推断作用域
- 如果推断的作用域不在有效作用域列表中,使用Skill工具加载Skill来更新配置
git:config-git
Phase 3: AI Code Quality Check
阶段3:AI代码质量检查
Goal: Remove AI-generated slop before committing.
Actions:
- Launch agent with Task tool (model: sonnet) to review changes
- Remove AI patterns: extra comments, unnecessary defensive checks, casts, inconsistent style
any - Agent runs autonomously without user confirmation
目标: 在提交前移除AI生成的冗余内容。
操作:
- 使用Task工具启动agent(模型:sonnet)来审查变更
- 移除AI生成的冗余模式:额外注释、不必要的防御性检查、类型转换、不一致的代码风格
any - Agent自主运行,无需用户确认
Phase 4: Commit Creation
阶段4:提交创建
Goal: Create atomic commits following Conventional Commits format.
Actions (repeat for each logical unit):
- Draft commit message per above
Commit Format Rules - Validate: title <50 chars lowercase imperative; body has bullets + explanation paragraph; footer has
Co-Authored-By - Stage relevant files and create commit
目标: 遵循Conventional Commits格式创建原子提交。
操作(针对每个逻辑单元重复执行):
- 根据上述「提交格式规则」草拟提交信息
- 验证:标题长度<50字符、小写祈使语气;正文包含项目符号+解释段落;页脚包含
Co-Authored-By - 暂存相关文件并创建提交