Skip to content

Git ワークフロー

本ドキュメントは、TASHIKA の Git 運用ルールと開発ワークフローを定義する。

→ 満たす設計: 技術スタック


ブランチ戦略: GitHub Flow

main ブランチと短命な feature ブランチの2種類のみで運用する。

squash mergesquash mergesquash mergesquash mergemainfeature/domain-entitiesfeature/employee-portalmainfix/tax-calculation-boundarydocs/api-spec-updatemain
squash mergesquash mergesquash mergesquash mergemainfeature/domain-entitiesfeature/employee-portalmainfix/tax-calculation-boundarydocs/api-spec-updatemain

ルール

ルール詳細
main の状態常にデプロイ可能。壊れたコードをマージしない
ブランチの起点必ず main から作成
ブランチの寿命短命(数時間〜数日)。長期ブランチは作らない
マージ方式squash merge(feature 内の試行錯誤を1コミットに集約)
マージ後feature ブランチは削除
直接 pushtypo 修正など軽微な変更のみ main への直接 push 可

ブランチ命名規則

{type}/{slug} 形式。Conventional Commits のプレフィックスと統一する。

プレフィックス用途
feature/新機能feature/domain-entities
fix/バグ修正fix/tax-calculation-boundary
docs/ドキュメントdocs/api-spec-update
refactor/リファクタリングrefactor/clean-architecture-layers
test/テスト追加・修正test/property-tests-tax-calc
chore/設定・依存関係chore/update-dependencies

コミット規約: Conventional Commits

{type}: {簡潔な説明(英語)}
type用途
feat新機能
fixバグ修正
docsドキュメント変更
refactorリファクタリング(機能変更なし)
testテスト追加・修正
choreビルド・設定・依存関係

基本的な開発フロー

1. ブランチ作成 → 実装 → PR → マージ

bash
# 1. main から feature ブランチを作成
git switch -c feature/domain-entities main

# 2. 実装・コミット(こまめに)
git commit -m "feat: Add Declaration entity and value objects"
git commit -m "feat: Add DeclarationSnapshot JSONB mapping"

# 3. リモートに push
git push -u origin feature/domain-entities

# 4. PR 作成(gh CLI)
gh pr create --base main

# 5. セルフレビュー → squash merge → ブランチ削除
gh pr merge --squash --delete-branch

2. PR 作成前のチェック

bash
# コード品質チェック
/convention-check

# セキュリティ関連の変更がある場合
/security-review

# ドキュメント変更がある場合
/review-requirements
/check-ids

Claude Code worktree による並行作業

git switchclaude -w の使い分け

シナリオ方法
1つのタスクに集中して作業git switch -c feature/xxx
作業中に別タスクを並行して進めたいclaude -w
Claude に長時間タスクを任せて別作業claude -w

git switch の制約

git switch はワーキングディレクトリを切り替えるため、未コミットの変更があると切り替えられない。 stash やコミットが必要になり、コンテキストの切り替えコストが発生する。

claude -w の仕組み

claude -w <name> を実行すると:

  1. .claude/worktrees/<name>/ にリポジトリの独立したコピーを作成
  2. 専用ブランチ worktree-<name> を自動作成(main ベース)
  3. そのコピー上で Claude Code セッションを開始

各 worktree は独立したファイルとブランチを持つため、複数の Claude Code セッションが互いに干渉せず並行作業できる。

使い方

bash
# ターミナル1: メイン作業
claude -w feature/domain-entities
> エンティティを実装して

# ターミナル2: 割り込みタスク(別ターミナルから同時実行)
claude -w fix/tax-boundary
> 税計算の境界値バグを修正して

# それぞれ独立して PR → squash merge

ライフサイクル

  • 変更なし: セッション終了時に worktree とブランチが自動削除
  • 変更あり: 保持するか削除するか確認される
  • 手動確認: git worktree list で一覧表示

推奨方針

普段は git switch による逐次作業で十分。 claude -w は割り込みタスクが発生したときの手段として使う。

リポジトリ (main)ターミナル 1ターミナル 2PR → squash mergePR → squash mergemain ブランチclaude -w feature/domain-entities.claude/worktrees/feature/domain-entities/worktree-feature/domain-entities ブランチclaude -w fix/tax-boundary.claude/worktrees/fix/tax-boundary/worktree-fix/tax-boundary ブランチ
リポジトリ (main)ターミナル 1ターミナル 2PR → squash mergePR → squash mergemain ブランチclaude -w feature/domain-entities.claude/worktrees/feature/domain-entities/worktree-feature/domain-entities ブランチclaude -w fix/tax-boundary.claude/worktrees/fix/tax-boundary/worktree-fix/tax-boundary ブランチ

GitHub リポジトリ設定

設定理由
Automatically delete head branches有効マージ後のリモートブランチを自動削除。git fetch --prune でローカルも追従
許可するマージ方式squash merge のみmerge commit・rebase merge を無効化し、規約外のマージを防止
Squash merge commit titlePR titlePRタイトル(日本語)をそのままコミットタイトルに使用
Squash merge commit messagePR body個別コミット列挙ではなく、整理されたPR本文を使用
Allow update branch有効PR画面で main の最新変更をブランチに取り込むボタンを表示