close-storylisted
Install: claude install-skill astropham1808/astro-agent-skills
# Close Story Worktree
Clean up a merged story in a strict order. Keep this skill limited to GitHub
merge verification and local Git cleanup.
## Required inputs
Resolve these before changing state:
- story ID;
- repository root;
- exact head branch;
- exact worktree path;
- PR URL or number;
- base branch.
Read the applicable `CLAUDE.md` (and `AGENTS.md` when the project keeps one for
Codex). Preserve unrelated worktrees and branches. Accept branch forms such as
`codex/AL-151`, `worktree-AL-161`, or `claude/AL-216`; never rewrite one naming
convention into another.
## Sequence
1. Inspect `git status --short --branch` and
`git worktree list --porcelain`.
2. Use `gh pr view` or the GitHub connector to confirm the exact PR has
`mergedAt` set and targets the expected base branch.
3. If the PR is open, draft, closed without merge, or ambiguous, stop. Return
the PR URL and leave the worktree and branch unchanged.
4. Require the story worktree to be clean. Never reset, clean, stash, or force
removal to make it appear clean.
5. Run `scripts/cleanup-merged-story.sh` without `--apply` to preview the exact
targets and safety checks.
6. Run the same command with `--apply` only when the user has placed cleanup in
scope. The script fetches the PR base, verifies the branch tip is an ancestor
of the updated base, removes the exact worktree without force, then uses
`git branch -d`.
7. Confirm the path no longer appears in `git worktree list --porcelain` and
t