/git-github:create-worktree-and-branchfrom git-github
このスキルは、ユーザーが「worktreeを作成して」「branchを切って」のように、既存のbranchを汚さずにコード修正を始めたい場合に使用する
Ships in git-github. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
git rev-parse --is-inside-work-treeでリポジトリルートパスを取得する
falseでgit管理下でない場合は、その旨を伝えてここで終了する以下をもとにAskUserQuestionツールを呼び出してユーザに確認する
questions:
- question: ベースブランチ名を教えてください
header: ベースブランチ
multiSelect: false
options:
- label: develop
description: 開発時
- label: staging
description: バグ修正時
- question: 作業ブランチ名のprefixを教えてください
header: prefix
multiSelect: false
options:
- label: feature
description: 機能追加時
- label: bug
description: バグ修正時
- question: 作業ブランチ名のsuffixを教えてください
header: suffix
multiSelect: false
options:
- label: 1
description: GitHub Issue等の数値指定
- label: fix-username-validation
description: 修正内容の概要で指定
以下を確認し、いずれか既存の場合はその旨を伝えてここで終了する。ユーザーに断りなく別名を組み立てない
git rev-parse --verify --quiet refs/heads/<prefixのサフィックス>/<サフィックス>でbranchの重複を確認するgit worktree listで.claude/worktrees/<サフィックス>の重複を確認する.gitignoreの確認と追記リポジトリルート直下の.gitignoreに.claude/worktrees/が含まれるか確認する
.gitignore自体が存在しなければ新規作成するgit fetch origin <ベースブランチ名>
git worktree add --no-track -b <作業ブランチのプレフィックス>/<作業ブランチのサフィックス> .claude/worktrees/<作業ブランチのサフィックス> origin/<ベースブランチ名>
--no-trackは必須とする。開始点がリモート追跡ブランチの場合、branch.autoSetupMergeの既定動作により新規branchが自動的にそれを追跡し、本番ブランチへの誤pushにつながるため
EnterWorktreeにpath: <リポジトリルート>/.claude/worktrees/<作業ブランチのサフィックス>を渡し、セッションをそのworktreeへ切り替える
git worktree listの結果をもとに、作成したworktreeのパスとbranch名、ベースブランチ名を報告する
## 作成したworktreeおよびbranch情報
- worktreeパス: xxx
- branch名: xxx
.env等のgitignore対象ファイルは.worktreeincludeによる自動コピーの対象外であり、新しいworktreeへ引き継がれない
必要な場合に備え、ユーザー自身が手動で実行するためのcpコマンドを例として提示する
実行はしないこと
cp <リポジトリルート>/.env <リポジトリルート>/.claude/worktrees/<作業ブランチのサフィックス>/.env
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub flupinochan/metalmental-claude --plugin git-github4 skills in this plugin
Other plugins' skills for the same job