mcpField
S
sc-worktree

sc-worktree

github.com/tony363エージェントワークフロー2091 回インストール30 週間前に更新
リポジトリ

sc-worktree について

並行したエージェント開発向けに、Git worktreeを独立した作業場所として管理するスキルです。作成、状態確認、変更の提案、削除を支援し、自動マージは行わず人によるレビューに委ねます。

主な機能

  1. 01独立したworktreeとブランチの作成
  2. 02状態確認と競合検出
  3. 03サブエージェントのworktreeへの割り当て
  4. 04人によるレビューに向けた変更提案
  5. 05古いworktreeの削除

活用シーン

  1. 01複数のエージェントで別々のタスクを並行実行
  2. 02プルリクエストレビュー用のブランチ準備
  3. 03直接コミットせずにパッチを作成

MCP 対応

提案前の検証、コードレビュー、競合対応の助言にはPAL MCPツールを利用できます。Rube MCPツールによるプルリクエスト作成やチーム通知も説明されています。

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/tony363/superclaude --skill sc-worktree

インストール後、Claude Code で/sc-worktreeを入力して読み込まれたか確認します。

詳細

Worktree 管理スキル

並行エージェント開発のための Git worktree 分離と、シンプルで安全なワークフローです。

クイックスタート

# Create isolated worktree for a task
/sc:worktree create feature-auth

# List all active worktrees
/sc:worktree list

# Propose changes for human review
/sc:worktree propose feature-auth

# Clean up stale worktrees
/sc:worktree cleanup

動作フロー

  1. 作成 - 一意の名前を付けて分離された worktree を初期化します
  2. 検証 - 事前チェックを行います(リポジトリがクリーンであること、競合がないこと)
  3. 割り当て - CWD を worktree に設定してサブエージェントを起動します
  4. 作業 - エージェントは分離環境で作業し、ブランチにコミットします
  5. 提案 - ブランチをプッシュし、人間によるレビュー用の PR を作成します
  6. クリーンアップ - マージ済みまたは古い worktree を削除します

コマンド

コマンド目的Git 操作
create <task-id>分離された worktree を作成git worktree add -b wt/<task>
listすべてのアクティブな worktree を表示git worktree list
status <task-id>worktree の状態を確認git status、git log
cleanup [--all]古い worktree を削除git worktree remove、prune
propose <task-id>人間によるレビュー用の PR を作成git push、gh pr create

フラグ

フラグ型デフォルト説明
--commitsbooltrueエージェントがブランチに直接コミットします
--patchesboolfalseエージェントはパッチファイルのみを生成します
--run-testsboolfalse提案前にテストを実行します
--forceboolfalse既存の worktree/ブランチを上書きします
--basestringmainworktree のベースブランチ

証拠要件

このスキルでは、厳密な証拠は必要ありません。worktree 操作は次の内容から自動的に記録されます。

  • Git worktree の一覧出力
  • ブランチの履歴
  • PR 作成の確認

命名規則

競合を防ぐため、worktree には決定的な命名規則を使用します。

Path:   .worktrees/<task-id>/
Branch: wt/<task-id>

例:

Path:   .worktrees/feature-auth/
Branch: wt/feature-auth

操作

Worktree の作成
/sc:worktree create feature-auth

# Executes:
# 1. mkdir -p .worktrees
# 2. git worktree add -b wt/feature-auth .worktrees/feature-auth
# 3. Returns worktree path for subagent CWD
Worktree の一覧表示
/sc:worktree list

# Shows:
# - Active worktrees
# - Associated branches
# - Last commit info
ステータスの確認
/sc:worktree status feature-auth

# Shows:
# - Uncommitted changes
# - Commits ahead of base branch
# - Conflict warnings
変更の提案
/sc:worktree propose feature-auth

# Executes:
# 1. git push -u origin wt/feature-auth
# 2. gh pr create --title "feat: feature-auth" --body "..."
# 3. Returns PR URL for human review
Worktree のクリーンアップ
/sc:worktree cleanup          # Remove merged worktrees
/sc:worktree cleanup --all    # Remove ALL worktrees
/sc:worktree cleanup feature-auth  # Remove specific worktree

# Executes:
# 1. git worktree remove .worktrees/<task-id>
# 2. git branch -d wt/<task-id>
# 3. git worktree prune

サブエージェントとの連携

worktree で作業するサブエージェントを起動する場合:

# 1. Create worktree
/sc:worktree create feature-auth

# 2. Spawn subagent with CWD
Task(
    prompt="Implement JWT authentication",
    subagent_type="general-purpose",
    # CWD implicitly set to .worktrees/feature-auth/
)

# 3. Agent works in isolation
# - All file operations scoped to worktree
# - Commits go to wt/feature-auth branch

# 4. Propose for review
/sc:worktree propose feature-auth

事前チェック

