name: cleanup description: Use when cleaning up peers, sessions, tmux panes, processes, feature worktrees, branches, generated artifacts, or after a delegated lane or PR is complete.
Cleanup
Cleanup has three parts: mesh registration/session, terminal/process, and workspace artifacts. Treat them separately.
Before cleanup
Confirm the work is complete, merged or no longer needed, and no peer/reviewer still needs the workspace. Preserve dirty, unmerged, or unpushed user work unless the user explicitly asked for destructive cleanup.
Safe sequence
- Check git state in the relevant worktree:
git fetch origin git status --short git log @{u}..HEAD - Deregister the peer only when it is no longer needed.
- Verify terminal state separately:
tmux list-windows -t <circle> - Kill pane/window only after verifying it is disposable or the user asked.
- Remove feature worktree and branch only after merge/disposal is clear:
git worktree remove <feature-worktree-path> git worktree prune git branch -d <feature-branch> - Re-check mesh, tmux, and worktree state.
Anti-patterns
- Treating stale mesh rows as proof the terminal is dead.
- Killing terminals that may contain resumable state.
- Pruning worktrees before checking dirty/unpushed work.
- Cleaning up before review or verification is complete.