Skip to main content

df-stack-close

Use when Delong invokes /df-stack-close — verifies every PR in the current Graphite stack has merged, then deletes the stack's local branches and removes the worktree.

Informations de source

Dépôt
delfu/dotfiles
Dernière activité de la source
12 octobre 2026 à 17:10
Langue détectée de SKILL.md
anglais
Étoiles
0
Forks
0

Options d'installation

Le prompt qui vérifie d'abord la source est sélectionné par défaut. Vous pouvez passer à une commande directe ou télécharger une copie locale.

Vérifiez les fichiers source

Lisez SKILL.md et les fichiers associés affichés par SkillsMP avant de décider de l'installer.

Affichage de SKILL.md

SKILL.md
Instructions source · Aperçu en lecture seule
name
df-stack-close
description
Use when Delong invokes /df-stack-close — verifies every PR in the current Graphite stack has merged, then deletes the stack's local branches and removes the worktree.
user-invocable
true
argument-hint
["branch"]
# Close a finished stack (Delong) Final step after `/df-new` or `/df-stack-extend` → `/df-stack-submit` → review → merge. Confirm the whole stack is merged, then clean up locally. Nothing here touches GitHub: the repo squash-merges and auto-deletes merged branches, so the remote is already clean. **Deleting branches and worktrees is destructive.** Do every check first, show the plan, and wait for an explicit yes. ## Workflow ### 1. Find the stack ```bash MAIN_ROOT=$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)") WT=$(git rev-parse --show-toplevel) ``` Pick the top branch: - If `[branch]` was given, use it. - If the current branch is checked out, use that branch. - If HEAD is detached (normal after `/df-stack-submit` in extend mode), use `git branch --format='%(refname:short)' --points-at HEAD`. - If nothing is found, ask. Walk down to the trunk. Repeat `gt info --branch <b> --no-interactive`, reading its `Parent:` line, until the parent is `staging`. The branches visited form `STACK`, bottom to top. Also collect the branches stacked **on** this one (`gt log short --stack --no-interactive` from a stack branch), including `/df-stack-extend` work. Those belong to other work. Report them and never delete them. ### 2. Verify everything merged For each branch in `STACK`: ```bash gh pr view "$b" --json number,state,headRefOid,url,title ``` - All `MERGED` → continue. - Any `OPEN` (draft or not) → stop. List each one's state and URL. - Any `CLOSED` without merging → stop and ask. It may be abandoned on purpose, or a mistake. - No PR found → stop and ask. ### 3. Check nothing would be lost Stop and report on any of these: - **Unsaved work in the worktree.** Check `git -C "$WT" status --porcelain`. Gitignored files don't count: `.worktreesetup` mirrors them in from the main checkout. - **Local commits that never reached the PR.** For each branch, check whether `git rev-parse "$b"` equals `headRefOid`. If it doesn't, list the extra commits with `git log --oneline <headRefOid>.."$b"`. - **A stack branch checked out in another worktree.** Check `git worktree list --porcelain`. Skip that branch and name the worktree. - **Children found in step 1.** Deleting their merged parent is safe: Graphite moves them onto `staging`. If one is checked out in another worktree, Graphite won't restack it, so mention that `/df-stack-sync` needs to run there. ### 4. Confirm Show the plan and **wait for a yes**: - The merged PRs: number, title, URL. - The branches to delete. Include any `backup/<branch>` refs that `/df-stack-submit` left from splits. - The worktree to remove, and how it will be removed (see step 6). - Anything skipped, and why. ### 5. Delete the branches Free the branches first: `git -C "$WT" switch --detach`. Then work top to bottom: ```bash gt delete "$b" --force --no-interactive # local only; also clears Graphite metadata and the branch's git config git branch -D "backup/$b" 2>/dev/null || true ``` `--force` is required. Squash merges never make the branch an ancestor of `staging`, so Graphite and `git branch -d` treat it as unmerged. Step 2 already proved it merged. **Never pass `--close`**: it acts on GitHub. ### 6. Remove the worktree **Never remove the main checkout** (`$WT` = `$MAIN_ROOT`), and never remove a worktree other than `$WT`. - **The session is in a worktree the desktop app created** (the session started there): archive this session as the last action, using `archive_session` with `session_id: "self"` and reason `stack merged`. The app removes its worktree, and the conversation ends. So give the final summary *before* the call. - **The session moved into the worktree via EnterWorktree** (from `/df-new` or `/df-stack-extend`): call **ExitWorktree** with `action: "keep"`, then run `git -C "$MAIN_ROOT" worktree remove "$WT"`. - If `worktree remove` refuses, say why. Use `--force` only after Delong agrees. Finish with `git -C "$MAIN_ROOT" worktree prune`. ## Common Pitfalls - Don't use `gt sync -d` to clean up. It also deletes the branches of PRs closed without merging, in every stack. Delete this stack's branches explicitly, as above. - GitHub retargets child PRs to `staging` after a merge. Walk the stack with Graphite's `Parent:`, not the PRs' `baseRefName`. - Don't run `git stash` to "clean" the tree before checking. Unsaved work is a reason to stop, not something to tidy away.
Voir sur GitHub