commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Commit Automation with WBS & Review

基于WBS与审查的Git提交自动化

Purpose

功能目标

Automate git commit workflow with:
  • WBS (Work Breakdown Structure) number tracking
  • Automated code review based on diff
  • Structured commit message generation
  • Interactive commit execution
IMPORTANT: Always communicate with the user in Korean (한국어) throughout the entire workflow.
实现Git提交工作流自动化,包含以下功能:
  • WBS(工作分解结构)编号追踪
  • 基于差异的自动化代码审查
  • 结构化提交消息生成
  • 交互式提交执行
重要提示:在整个工作流中始终使用韩语(한국어)与用户沟通。

Trigger Conditions

触发条件

When to activate this skill:

何时激活该技能:

  • 커밋해줘 / 커밋 쳐줘 / 커밋 올려줘
  • 커밋 메시지 만들어줘 / 커밋메시지 / 커밋 메세지
  • git commit / commit message / 커밋 메시지 추천
  • "WBS 1234로 커밋" (WBS + commit mention)
  • "메시지만" (message generation only, no commit execution)
  • 커밋해줘 / 커밋 쳐줘 / 커밋 올려줘
  • 커밋 메시지 만들어줘 / 커밋메시지 / 커밋 메세지
  • git commit / commit message / 提交消息推荐
  • "WBS 1234로 커밋"(提及WBS与提交)
  • "메시지만"(仅生成消息,不执行提交)

When NOT to activate:

何时不激活:

  • Simple git concept questions (e.g., "커밋이 뭐야?")

  • 简单的Git概念问题(例如:"커밋이 뭐야?")

Workflow

工作流

Performance Note: Cache git command results throughout the workflow. Do not re-run
git status
,
git diff
, or
git log
if already executed in previous steps.
性能注意事项: 在整个工作流中缓存Git命令结果。如果之前步骤已执行过
git status
git diff
git log
,则无需重复运行。

Step 0: WBS Selection

步骤0:WBS选择

If user provided WBS number in the request:
  • Parse patterns:
    • Single: "WBS 123", "WBS-123", "123으로 커밋", "커밋 123", "/commit 123"
    • Multiple: "13, 14로 커밋", "커밋 13 14", "/commit 13, 14"
  • Extract number(s) from the request:
    • Single number → format as
      WBS-<number>
      (e.g., 1234 → WBS-1234)
    • Multiple numbers → split by comma/space, format each, join with ", " (e.g., "13, 14" → WBS-13, WBS-14)
  • IMPORTANT: Skip selection UI and proceed directly to Step 1 with the extracted WBS number(s)
If NO WBS number provided:
  1. Run
    git log -1 --pretty=%B
    to get the most recent commit message
    • This is more reliable than reading
      .git/COMMIT_EDITMSG
      (works correctly during amend/rebase)
    • If this fails, fallback to reading
      .git/COMMIT_EDITMSG
  2. Parse "Context:" section to extract WBS number from the most recent commit
  3. Extract the commit subject (first line) as the task description
  4. If WBS found (not "N/A"), prepare it as the previous WBS option with format: "WBS-XX (commit subject)"
  5. Present selection UI:
========================================
WBS 작업 선택:
========================================
1. 직접입력
2. WBS 없음 (N/A)
[3: Previous WBS if found, e.g., "3. WBS-48 (이전 커밋 제목)"]
4. 취소
========================================
선택 (숫자 입력):
  1. MANDATORY: Wait for user selection. Do NOT auto-select or assume any option based on previous commits.
Handle user selection:
  • Option 1 (직접입력): Prompt for WBS number:
    WBS 작업 번호를 입력해주세요:
    - 단일: 1234
    - 여러 개: 13, 14 또는 13 14
    - 없음: '없음' 입력
    • If "없음" or empty → set WBS to "N/A"
    • Otherwise → parse input:
      • Split by comma or space (e.g., "13, 14" or "13 14")
      • Format each as
        WBS-<number>
      • Join with ", " →
        WBS-13, WBS-14
  • Option 2 (WBS 없음): Set WBS to "N/A" and proceed
  • Option 3 (Previous WBS): Use the previous WBS number extracted from git log
  • Option 4 (취소): Exit workflow without proceeding
