本文へ移動
cccskills
無料GitHub で公開

git-worktree

Create, switch to, or delete a git worktree under ~/.worktrees/<path-key>/<branch>, then rebase the agent session onto that directory. Use when asked to make, enter, or remove a worktree for a branch, when work needs an isolated checkout, or when invoked as /git:worktree.

インストール方法を見る

含まれるファイル(2)

  • SKILL.md5.0 KB
  • agents/openai.yaml43 B

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Git Worktree

Announce at start: "Using git-worktree skill to <action> the worktree for <branch>."

Contract

This skill never re-derives worktree paths in prose. wt on PATH is the single agent-side implementation. Layout and constraint questions belong to the using-git-worktrees skill.

Actions

InvocationEffect
wt path <branch> [--allow-home]prints the path that would be used; mutates nothing
wt resolve <branch> [--allow-home]prints the registered worktree path, or exits 3
wt switch <branch> [--allow-home]resolve, else create; prints the path
wt create <branch> [--allow-home]create only; exits 4 if already registered
wt remove <branch> [--allow-home] [--force]git worktree remove + prune; never touches the branch
wt listone <path>\t<branch> line per worktree (agents cannot use wt's fzf picker)
wt verify <branch>just check with HOME remapped (implies --allow-home)

Session Rebase Protocol

The load-bearing part. Three parts, in this order:

A. Bind the worktree (always, immediately, no waiting)

Capture the path:

wt_path=$(wt switch "$branch" ${allow_home:+--allow-home})

From this point in the session:

  • every shell call passes the worktree as the working directory — git -C "$wt_path" …, or the bash tool's cwd parameter (omp resolves an absolute cwd outside the session directory fine; verified)
  • every file tool call (read/grep/glob/edit) uses absolute paths under $wt_path
  • every task subagent prompt states $wt_path and requires absolute paths under it. Subagents inherit the parent's cwd and the task tool has no cwd field, so a subagent given relative paths silently works in the wrong tree
  • the final report restates $wt_path verbatim, so the binding survives context compaction

B. Move the harness's own root (one line, user-run)

Detect the harness — order matters, omp sets both OMPCODE=1 and CLAUDECODE=1:

if [ -n "${OMPCODE:-}" ]; then harness=omp
elif [ -n "${CLAUDECODE:-}" ]; then harness=claude
else harness=other; fi

Then print exactly one line for the user to run:

HarnessLine to printTruth to state alongside it
omp/move <wt_path>a real cwd change that keeps this conversation, and reloads project-scoped settings/plugins/commands for the worktree. The agent cannot self-invoke slash commands, so the user runs it. Offer /add-dir <wt_path> instead when they want both roots live, and /dirs to inspect.
claude/add-dir <wt_path>Claude Code has no cwd-change command; this only grants access, so pwd stays put and part A remains the working mechanism
otheromp --cwd <wt_path>starts a fresh session rooted at the worktree; loses this conversation. --cwd also bypasses omp's ~→temp-dir auto-switch

Never suggest omp worktree/omp wt here: that CLI manages omp's own agent worktrees under ~/.omp/wt and has nothing to do with ~/.worktrees/.

C. Never block on B

Continue the task under part A whether or not the user runs the line. Do not use AskUserQuestion to wait for it.

Deleting

wt remove refuses in three cases; the skill explains each rather than reaching for --force:

  • the current session directory (or $PWD) is inside the target worktree → tell the user to /move out (omp) or work from another root first
  • the target is the repo's main worktree → never removable
  • the worktree has uncommitted changes → report git -C <path> status --porcelain=v1 and ask before re-running with --force

Branch deletion is out of scope and stays with git-cleanup / branch-finish. After a successful remove, print git -C <repo_root> branch -d <branch> as the follow-up the user may want, and do not run it.

Never

  • Never re-derive the worktree path in prose or with an ad-hoc sed/tr pipeline — call wt path.
  • Never create a dotfiles worktree without --allow-home.
  • Never treat a wt shell session as proof that live terminals picked up .config/zsh/** or .config/nushell/** (see using-git-worktrees).
  • Never git worktree add a path whose leaf differs from the branch name.
  • Never remove a worktree to "fix" a dirty tree.
  • Never invoke omp worktree / omp wt, and never describe them as related: they manage omp's own agent worktrees under ~/.omp/wt, not ~/.worktrees/.
  • Never hand a subagent a relative path and assume it lands in the worktree — subagents inherit the parent cwd.

Integration

Pairs with: using-git-worktrees (layout/constraints), branch-finish (post-merge cleanup), git-stack (already creates worktrees under the same convention).

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

2ndbrain

無料

Quick-save the last assistant response as a verbatim note in the 2ndBrain Obsidian vault (~/2ndBrain/quick-notes/<year>/). Use when the user asks to quick-save/save the last response to 2ndBrain, or invokes $2ndbrain or /skill:2ndbrain.

日本語の概要は準備中です。原文の説明を表示しています。

phatblat/dotfiles122026年10月11日 更新

Write commit messages under the agent-commits convention - a Conventional Commits fork with no chore catch-all, intent-only type tokens, facts in trailers, and legally-grounded AI provenance (Assisted-by, never Co-authored-by). Use when composing a commit in a repo whose commitlint.config.js extends agent-commits, when deciding between feat/fix/refactor/perf, or when recording AI participation.

日本語の概要は準備中です。原文の説明を表示しています。

phatblat/dotfiles122026年10月11日 更新

Coordinate multi-agent work through durable artifacts in git instead of chat. Use this whenever a task involves sending a message to another agent, agent mailboxes or handoffs, claiming work from a shared queue, notifying another agent or crew (OpenClaw, Grok Bot, Claude Code, Codex, Gas Town/Gas City workers) that work is ready, or whenever the user mentions the artifact bus, message bus, agent mail, beads mail, doorbells, or pings between agents — even if they don't say "bus" explicitly.

日本語の概要は準備中です。原文の説明を表示しています。

phatblat/dotfiles122026年10月11日 更新

aven

無料

Use aven to find tasks, update status, and leave durable handoff context.

日本語の概要は準備中です。原文の説明を表示しています。

phatblat/dotfiles122026年10月11日 更新

boris

無料

Claude Code workflow tips from Boris Cherny (creator of Claude Code) and the Claude Code team. Use when: setting up Claude Code, optimizing workflows, running parallel sessions, configuring CLAUDE.md, using skills/commands, subagents, hooks, MCP integrations, or learning best practices. Covers: git worktrees, plan mode, verification, permissions, Slack MCP, BigQuery, prompting tips, plugins, custom agents, sandboxing, keybindings, status lines, output styles, customization, /simplify for code quality, /batch for parallel code migrations, /loop for scheduled tasks, code review agents, /btw for mid-task questions, /effort max reasoning, remote control sessions, voice mode, setup scripts, session naming, /color, PostCompact hook, auto mode, /schedule cloud jobs, iMessage plugin, auto-memory, and auto-dream, mobile app, session teleporting, Cowork Dispatch, Chrome extension, Desktop app, /branch forking, --bare SDK startup, --add-dir multi-repo, --agent custom agents, /voice input.

日本語の概要は準備中です。原文の説明を表示しています。

phatblat/dotfiles122026年10月11日 更新

boris

無料

Codex workflow tips from Boris Cherny (creator of Codex) and the Codex team. Use when: setting up Codex, optimizing workflows, running parallel sessions, configuring AGENTS.md, using skills/commands, subagents, hooks, MCP integrations, or learning best practices. Covers: git worktrees, plan mode, verification, permissions, Slack MCP, BigQuery, prompting tips, plugins, custom agents, sandboxing, keybindings, status lines, output styles, customization, /simplify for code quality, /batch for parallel code migrations, /loop for scheduled tasks, code review agents, /btw for mid-task questions, /effort max reasoning, remote control sessions, voice mode, setup scripts, session naming, /color, PostCompact hook, auto mode, /schedule cloud jobs, iMessage plugin, auto-memory, and auto-dream, mobile app, session teleporting, Cowork Dispatch, Chrome extension, Desktop app, /branch forking, --bare SDK startup, --add-dir multi-repo, --agent custom agents, /voice input.

日本語の概要は準備中です。原文の説明を表示しています。

phatblat/dotfiles122026年10月11日 更新

phatblat のスキルをすべて見る

このスキルの問題を報告する