worktree を作成する前に、このスキルは次の項目を検証します。

  1. リポジトリの状態

    • リポジトリがクリーンであるか、--force フラグが指定されている
    • メインブランチが最新である
  2. ブランチの利用可否

    • wt/<task-id> ブランチが存在しないか、明示的に再利用する
    • 競合するリモートブランチがない
  3. パスの利用可否

    • .worktrees/<task-id> が存在しないか、--force フラグが指定されている

競合の検出

提案する前に、このスキルは競合を確認します。

# Fetch latest changes
git fetch origin main

# Check if worktree is behind
git merge-base --is-ancestor origin/main HEAD

# Warn but don't block if behind
# Human reviewer handles merge strategy

例

単一エージェントのワークフロー
# Create worktree
/sc:worktree create add-logging

# Work in worktree (agent operates here)
# ... agent makes changes, commits ...

# Propose changes
/sc:worktree propose add-logging

# Human reviews PR, merges

# Cleanup
/sc:worktree cleanup add-logging
複数エージェントの並行ワークフロー
# Orchestrator creates multiple worktrees
/sc:worktree create feature-auth
/sc:worktree create feature-logging
/sc:worktree create feature-metrics

# Spawn agents in parallel (each with own worktree)
# Agent A -> .worktrees/feature-auth/
# Agent B -> .worktrees/feature-logging/
# Agent C -> .worktrees/feature-metrics/

# Propose all changes
/sc:worktree propose feature-auth
/sc:worktree propose feature-logging
/sc:worktree propose feature-metrics

# Human reviews 3 PRs, merges sequentially

# Cleanup all
/sc:worktree cleanup --all
パッチモード(直接コミットしない場合)
/sc:worktree create refactor-api --patches

# Agent produces .patch files instead of commits
# Orchestrator reviews patches before applying

/sc:worktree propose refactor-api  # Creates PR from patches

MCP 連携

PAL MCP(検証とレビュー)
ツール使用するタイミング目的
mcp__pal__precommit提案前worktree 内の変更を検証
mcp__pal__codereview提案前worktree の変更をレビュー
mcp__pal__consensus競合の解決複数モデルによるマージ戦略
PAL の使用パターン
# Validate worktree changes before proposing
mcp__pal__precommit(
    path=".worktrees/feature-auth",
    step="Validating worktree changes",
    findings="Security, test coverage, completeness",
    compare_to="main"
)

# Review worktree branch
mcp__pal__codereview(
    review_type="full",
    step="Reviewing feature-auth worktree",
    relevant_files=[".worktrees/feature-auth/src/auth.py"]
)
Rube MCP(自動化と通知)
ツール使用するタイミング目的
mcp__rube__RUBE_SEARCH_TOOLSGitHub 連携PR ツールを検索
mcp__rube__RUBE_MULTI_EXECUTE_TOOL提案コマンドPR を作成し、チームに通知
Rube の使用パターン
# Create PR and notify team
mcp__rube__RUBE_MULTI_EXECUTE_TOOL(tools=[
    {"tool_slug": "GITHUB_CREATE_PULL_REQUEST", "arguments": {
        "repo": "myapp",
        "title": "feat: feature-auth from worktree",
        "body": "## Worktree: feature-auth\nCreated via /sc:worktree",
        "base": "main",
        "head": "wt/feature-auth"
    }},
    {"tool_slug": "SLACK_SEND_MESSAGE", "arguments": {
        "channel": "#pull-requests",
        "text": "New PR from worktree: wt/feature-auth"
    }}
])

フラグ(拡張)

フラグ型デフォルト説明
--pal-reviewboolfalse提案前に PAL codereview を使用
--create-prbooltrueRube 経由で GitHub PR を作成
--notifystring-Rube 経由で通知(slack、teams)
--draftboolfalseドラフト PR を作成

ツールの連携

  • Bash - Git worktree コマンド、ディレクトリ操作
  • Read - worktree のステータスとログを確認
  • Task - worktree の CWD を設定してサブエージェントを起動
  • PAL MCP - 提案前の検証、コードレビュー
  • Rube MCP - PR の作成、チームへの通知

安全性の保証

  1. 分離 - 各 worktree には個別の作業ディレクトリがあります
  2. 自動マージなし - すべてのマージで人間によるレビューが必要です
  3. 一意の命名 - 決定論的なパスにより衝突を防ぎます
  4. クラッシュセーフ - cleanup --all ですべての古い worktree を削除します
  5. 警告のみの競合 - 競合が発生しても警告するだけで、処理はブロックされません

制限事項

  • 品質の自動スコアリングには対応していません(CI/テストを使用してください)
  • リースの追跡には対応していません(代わりに定期的にクリーンアップします)
  • 高度な競合解決には対応していません(人間によるレビューが必要です)
  • main への自動マージには対応していません(PR ベースのワークフローです)

コメント