git-worktree-parallel
Skill1 starsChanged 7 months agoMITView on GitHub
git worktreeを使った並行実装。Agent Teamsと組み合わせてワーカーごとに独立作業ディレクトリを提供。 トリガー: "worktree", "ワークツリー", "並行ブランチ", "worktreeで分担", "ブランチ分離で開発", "worktree並列" 使用場面: (1) Agent Teamsワーカーに物理的に分離された作業環境を提供、 (2) 複数ブランチの同時作業、(3) ファイル競合をOSレベルで完全防止 関連スキル: agent-teams-coding
- Installs packages
- Commits and pushes
In this repository66 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- agent-teams-codingSkill
- AI External Brain (Knowledge Base)Skill
- awesome-design-md-jpSkill
- awesome-design-mdSkill
- softbank-invoiceSkill
- claude-for-chromeSkill
- codebase-patrolSkill
- codex-autopilotSkill
- codexSkill
- Context7 Documentation LookupSkill
- design-review-checklistSkill
- detail-design-docSkill
- discord-promotionSkill
- drawioSkill
- e2e-testSkill
- fish-audio-apiSkill
- fish-audio-docsSkill
- fish-audioSkill
- fortress-implementSkill
- fortress-reviewSkill
- freee Developer APISkill
- frontend-skillSkill
- gBizINFO APISkill
- github-cliSkill
- google-sheets-apiSkill
- google-sheets-mcpSkill
- graphify-windowsSkill
- issue-autopilot-batchSkill
- issue-flowSkill
- issue-plannerSkill
- Jグランツ APISkill
- Knip - Dead Code DetectionSkill
- liftkitSkill
- llm-vulnerability-testSkill
- MarkItDownSkill
- mba-strategy-consultantSkill
- Obsidian CLI OperationsSkill
- openrouterSkill
- PAY.JP CLI OperationsSkill
- playwright-cliSkill
- playwrightSkill
- qwen-coderSkill
- ryokan-forecastSkill
- security-adversarialSkill
- security-settingsSkill
- skill-improveSkill
- stoic-daily-practiceSkill
- Stripe CLI OperationsSkill
- Stripe PayPay決済Skill
- Supabase CLI OperationsSkill
- tile-terminalsSkill
- timesfmSkill
- ui-ux-pro-maxSkill
- usacon-account-mgmtSkill
- usacon-cliSkill
- usacon-discordSkill
- usacon-partner-registrationSkill
- usaconSkill
- ux-psychologySkill
- The first 60 shown.
The file
Files
git worktree 並行実装スキル
概要
git worktree を使い、1つのリポジトリから複数の作業ディレクトリ(worktree)を作成して並行開発を行う。
Agent Teams スキル(/agent-teams-coding)と組み合わせることで、ファイル競合をOSレベルで完全に防止する。
リポジトリ(メイン)
C:\project\my-app\ ← メイン worktree(ベースブランチ)
│
├── .git\ ← 全 worktree で共有(実体はここだけ)
│
├─ worktrees/
│ ├── wt-api\ → C:\project\wt-api\ ← Worker A(feature/api ブランチ)
│ └── wt-ui\ → C:\project\wt-ui\ ← Worker B(feature/ui ブランチ)
│
│ ┌──────────────────────────────────────────────────┐
│ │ 各 worktree は完全に独立したディレクトリ │
│ │ → 同じファイルを同時編集しても物理的に競合しない │
│ │ → .git は共有なので git 操作は相互に見える │
│ └──────────────────────────────────────────────────┘
│
└── 最終的にベースブランチへ順次マージ核心ルール
- 1ワーカー = 1 worktree = 1ブランチ = 1ディレクトリ
- worktree作成前にベースブランチを最新化:
git checkout $baseBranch && git pull origin $baseBranch - メイン worktree は常にクリーン: マージ先の汚染を防ぐ
- マージ順序は固定: 基盤層(DB/スキーマ)→ 共有層(型/API)→ 表示層(UI)
- primary_scope 外の変更は最小限: マージ競合を予防
- staging → main は --merge を使用: --squash はコード重複リスクあり
- worktree削除は
git worktree removeを使用: 手動削除するとゴミが残る - 各 worktree で npm install を実行: メインだけでは不足
- コミット&プッシュ後に TeamDelete: 未コミット変更が消失するのを防止
- Windows MAX_PATH 対策: パスを短く保つ(
C:\wt\api等)、core.longpaths true
agent-teams スキルとの関係
| アプローチ | 競合防止の仕組み | 強度 | 適用場面 |
| agent-teams のみ | ファイル所有権ルール(ソフト制約) | 中 | 担当を明確に分離できる場合 |
| worktree + agent-teams | 物理ディレクトリ分離(ハード制約) | 高 | 大規模変更、安全重視の場合 |
| worktree のみ | ディレクトリ分離のみ | 中 | 少人数で担当範囲が明確な場合 |
推奨: Agent Teams を使う場合は worktree + agent-teams の併用 が最も安全。
クイックスタート
1. worktree の作成
# メインリポジトリでベースブランチを最新化
Set-Location "C:\project\my-app"
git checkout staging # ベースブランチ(main / staging / develop)
git pull origin staging
# worktree 作成
git worktree add ../wt-api -b feature/api
git worktree add ../wt-ui -b feature/ui
git worktree add ../wt-db -b feature/db
# 確認
git worktree list2. 各 worktree で依存インストール
Set-Location "C:\project\wt-api"; npm install
Set-Location "C:\project\wt-ui"; npm install
Set-Location "C:\project\wt-db"; npm install3. 順次マージ(作業完了後)
Set-Location "C:\project\my-app"
git checkout staging
git merge feature/db --no-ff -m "Merge feature/db: DB層実装"
git merge feature/api --no-ff -m "Merge feature/api: API実装"
git merge feature/ui --no-ff -m "Merge feature/ui: UI実装"
git push origin staging4. クリーンアップ
git worktree remove ../wt-api
git worktree remove ../wt-ui
git worktree remove ../wt-db
git worktree pruneベースブランチ戦略(概要)
| ブランチモデル | ベースブランチ | マージ先 | 本番反映 |
| シンプル(main のみ) | main | main | マージで即反映 |
| staging 経由(推奨) | staging | staging | staging → E2E → main |
| develop 経由 | develop | develop | develop → staging → main |
重要: staging 経由の場合、worktree ブランチは staging にマージする。main に直接マージしない。
6フェーズ実行チェックリスト
Phase 1: 準備 → ベースブランチ決定・最新化・worktree作成・npm install
Phase 2: 並行作業 → TeamCreate・ワーカースポーン・実装
Phase 3: 統合 → dry-run → 順次マージ → 型チェック+テスト
Phase 4: プレビュー検証 → デプロイ待機 → E2Eテスト
Phase 5: 本番リリース → staging→main PR → マージ → 本番確認
Phase 6: クリーンアップ → worktree削除 → ブランチ削除 → TeamDelete詳細リファレンス
references/agent-teams-integration.md
- worktree-per-worker モデル(基本原則、なぜ worktree が最適か)
- Agent Teams 連携の実行フロー(Step 0〜Step 5 補足)
- worktree 一括作成スクリプト(PowerShell)
- worktree 所有権契約テンプレート(YAML)
- ワーカースポーン時のプロンプト例
- git worktree コマンドリファレンス(作成・一覧・削除・ロック)
- worktree クリーンアップスクリプト
- 完全実行フローチェックリスト(6フェーズ詳細)
- Windows 環境での注意事項(MAX_PATH、ロックファイル、node_modules等)
- アンチパターン一覧(12項目)
- トラブルシューティング
references/merge-strategy.md
- 順次マージ戦略(推奨手順、マージ順序の原則)
- staging → E2E → main フロー
- staging → main マージの注意点(--merge 推奨)
- マージ競合が発生しやすいファイルと対策一覧
- 競合解決 PowerShell ヘルパー(Resolve-MergeConflicts、Resolve-LockfileConflict)
- マージ前 dry-run チェック(Test-MergeDryRun)
references/base-branch-strategy.md
- 前提条件(gitバージョン、リポジトリ要件)
- EnterWorktreeツール使用時の必須手順
- 危険なパターン(古いベースからのworktree作成)
- ベースブランチ戦略(シンプル / staging経由 / develop経由)
- staging 経由フロー(Vercel + プレビュー環境)
関連スキル
/agent-teams-coding: Agent Teamsの並列コーディングオーケストレーション。worktree と併用推奨/github-cli: PR作成・マージのワークフロー。worktree ブランチのPR管理に使用/usacon: staging 経由フローの実例。$baseBranch = "staging"で使用
トラブルシューティング
| 問題 | 対処法 |
| worktree作成失敗(ブランチ既存) | git branch -D <branch> で既存ブランチを削除してから再作成 |
| .git/HEAD DENY ACL | 他のAIエージェントが並列作業中。完了を待つかHEAD変更不要な操作に限定 |
| worktreeディレクトリが残る | git worktree prune でorphanedエントリを削除 |
| node_modules不足 | worktree内で npm install を実行(親リポジトリとは独立) |
worktreeチェックリスト
- ベースブランチが最新か(
git pull済み) - worktreeパスが既存ディレクトリと重複していないか
- 作業完了後にworktreeを削除したか(
git worktree remove)
改訂履歴
| 日付 | 変更内容 | 変更理由 |
| 2025-12 | 初版作成 | git worktree並行実装パターンの標準化 |
| 2026-03-18 | トラブルシューティング・改訂履歴・チェックリスト追加 | skill-improve audit対応 |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

