I always announced the clear: "I will clear." That gave Claude the chance to finish up before the context goes away.
Then I noticed I was repeating the same requests every time: clean up the worktree, delete the local branches the session created. So I put it all in one skill, /pre-clear. Now I type it when I'm finished, and only then /clear.
What I get from it
- Claude saves what matters to memory: the decisions, my corrections, and the state of the work. The next session starts blank, but it finds what it needs. I almost never have to go back to an old session.
- A clean workspace: merged branches and the session's worktree are removed, so nothing piles up.
- A last check before I clear: Claude warns me if a PR is still unmerged, work isn't pushed, or a question is still waiting for my answer. It tells me instead of deleting anything.
The steps, in the same order every time
- List what the session made: branches, worktree, PRs, issues.
- Stop if anything is unfinished.
- Clean up only what is merged, with
git branch -d, never a remote branch. - Save what is worth remembering, but nothing the repo already records.
- End with a handoff: what is done, what is open, what was not verified.
After a /clear unpushed work stays on disk only until the worktree is removed. A cloud session's machine can be deleted. The skill checks both first.
Its first run stopped on an open PR and deleted nothing. After I merged, it finished the job.