Important: Never invent or guess WBS numbers.

如果用户在请求中提供了WBS编号:
  • 解析格式:
    • 单个编号:"WBS 123"、"WBS-123"、"123으로 커밋"、"커밋 123"、"/commit 123"
    • 多个编号:"13, 14로 커밋"、"커밋 13 14"、"/commit 13, 14"
  • 从请求中提取编号:
    • 单个编号 → 格式化为
      WBS-<编号>
      (例如:1234 → WBS-1234)
    • 多个编号 → 按逗号/空格拆分,分别格式化后用", "连接(例如:"13, 14" → WBS-13, WBS-14)
  • 重要提示: 跳过选择界面,直接使用提取的WBS编号进入步骤1
如果未提供WBS编号:
  1. 运行
    git log -1 --pretty=%B
    获取最近一次的提交消息
    • 这比读取
      .git/COMMIT_EDITMSG
      更可靠(在 amend/rebase 过程中也能正常工作)
    • 如果此命令失败, fallback 到读取
      .git/COMMIT_EDITMSG
  2. 解析"Context:"部分,从最近的提交消息中提取WBS编号
  3. 提取提交主题(第一行)作为任务描述
  4. 如果找到WBS编号(不是"N/A"),将其整理为历史WBS选项,格式为:"WBS-XX (提交主题)"
  5. 展示选择界面:
========================================
WBS 작업 선택:
========================================
1. 직접입력
2. WBS 없음 (N/A)
[3: Previous WBS if found, e.g., "3. WBS-48 (이전 커밋 제목)"]
4. 취소
========================================
선택 (숫자 입력):
  1. 强制要求: 等待用户选择。不得基于历史提交自动选择或默认任何选项。
处理用户选择:
  • 选项1(직접입력): 提示用户输入WBS编号:
    WBS 작업 번호를 입력해주세요:
    - 단일: 1234
    - 여러 개: 13, 14 또는 13 14
    - 없음: '없음' 입력
    • 如果输入"없음"或为空 → 将WBS设置为"N/A"
    • 否则 → 解析输入:
      • 按逗号或空格拆分(例如:"13, 14"或"13 14")
      • 每个编号格式化为
        WBS-<编号>
      • 用", "连接 →
        WBS-13, WBS-14
  • 选项2(WBS 없음): 将WBS设置为"N/A"并继续
  • 选项3(历史WBS): 使用从Git日志中提取的历史WBS编号
  • 选项4(취소): 退出工作流,不继续执行
重要提示: 不得编造或猜测WBS编号。

Step 1: Inspect Changes

步骤1:检查更改

  1. MUST run
    git status -sb
    to get branch and file status
  2. MUST run diff commands:
    • First try:
      git diff --staged
    • If empty, try:
      git diff
  3. Summarize changes in 3-5 lines (what files changed, what kind of changes)
Commit Split Detection: If changes span multiple unrelated domains, suggest splitting:
  • Backend vs Frontend
  • Feature vs Refactor
  • Logic vs Formatting
  • Dependencies vs Business code
If split is recommended:
  1. Explain split criteria and reasoning
  2. List files for each commit unit
  3. Wait for user approval
  4. On approval:
    • Stage first unit →
      git add <files>
    • Continue with Step 2-6 for first unit
    • Repeat for remaining units
  5. If user says "just do it all at once" → proceed as single commit

  1. 必须运行
    git status -sb
    获取分支与文件状态
  2. 必须运行差异命令:
    • 首先尝试:
      git diff --staged
    • 如果为空,尝试:
      git diff
  3. 用3-5行总结更改内容(哪些文件被修改,修改类型是什么)
提交拆分检测: 如果更改涉及多个不相关领域,建议拆分提交:
  • 后端与前端
  • 功能开发与重构
  • 逻辑修改与格式调整
  • 依赖更新与业务代码
如果建议拆分:
  1. 说明拆分标准与理由
  2. 列出每个提交单元对应的文件
  3. 等待用户确认
  4. 确认后:
    • 暂存第一个单元 →
      git add <文件>
    • 针对第一个单元执行步骤2-6
    • 对剩余单元重复此流程
  5. 如果用户说"一次性提交所有内容" → 作为单个提交继续执行

