Best practices for Claude Code changedbest-practices
Upstream edited this page at 29 Nov 2026 00:00 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 29 Nov 2026 00:07 UTC.
Upstream edited
Recorded here
Lines+1added
Lines−1removed
From line
591
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits44to this page, all time
The whole hunk
from line 591, old and new numbered
/
from line 591
591591
592592You rarely have to clean any of this up yourself:
593593
594* When you exit an unnamed worktree session, Claude Code [removes a worktree it created with git](https://code.claude.com/docs/en/worktrees.md#clean-up-worktrees) if there's nothing in it. For a named session, or one with changes, it asks what to do.
594* When you exit an unnamed worktree session, Claude Code [can remove a worktree it created with git](https://code.claude.com/docs/en/worktrees.md#clean-up-worktrees) if `git status` is clean and there are no new commits. Otherwise, or if you named the session with [`-n` or `/rename`](https://code.claude.com/docs/en/sessions#name-your-sessions), Claude Code asks first.
595595* Subagent and background-session worktrees that get left behind [can be removed automatically](https://code.claude.com/docs/en/worktrees.md#clean-up-subagent-and-background-session-worktrees) once they're older than `cleanupPeriodDays` and hold no work.
596596
597597> [!NOTE]
No line in this hunk matches that.