name: git-flow description: Skill for the full git lifecycle in this repo, from init through branch, worktree, PR, and cleanup.
Git Flow
このリポジトリにおける git 運用の方針を定める。main ブランチでは直接作業せず、すべての変更を作業ブランチと worktree 上で進め、Pull Request 経由で統合する。これにより、レビューを必ず通し、履歴を機能・修正単位で残し、問題発生時に特定コミットへ戻せる状態を保つ。
ライフサイクルは Initialization・Start・Integration・Cleanup の4フェーズからなる。全体像を以下に示す。
flowchart LR
init[Initialization] --> start[Start]
start --> integrate[Integration]
integrate --> cleanup[Cleanup]
cleanup --> start
Initialization
新規リポジトリを立ち上げるフェーズである。デフォルトブランチを main としたパブリックリポジトリを作成し、空コミットで履歴の起点を確立する。master は使わない。
git init -b main
git commit --allow-empty -m "Initial commit"
Start
作業を開始するフェーズである。命名規則に従ったブランチを、ベースブランチの最新コミットから worktree として切り出す。worktree を独立させることで、ブランチを切り替えずに並行作業や緊急対応へ移れる。
ブランチ名は <type>/<description> 形式とする。<type> は変更の種類を表し、以下から選ぶ。
| type | 用途 |
|---|---|
| feat | 新機能の追加 |
| fix | バグ修正 |
| chore | コードに直接関係しない変更(ビルド・ツールなど) |
| docs | ドキュメントの変更 |
| refactor | 挙動を変えないコードの整理 |
| test | テストの追加・修正 |
<description> は変更内容が一言で伝わる kebab-case の英語動詞句とし、2〜5 語に収める。人名・連番・日付・ tmp ・ wip のような意味を持たない語は避ける。
| 評価 | 例 |
|---|---|
| 良い | feat/add-search-filter , fix/login-redirect-loop |
| 悪い | feature1 , tmp , yuji-branch , 20260509 |
worktree はベースブランチ(既定 origin/main )の最新を起点に、リポジトリ配下の .worktrees/ へ配置する。ディレクトリ名はブランチ名の / を - に変換した文字列とし、同名の worktree が既にあれば再利用する。
git fetch origin <base>
git worktree add -b <type>/<description> .worktrees/<dir> origin/<base>
Integration
変更を Pull Request としてリモートへ統合するフェーズである。作業ブランチを push して PR を作成し、レビュー承認を経てからマージする。
PR は独断でマージしない。必ずレビューを依頼し、承認を得てからマージする。履歴を機能・修正単位の 1 コミットへ集約するため、マージ方式は squash に固定する。同一ブランチの PR が既に open であれば、新規に作らず追記 push に留める。
git push -u origin <type>/<description>
gh pr create --fill
gh pr merge --squash
Cleanup
マージ後に環境を整えるフェーズである。残骸を残さないよう、ブランチと worktree を削除し、関連する GitHub Issue をクローズする。
git worktree remove .worktrees/<dir>
git branch -d <type>/<description>
git push origin --delete <type>/<description>
gh issue close <number> --reason completed