Hooks reference changedhooks
Nearest release: v2.1.293, published 9 hours after upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 7 Oct 2026 07:24 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 7 Oct 2026 07:37 UTC.
Upstream edited
Recorded here
Lines+5added
Lines−6removed
From line
57
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits92to this page, all time
The whole hunk
from line 57, old and new numbered
/
from line 57
5757| `DirectoryAdded` | When a working directory is added mid-session via `/add-dir` or the SDK `register_repo_root` control request |
5858| `FileChanged` | When a watched file changes on disk. The `matcher` field specifies which filenames to watch |
5959| `WorktreeCreate` | When a worktree is being created via `--worktree`, `isolation: "worktree"`, or for a background session. Replaces default git behavior |
60| `WorktreeRemove` | When a worktree is being removed at session exit, when a subagent finishes, or when you delete a background session |
60| `WorktreeRemove` | When a worktree that a `WorktreeCreate` hook created is being removed |
6161| `PreCompact` | Before context compaction |
6262| `PostCompact` | After context compaction completes |
6363| `PreModelSwitch` | Before Claude Code applies a model switch that you or a client requested. Can block the switch |
from line 3026
30263026
30273027### WorktreeRemove
30283028
3029Runs when a worktree is being removed. This is the cleanup counterpart to [WorktreeCreate](#worktreecreate). The event fires when:
3029Runs when Claude Code cleans up a worktree that your [`WorktreeCreate`](#worktreecreate) hook created. The event fires when:
30303030
3031* you exit a `--worktree` session and choose to remove it
3032* a subagent with `isolation: "worktree"` finishes
3033* you delete a [background session](/docs/en/agent-view#what-deleting-a-session-removes) whose worktree the hook created
3031* You exit a `--worktree` session and choose to remove the worktree
3032* You delete a [background session](/docs/en/agent-view#what-deleting-a-session-removes) that runs in the worktree
30343033
30353034For git-based worktrees, Claude Code handles cleanup automatically with `git worktree remove`. If you configured a WorktreeCreate hook, pair it with a WorktreeRemove hook to control cleanup of the worktrees it creates:
30363035
No line in this hunk matches that.