AgentSkillsCN

commit-branch-rule

当用户请求创建分支、提交或合并(例如:创建分支、提交、合并)时,或询问如何撰写提交信息时,强制执行此仓库的 Git 工作流。从 main 分支开始,围绕 task/<topic> 展开工作,仅按照既定的提交信息格式提交所要求的文件,然后合并回 main 分支。

SKILL.md
--- frontmatter
name: commit-branch-rule
description: >-
  Enforce this repository's git workflow when the user asks to create a branch,
  commit, or merge (for example: ブランチ切って, コミットして, マージして), or
  asks how to write commit messages. Start from main, work on
  task/<topic>, commit only requested files with the defined message format,
  and merge back into main.

Goal

main から作業ブランチを切り、依頼範囲だけをコミットし、main へマージする。

Mandatory Behavior

  • コミット依頼を受けたら git status --short --branch で変更一覧を確認する。
  • 「コミットして」の依頼では、特に停止条件の指定がない限り main へのマージまで実行する。
  • 依頼範囲外の変更をコミットに含めない。
  • コミット後にコミットID、コミットメッセージ、対象ファイルを報告する。

Standard Workflow

  1. main を最新化する。
    git checkout main && git pull --ff-only origin main
  2. main から作業ブランチを作成する。
    git checkout -b task/<topic>
  3. 作業ブランチで変更をコミットする。
    git add <files> && git commit -m "<message>"
  4. 作業ブランチを main にマージする。
    git checkout main && git merge --no-ff task/<topic>

Commit Message Rule

  • 形式は <type>: <summary> とする。
  • typefeat, fix, refactor, docs, chore のいずれかを使う。
  • summary は英語で簡潔に書き、50文字前後を目安にする。
  • 1コミット1目的にし、メッセージはその目的だけを表す。

Rules

  • main へ直接コミットしない。
  • マージ前に git status がクリーンであることを確認する。
  • 競合がある場合は作業ブランチで解消してからマージする。

Output Style

  • 実行したコマンドの流れを短く報告する。
  • 実行後の git status --short --branch の要点を報告する。