JDS5 No-BS AI

Closing Claude Code sessions safely: 'remove from list' isn't always cosmetic

By Daniel S. · June 24, 2026

If your Claude Code session list — either the agent view in your terminal or the sidebar at claude.ai/code — gets cluttered, the obvious move is to clear out the ones you don't need. There's a real distinction worth knowing first: the two surfaces handle "remove from the list" differently, and on one of them a careless second keystroke deletes the git worktree Claude was working in.

This is what the Anthropic docs say, in one place, with the cleanup pattern that works for both.

Two surfaces, two cleanup models

There are two places where you accumulate "recent" Claude Code sessions, and they were designed with different assumptions about what should happen when you clear them.

Agent view (claude agents). The terminal-side dashboard for background sessions running on your machine. These sessions keep running without a terminal attached because a supervisor process owns them; detaching does not stop them. To remove a session from the list, you press Ctrl+X once to stop it, then Ctrl+X again within two seconds to delete the row. Deleting also removes the worktree Claude created for that session, "including any uncommitted changes in it" — the docs are explicit. The conversation transcript stays on disk and you can still recover it with claude --resume, but the working tree is gone.

Claude Code on the web. The cloud surface at claude.ai/code. Sessions persist even if you close your browser — they run on Anthropic-managed infrastructure, not your machine. The web sidebar has two distinct actions: Archive hides a session from the default list but doesn't stop it or touch its data; Delete "permanently removes the session and its data" and cannot be undone. There's no equivalent of the agent-view footgun here — the web UI doesn't bundle list-removal with workspace deletion.

The clean mental model: agent view's Ctrl+X Ctrl+X is destructive cleanup, web's archive is safe cleanup, and web's delete is destructive cleanup. Knowing which you're invoking before you invoke it is the entire skill.

The agent-view footgun, in one line

If Claude spawned its own worktree for a background session and that session has uncommitted work you care about, commit or push before the second Ctrl+X. The docs spell it out directly: "push or commit work you want to keep first."

A worktree you created yourself and dispatched the session into is left alone — only worktrees Claude created on your behalf get deleted. Same for transcripts: those live elsewhere and survive deletion. The thing at risk is purely the uncommitted state inside a Claude-created worktree.

If you're not sure whether you care, do the first Ctrl+X to stop the session, then attach to it (Enter on the row) and run git status inside before the second keystroke. Ten seconds; saves the regret.

The web sidebar in one line

Default to Archive, not Delete. Archived sessions are still there if you ever want them back, just not in the default view. Delete is for sessions you genuinely want gone forever — and "forever" is the operative word; the docs note it cannot be undone.

Two web-specific things worth knowing alongside that:

The safe cleanup pattern, both surfaces

For agent view:

  1. Ctrl+X once to stop the session.
  2. If Claude created a worktree and there's uncommitted work in it: attach, push or commit, detach.
  3. Ctrl+X again within two seconds to delete the row and the (now-empty) worktree.

For the web sidebar:

  1. Open the session if you're unsure whether it's still doing work; let it finish or end it explicitly.
  2. Archive if you might want it back. Delete only when "permanently and forever" is what you actually mean.

In both cases the principle is the same — stop the work first, then deal with the list — but the consequences of skipping that step differ. On the web, careless cleanup loses a transcript. In agent view, it can lose uncommitted code.

What persists either way

Worth knowing what does not disappear when you clean up:

So the list itself is cheap to maintain in either UI — as long as you know which keystroke or button does what before you press it.


Sources: Manage multiple agents with agent view (the Ctrl+X twice / worktree-deletion behavior is in the "Organize the list" section); Use Claude Code on the web (the Archive / Delete distinction is in the "Work with sessions" section). Verified 2026-06-24.