Claude-skill-registry-data sc-managing-worktrees
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry-data
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry-data "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/managing-worktrees" ~/.claude/skills/majiayu000-claude-skill-registry-data-sc-managing-worktrees && rm -rf "$T"
manifest:
data/managing-worktrees/SKILL.mdsource content
Managing Git Worktrees
Use this skill to manage worktrees with a standard structure and tracking. Use the
/sc-git-worktree command to invoke this skill.
Agent Delegation
This skill delegates to specialized agents via the Task tool:
| Operation | Agent | Returns |
|---|---|---|
| Create | | JSON: success, path, branch, tracking_row |
| Scan | | JSON: success, worktrees list, recommendations |
| Cleanup | | JSON: success, branch_deleted, tracking_update |
| Abort | | JSON: success, worktree_removed, tracking_update |
To invoke an agent, use the Task tool with:
- Prompt file:
.claude/agents/<agent-name>.md - Parameters as documented in each agent's Inputs section
Standards and paths
- Repo root: current directory.
- Default worktree base:
.../synaptic-canvas-worktrees - Worktrees live in
.<worktree_base>/<branch> - Tracking document (if used):
must be updated on create/scan/cleanup/abandon. Allow a toggle to disable tracking for repos that don’t use it.<worktree_base>/worktree-tracking.md - Naming: worktree directory = branch name; branch naming follows repo policy (e.g., master release; develop/DevBranch integration; feature from integration; hotfix from master; release branches as needed).
- Branch protections/hooks: no direct commits to protected branches; ensure hooks/branch protections are respected across worktrees.
- Cleanliness: worktrees must be removed and tracking updated when work is complete or branch is merged.
Workflows
Scaffolding (if missing)
- Ensure base path exists:
. If missing, create it.<worktree_base> - If tracking is enabled, ensure tracking doc exists with headers.
Create worktree (and branch)
- Inputs:
,--branch <name>
, optional--base <master|develop|...>
.--path - Ensure scaffolding/tracking doc exists (if enabled); fetch all:
.git fetch --all --prune - Confirm base branch exists and is up to date.
- Determine path: default
(or override).<worktree_base>/<branch> - Create branch/worktree:
- If branch does not yet exist:
.git worktree add -b <branch> <path> <base> - If branch exists:
.git worktree add <path> <branch>
- If branch does not yet exist:
- In the new worktree, ensure hooks apply and verify status is clean.
- If tracking enabled, add/refresh entry in tracking doc (branch, path, base, purpose, owner, created date, status).
- Agent option: delegate to
agent; it returns structured JSON (tracking row, status).sc-worktree-create
Scan/verify worktrees
- List worktrees:
.git worktree list --porcelain - Cross-check tracking doc (if enabled); flag missing/stale entries or extra rows.
- For each worktree, check status and merge state:
git -C <path> status --shortgit -C <path> fetch
to see if merged.git branch --remotes --contains <branch>
- Identify issues: untracked changes, diverged branches, merged-but-not-cleaned worktrees, missing tracking entries.
- Update tracking doc with current state and issues (if enabled); propose cleanup where appropriate.
- Agent option: delegate to
agent; it returns structured JSON.sc-worktree-scan
Clean-up worktree (post-merge or finished work)
- If
is not clean, stop and request explicit approval/coordination.git status - Ensure all work is committed/pushed or explicitly confirmed to discard.
- Confirm target branch merged or otherwise approved for removal.
- Remove worktree:
(usegit worktree remove <path>
only with approval).--force - If merged and no unique commits, delete the branch locally (
) and remotely (git branch -d <branch>
) by default; only skip if the user explicitly opts out. If the remote branch is already absent, continue without error. If not merged, only delete with explicit approval.git push origin --delete <branch> - If tracking enabled, update tracking doc to remove/mark cleaned with merge SHA/date.
- Agent option: delegate to
agent; it returns structured JSON.sc-worktree-cleanup
Abandon worktree (discard work)
- If
is not clean, stop and request explicit approval/coordination.git status - Confirm user approval to discard local changes and optionally delete the branch.
- Remove worktree:
(force only with approval).git worktree remove <path> - If instructed, delete the branch locally (
) and remotely (git branch -D <branch>
).git push origin --delete <branch> - If tracking enabled, update tracking doc to remove the entry and note abandonment.
- Agent option: delegate to
agent; it returns structured JSON.sc-worktree-abort
Safety and reminders
- Never delete branches or force-remove worktrees without explicit approval.
- Never clean/abandon a worktree with uncommitted changes unless explicitly approved.
- Keep tracking doc in sync on every operation when enabled.
- Respect branch protections and hooks; no direct commits to protected branches.
- Use background agents for long scans/cleanups; keep the main context focused on decisions and summaries.