con un clic
session-cleanup
// End-of-session housekeeping for git repositories. Use when the user asks to 'end of session', 'clean up session', 'session housekeeping', 'clean up branches', 'clean up worktrees', or 'clean up remote branches'.
// End-of-session housekeeping for git repositories. Use when the user asks to 'end of session', 'clean up session', 'session housekeeping', 'clean up branches', 'clean up worktrees', or 'clean up remote branches'.
| name | Session Cleanup |
| description | End-of-session housekeeping for git repositories. Use when the user asks to 'end of session', 'clean up session', 'session housekeeping', 'clean up branches', 'clean up worktrees', or 'clean up remote branches'. |
| version | 1.2.1 |
Structured end-of-session housekeeping: doc review, branch audit, worktree removal, and remote sync.
Type: Guided Decision
Directive: ASK, THEN EXECUTE
Audits each category and presents findings before taking any destructive action. Deletions always follow an explicit audit phase.
This skill spawns a general-purpose subagent that performs git operations and file edits.
Foreground execution required: Yes
Required tools: Read, Write, Edit, Bash, Grep, Glob
Fallback: If tools are denied, the subagent returns a checklist of recommended actions for the coordinator to apply manually.
Invoke at the end of a working session:
/session-cleanup
Or trigger via phrases: "end of session", "clean up branches", "clean up worktrees", "session cleanup"
Out of scope: PR creation/merge (/ship), production deploys, Linear issue updates (/linear), resolving merge conflicts.
git worktree removeBefore launching the cleanup agent, run these two commands via Bash:
git status --porcelain
git branch --list | grep -v "^\* main$"
If both return empty (working tree clean AND only main branch exists locally), cleanup has almost certainly already run this session. Do NOT spawn the agent. Instead, tell the user:
"The repo looks clean already — only
main, nothing uncommitted. Cleanup appears to have already run this session. Run it again anyway?"
Only proceed to Dispatch if the user confirms, or if either check returns output (there is real work to do).
Use the Task tool with subagent_type="general-purpose" and pass the full contents
of ~/.claude/skills/session-cleanup/agent-prompt.md as the prompt.
git push origin --delete b1 b2 ... bN invocation instead of a per-branch loop. Eliminates O(N) pre-push hook runs and avoids partial-deletion state from mid-loop hook failures. (SMI-3710)