Goal
Show the current worktree situation and prevent accidental edits in the primary working directory.
Rules
- •Do not make code changes.
- •Do not commit, push, or open PRs.
- •Only inspect and report.
Steps
- •Confirm git repo
- •If not in a git repo, report that and stop.
- •Show worktrees
- •Run:
git worktree list - •Identify:
- •the primary worktree (usually the repo root)
- •any additional worktrees (candidates)
- •Determine the active / likely-active worktree
- •If
.worktrees/_active.jsonexists:- •Read and report
branch,base,path. - •Verify the path exists.
- •Mark this as Active (recorded).
- •Read and report
- •Else (no
_active.json):- •From
git worktree list, collect non-primary worktrees. - •If there are no additional worktrees:
- •Report: "No additional worktrees found."
- •Skip to Step 5.
- •If there is exactly one additional worktree:
- •Treat it as Likely active (only candidate).
- •If there are multiple additional worktrees:
- •Determine "most likely active" using this heuristic order (no filesystem changes):
- •Prefer a worktree whose path starts with
.worktrees/(repo-local convention). - •Among those, prefer one whose branch name matches common feature patterns:
- •
feat/*,feature/*,fix/*,bugfix/*,chore/*
- •
- •If still multiple, pick the one that appears last in
git worktree listoutput (often newest).
- •Prefer a worktree whose path starts with
- •Mark it as Likely active (heuristic).
- •Determine "most likely active" using this heuristic order (no filesystem changes):
- •For the chosen likely-active worktree, set:
- •
path= candidate path - •
branch= candidate branch
- •
- •From
- •Verify cleanliness (active or likely-active)
- •If an active/likely-active worktree path is known:
- •Run:
git -C <path> status --porcelain - •If non-empty: report "worktree is NOT clean" and show a short summary of modified/untracked.
- •If empty: report "worktree is clean".
- •Also report the branch:
git -C <path> rev-parse --abbrev-ref HEAD.
- •Run:
- •Guardrail reminder
- •If an active/likely-active worktree exists:
- •Explicitly state: "Do all feature edits inside: <path>."
- •If no active/likely-active worktree exists:
- •Suggest using
worktree-start-featureto create one for a new feature.
- •Suggest using
Output format
- •Worktrees: list (path + branch)
- •Active worktree: branch/path and whether it is recorded or heuristic
- •Cleanliness: clean / not clean (active/likely-active)
- •Reminder: where to work