Blog
Home

Ending a Claude Code session with /clear

23 November 2026 · 12 views

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

  1. List what the session made: branches, worktree, PRs, issues.
  2. Stop if anything is unfinished.
  3. Clean up only what is merged, with git branch -d, never a remote branch.
  4. Save what is worth remembering, but nothing the repo already records.
  5. 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.

Co-authored with Claude.

If this was useful, you can buy me a coffee.

New articles: follow via RSS.

Let's connect on LinkedIn.

Related articles

Comments

← All articlesView as Markdown