ce-worktree
できること
新規または既存のブランチで、分離された作業場所を作り、メインのフォルダをそのままに保ちます。1つのリポジトリで複数の作業を並行して進める開発者向けです。
使う場面
- ✓新しい作業を始め、メインのチェックアウトから切り離しておきたいとき。
- ✓プルリクエストやコミットを、独自のフォルダでチェックアウトしたいとき。
- ✓ブランチがすでにほかの場所でチェックアウトされているとき。
スキルのリンク
https://github.com/EveryInc/compound-engineering-plugin/blob/main/skills/ce-worktree/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このフィーチャー用に別のワークスペースを作ってください。メインのフォルダには触れないでください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、作業がすでに分離されているかをまず確認し、組み込みのワークツリーツールまたは通常のgitを使って新しいワークスペースを作り、そのパスとブランチを報告します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Worktree Isolation
Ensure the current work happens in an isolated workspace, without disturbing the user's main checkout. Most coding harnesses now create a worktree by default at session start, so the common case is that isolation already exists.
Done when: the caller is working in an isolated tree — existing or newly created — and its path and branch have been reported, or a blocker has been reported instead.
Order of operations: detect existing isolation -> prefer a native worktree tool -> fall back to plain git. Never create a worktree the harness cannot see.
Two modes, set by the caller's need:
- New work (default). No ref named — create a fresh branch from a base (trunk). This is what
ce-workandce-code-reviewuse when the user picks the worktree option. - Isolate an existing ref. The caller names a PR head, branch, or commit — attach the worktree to that ref instead of creating a new branch. A branch can be checked out in only one worktree at a time. If the named ref is already checked out anywhere (most commonly as the primary checkout's current branch), do not create a second worktree — report that it is already checked out at
<path>and let the caller act (work there in place; or, only if a clean separate tree is essential, create a detached worktree at the same commit).
Step 0: Detect existing isolation
Compare the resolved absolute git dir against the resolved absolute common git dir. Git mixes absolute and relative forms depending on the current directory (from a subdirectory of a normal checkout, --git-dir comes back absolute while --git-common-dir may be relative), so a raw string compare yields a false "already isolated":
git rev-parse --absolute-git-dir # absolute git dir for this worktree
(cd "$(git rev-parse --git-common-dir)" && pwd -P) # absolute shared (common) git dir
Equal -> normal checkout; continue to Step 1.
Different -> a linked worktree or a submodule. Distinguish with git rev-parse --show-superproject-working-tree:
- Non-empty -> submodule; treat it as a normal checkout and continue to Step 1.
- Empty -> already isolated. Report the worktree path (
git rev-parse --show-toplevel) and current branch, then work in place — a worktree-from-worktree lands in the wrong tree and is invisible to the harness that made the current one. In isolate-an-existing-ref mode, check that ref out here (unless it is already current) rather than nesting a worktree.
Step 1: Prefer the harness's native worktree tool
If the harness provides a native worktree primitive — for example an EnterWorktree / WorktreeCreate tool, a /worktree command, or a --worktree flag — use it and stop. Native tools place, track, and clean up the worktree so the harness can manage it. A behind-the-back git worktree add creates phantom state the harness cannot see, navigate to, or clean up.
Step 2: Git fallback
Only when there is no native tool and Step 0 found no existing isolation.
- Run from the repo root:
cd "$(git rev-parse --show-toplevel)". The paths below are repo-root-relative, but the skill runs from the user's current directory — without this,.worktrees/<branch>and the.gitignoreedit land in a subdirectory (e.g.src/.worktrees/...). - Choose a meaningful branch name from the work description (e.g.
feat/login,fix/email-validation) — never an opaque auto-generated one. Base: origin's default branch, elsemain. - Ensure
.worktrees/is gitignored before creating anything:git check-ignore -q .worktrees/— with the trailing slash, so an existing directory-only.worktrees/rule is honored even before the directory exists (without the slash the probe misses it and dirties a correctly-configured repo). Not ignored -> add a.worktrees/line to.gitignore. - Refresh the base with
git fetch origin <from-branch>. This is non-fatal — nooriginremote, a differently-named remote, or a local-only branch is not an abort; continue with the local ref. - Create the worktree, per mode:
- New work:
git worktree add -b <branch-name> .worktrees/<branch-name> origin/<from-branch>(use the local<from-branch>ref iforigin/<from-branch>does not exist). - Existing branch or tag:
git worktree add .worktrees/<slug> <target-ref>. - PR: check it out on a local branch —
git fetch origin pull/<n>/head:pr-<n>then `
- New work:
よくある質問
メインのチェックアウトは変更されますか?
いいえ。メインのチェックアウトを乱さないように設計されています。
既存のプルリクエストのブランチに接続できますか?
はい。既存のブランチ、プルリクエスト、コミットにワークツリーを接続できます。
ブランチがすでに使用されている場合は?
どこにチェックアウトされているかを伝え、次にどうするかはあなたが決めます。
詳細
作者による元の説明
Set up isolated git worktrees — create a new branch for fresh work, or attach a worktree to an existing branch, PR, or commit. Use when starting isolated work or isolating an existing ref.
人気
- GitHubのスター
- 26k
- ランキング
- #10052
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
ce-babysit-pr
26kエージェントが、開いているGitHubのプルリクエストを、レビューのコメント、失敗したチェック、古くなったブランチを扱いながら、時間をかけてマージに向けて進められるよう支援します。
ce-bakeoff
26kエージェントが、ある問題に対して複数の競合する解決策を作り、それらを比べて、最も強い部分を組み合わせた推奨のアプローチにまとめられるよう支援します。
ce-brainstorm
26kエージェントが、作業を始める前に、短くガイドされた会話を通じて、漠然としたアイデアを明確で適切な大きさの要件に変えられるよう支援します。
ce-code-review
26kエージェントが、指定されたコードの変更やプルリクエストについて、バグ、回帰、テストの不足、基準の問題をレビューし、明確な指摘を報告できるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。