Step 2: Code Review

步骤2:代码审查

Diff Scope Rule (Mandatory):
  • Review ONLY lines added/removed in the current diff
  • Inspect minimal surrounding context
  • Do NOT audit unrelated existing code
  • Ignore legacy technical debt not introduced by this change
  • Do NOT suggest architectural refactors unrelated to this diff
Review Checklist:
  1. Potential bugs:
    • Null/undefined handling
    • Edge cases
    • Error handling
    • Broken logic
  2. Debug leftovers:
    • console.log / print / System.out.println
    • TODO / FIXME comments
  3. Security issues:
    • Hard-coded secrets/tokens
    • Sensitive data in logs
    • SQL injection / XSS vulnerabilities
  4. Code quality:
    • Code duplication
    • Poor naming
    • Overly large functions/files
  5. Unintended changes:
    • Unrelated formatting changes
    • Stray files
    • Generated artifacts (build outputs, lock files if not intended)

差异范围规则(强制要求):
  • 仅审查当前差异中新增/删除的代码行
  • 检查最小范围的上下文
  • 不得审计无关的现有代码
  • 忽略此次更改未引入的遗留技术债务
  • 不得建议与当前差异无关的架构重构
审查清单:
  1. 潜在Bug:
    • 空值/未定义处理
    • 边界情况
    • 错误处理
    • 逻辑漏洞
  2. 调试残留:
    • console.log / print / System.out.println
    • TODO / FIXME注释
  3. 安全问题:
    • 硬编码的密钥/令牌
    • 日志中的敏感数据
    • SQL注入 / XSS漏洞
  4. 代码质量:
    • 代码重复
    • 命名不佳
    • 过大的函数/文件
  5. 意外更改:
    • 无关的格式修改
    • 多余文件
    • 生成的产物(构建输出、锁文件,除非是有意修改)

Step 3: Review Output

步骤3:审查结果输出

Present review results in Korean using this format:
markdown
undefined
使用韩语以下列格式展示审查结果:
markdown
undefined

🔍 변경 요약

🔍 변경 요약

  • [Brief summary of changes]
  • [更改内容简要总结]

⚠️ 리스크 / 주의점

⚠️ 리스크 / 주의점

  • [Identified risks or concerns, or "없음" if none]
  • [识别到的风险或注意事项,若无则填"없음"]

🛠️ 개선 제안

🛠️ 개선 제안

  • [Specific suggestions with file:line references, or "없음" if none]
  • [带文件:行号的具体建议,若无则填"없음"]

✅ 결론

✅ 결론

  • [리뷰 통과 | 수정 필요 | 커밋 분리 권장]

---
  • [리뷰 통과 | 수정 필요 | 커밋 분리 권장]

---

Step 4: Review Decision Branch

步骤4:审查决策分支

If review result = "리뷰 통과":
  • Proceed to Step 5
If review result = "수정 필요":
  • Do NOT generate commit message
  • Show review output and instruct: "위 이슈를 수정한 뒤 다시 커밋을 요청해주세요."
  • If user explicitly says "ignore and commit anyway" → proceed to Step 5
If review result = "커밋 분리 권장":
  • Follow Commit Split Guide from Step 1
  • Process each unit through Steps 2-6 separately

如果审查结果 = "리뷰 통과":
  • 进入步骤5
如果审查结果 = "수정 필요":
  • 不生成提交消息
  • 展示审查结果并提示:"위 이슈를 수정한 뒤 다시 커밋을 요청해주세요."
  • 如果用户明确表示"忽略并提交" → 进入步骤5
如果审查结果 = "커밋 분리 권장":
  • 遵循步骤1中的提交拆分指南
  • 对每个单元分别执行步骤2-6

Step 5: Generate Commit Message

步骤5:生成提交消息

PRE-CHECK: Ensure WBS number has been set in Step 0 (including "N/A" for no WBS). If not set at all, return to Step 0 for user selection.
  1. MUST read
    templates/commit-msg-template.md
    from skill directory
    • This file contains the commit message format, emoji mapping, and all template rules
    • No user notification, silent check
    • Follow the template structure and emoji mapping exactly as defined in the file
  2. Generate exactly 1 commit message (best candidate only)
  3. Do NOT run any git commands in this step

