/empire-git:worktree-open [branch | task description] [--base <branch>]from empire-git
Creates or reopens git worktrees for parallel development. Derives branch names from task descriptions and guides launching agent sessions in isolated environments.
Ships in empire-git. 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.
Read when SKILL.md points to them; scripts run unread.
Create or reopen a git worktree for parallel development, then guide the user to launch an agent session in it.
User input: $ARGUMENTS
Determine what the user wants from $ARGUMENTS:
| Input pattern | Action |
|---|---|
| Empty (no arguments) | Ask the user what they want to work on |
Looks like a branch name (contains /, or starts with feat/, fix/, chore/, refactor/, docs/, ci/, test/) | Use as the branch name directly |
| Natural language (a task description like "add auth to the API") | Derive a branch name (see below) |
Generate a branch name following this convention:
<type>/<1-4-word-slug>feat, fix, refactor, chore, docs, ci, test — infer from the descriptionfeat/auth-api-refactor, fix/login-timeout, chore/upgrade-depsDo not ask the user to confirm the branch name, just use it and proceed immediately.
If the user specified --base <branch> in their arguments, use that.
Otherwise, default base = the current branch. If the current branch matches ^(feat|fix|refactor|chore|docs|ci|test)/, ask the user via AskUserQuestion:
question: "Branch from current `<current-branch>` or from the default branch?"
header: "Base branch"
options:
- label: "Current (`<current-branch>`)"
description: "Stack this work on top of an existing feature branch"
- label: "Default (`main` or repo default)"
description: "Independent branch off the repo's default branch"
Resolve the repo's default branch via git symbolic-ref --short refs/remotes/origin/HEAD | sed 's|^origin/||'. If that fails, fall back to main, then master.
Run:
git worktree list --porcelain
Derive the expected worktree directory:
REPO_ROOT="$(git rev-parse --show-toplevel)"
SAFE_BRANCH="$(echo "<branch-name>" | tr '/' '-')"
BRANCH_HASH="$(printf '%s' "<branch-name>" | cksum | awk '{printf "%08x", $1}')"
WORKTREE_DIR="${REPO_ROOT}/.claude/worktrees/${SAFE_BRANCH}-${BRANCH_HASH}"
If the worktree directory exists and is valid (has a .git file):
--reopen flag (Step 4).If the branch exists but has no worktree:
If neither exists:
The setup script ships with this skill. On Claude Code it is at ${CLAUDE_PLUGIN_ROOT}/scripts/worktree-setup.sh; on other agents (e.g. Codex) it is scripts/worktree-setup.sh inside this skill's directory. Substitute the right path in the commands below.
New worktree:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-setup.sh" "<branch-name>" --base "<base-branch>"
Reopen existing worktree:
bash "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-setup.sh" "<branch-name>" --reopen
The script auto-detects the package manager from lockfiles (pnpm, npm, yarn, bun, uv, poetry, pipenv, bundler, cargo, go modules) and runs the matching install command. No per-repo configuration is required.
After the setup script succeeds, record the worktree in the per-session registry so external tooling can discover it (same path convention as Step 4: ${CLAUDE_PLUGIN_ROOT}/scripts/worktree-registry.sh on Claude Code, scripts/worktree-registry.sh on other agents):
bash "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-registry.sh" add \
"<branch-name>" \
"<worktree-path>" \
--base "<base-branch>" \
--repo-root "<repo-root>"
The registry lives at ~/.claude/sessions/<session-id>/active-worktrees.json (session id from $CLAUDE_CODE_SESSION_ID or $AGENT_SESSION_ID). Re-opening an existing worktree refreshes its opened_at without duplicating the entry.
If the registry call fails (e.g., jq missing), print a warning and continue — the worktree itself is still usable.
After the setup script completes, print:
Worktree ready!
Branch: <branch-name>
Path: <worktree-path>
Status: new | reopened
To start working in this worktree, navigate to it and launch your agent session or open in VSCode:
cd <worktree-path>
claude # or `codex`, etc. — start your agent in this worktree
code . # Opens the worktree in a new VSCode window
This skill is deterministic — the same branch name always produces the same worktree path and ports, so the user can bookmark URLs and expect consistency. It's also idempotent — running it twice with the same branch reopens rather than duplicates, which means the user never has to worry about accidentally creating a mess.
Git only allows a branch to be checked out in one worktree at a time, so the setup script will refuse if the branch is already in use elsewhere. If that happens, surface the error clearly so the user knows which worktree has it.
If the setup script fails partway through, just report what happened. Don't try to auto-clean — partial state is easier for the user to inspect and fix (via /empire-git:worktree-close) than state that was silently deleted.
What SKILL.md sets; muted values are Claude Code's defaults
sonnetThree short reads, in order
Other plugins' skills for the same job
npx claudepluginhub marcoskichel/empire --plugin empire-git12 skills in this plugin
/activity-reportGenerate a concise activity report of the user's GitHub work over a period, grouped by area or feature instead of PR by PR. Use when user says "activity report", "weekly report", "what did I do this week", "what did I ship", "work summary", "summarize my week", "status update for my manager", "what did <user> ship", or `/empire-git:activity-report [start-date] [end-date] [author]`.
/pr-comment-replyRender the canonical reply text for a PR review comment. Use when drafting, writing, or posting a "PR comment reply", "review comment reply", "reply to this comment", "respond to this review comment", "answer the reviewer", "reply on the PR thread", or any text bound for `gh api` review-thread replies, `gh pr comment`, or a GitHub review comment box. Triggers on "reply to the comment", "answer this review comment", "respond to the reviewer", "draft a reply", "post a reply on the PR". Outputs plain text for the caller to post unchanged.
/pr-descriptionRender the canonical PR description body. Use when drafting, writing, updating, or regenerating a "PR description", "PR body", "pull request description", "pull request body", "PR summary", "PR template", "GitHub PR body", or any text bound for `gh pr create --body`, `gh pr create --body-file`, `gh pr edit --body`, `gh pr edit --body-file`, or a GitHub PR template. Triggers on "draft a PR", "write the PR", "summarize this branch for review", "regenerate PR body". MUST be invoked before any `gh pr create --body*` or `gh pr edit --body*` per empire-git rules. Outputs markdown for stdin.
/pr-mergeGate then merge a single pull request safely. Use when the user says "merge this PR", "merge the PR", "land this", "ship this PR", "merge when green". Verifies CI is green (investigates and attempts a fix when red), rebases and resolves conflicts when the branch is behind, triages unresolved review threads intelligently (resolve, fix, or ask — never blindly block), then merges and deletes the branch. Fast-forwards the local base checkout (e.g. updates `master`) when it is checked out.
/pr-merge-stackMerge an entire stack of dependent PRs bottom-up: merge the base PR, pull the base branch, rebase the next PR onto it, wait for CI, merge, repeat until the stack is empty. Use when the user says "merge the stack", "merge pr stack", "land the stack", "merge all these PRs", "merge the chain", "ship the whole stack", or names several stacked PRs to merge in order. Infers the stack from conversation; asks when it can't. Offers admin merge (skip review requirements) up front — CI must still pass either way.
/pr-review-postPost a GitHub PR review (verdict + inline comments) in one API call. Use when posting, submitting, or publishing a "PR review", "code review", "review with inline comments", "approve the PR", "request changes", or any payload bound for `gh api repos/*/pulls/*/reviews`. Triggers on "post the review", "submit the review", "publish the review comments", "approve this PR", "request changes on the PR", "leave a review". MUST be used for any review POST so comments and verdict land atomically. Never posts without the caller's confirmed verdict.