预检查: 确保步骤0已设置WBS编号(包括无WBS时的"N/A")。如果未设置,返回步骤0让用户选择。
  1. 必须读取技能目录中的
    templates/commit-msg-template.md
    • 该文件包含提交消息格式、表情符号映射及所有模板规则
    • 无需通知用户,静默检查
    • 严格遵循文件中定义的模板结构与表情符号映射
  2. 生成恰好1条提交消息(仅最佳候选)
  3. 此步骤不得运行任何Git命令

Step 6: Commit Execution

步骤6:提交执行

If trigger was "메시지만":
  • Display generated message and EXIT (skip commit execution)
Otherwise, present commit UI:
========================================
제안된 커밋 메시지:
========================================
[Display the generated commit message here]
========================================
1. 제안된 커밋 사용
2. 제안된 커밋 수정
3. 취소
========================================
선택 (1-3):
Handle user selection:
  • Option 1 (제안된 커밋 사용):
    • Check if files are staged:
      git diff --staged --name-only
    • IMPORTANT: Escape double quotes and special characters in commit message before executing git commit
    • If staged files exist → run
      git commit -m "..."
    • If nothing staged → list unstaged files, ask user which to add, then run
      git add <files>
      git commit -m "..."
  • Option 2 (제안된 커밋 수정):
    • Prompt: "수정할 내용을 입력해주세요 (전체 커밋 메시지 또는 수정 지시):"
    • Wait for user input
    • Apply modifications to commit message
    • Commit with modified message
  • Option 3 (취소):
    • Exit without committing

如果触发词是"메시지만":
  • 展示生成的消息并退出(跳过提交执行)
否则,展示提交界面:
========================================
제안된 커밋 메시지:
========================================
[在此处展示生成的提交消息]
========================================
1. 제안된 커밋 사용
2. 제안된 커밋 수정
3. 취소
========================================
선택 (1-3):
处理用户选择:
  • 选项1(제안된 커밋 사용):
    • 检查文件是否已暂存:
      git diff --staged --name-only
    • 重要提示: 在执行git commit前,转义提交消息中的双引号与特殊字符
    • 如果有暂存文件 → 运行
      git commit -m "..."
    • 如果无暂存文件 → 列出未暂存文件,询问用户要添加哪些,然后运行
      git add <文件>
      git commit -m "..."
  • 选项2(제안된 커밋 수정):
    • 提示:"수정할 내용을 입력해주세요 (전체 커밋 메시지 또는 수정 지시):"
    • 等待用户输入
    • 对提交消息应用修改
    • 使用修改后的消息提交
  • 选项3(취소):
    • 退出,不执行提交

Refinement Notes

优化说明

Why this design:
  1. WBS tracking: Company workflow requires linking commits to WBS tasks
  2. Automatic WBS suggestion: Reduces friction by suggesting recent WBS numbers
  3. Mandatory review: Prevents shipping debug code, secrets, or bugs
  4. Template flexibility: Projects can override with custom templates
  5. Interactive selection: Gives user control at each decision point
  6. "메시지만" mode: Useful for learning or preparing messages before committing
Tool usage patterns:
  • Silent execution for context gathering (git log)
  • Explicit user prompts for decisions (WBS selection, commit execution)
  • Structured output formats for consistency
Error handling:
  • Never proceed if review fails (unless user overrides)
  • Never invent WBS numbers
  • Always confirm before staging/committing files
设计原因:
  1. WBS追踪: 公司工作流要求将提交与WBS任务关联
  2. 自动WBS建议: 通过推荐最近的WBS编号减少操作摩擦
  3. 强制审查: 避免提交调试代码、密钥或Bug
  4. 模板灵活性: 项目可通过自定义模板覆盖默认设置
  5. 交互式选择: 在每个决策点给予用户控制权
  6. "메시지만"模式: 适合学习或在提交前准备消息
工具使用模式:
  • 静默执行上下文收集(git log)
  • 明确提示用户进行决策(WBS选择、提交执行)
  • 结构化输出格式确保一致性
错误处理:
  • 审查未通过时不得继续执行(除非用户覆盖)
  • 不得编造WBS编号
  • 暂存/提交文件前始终确认