{"version":"2.1.300","anchor":"worktree-creation-plugin-worktreecreate-hooks-registered-fi","canonical_anchor":"worktree-creation-plugin-worktreecreate-hooks-registered-fi","heading":"Plugin WorktreeCreate hooks now run when --worktree creates a worktree","tier":"notice","area":"Worktrees","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.300\/e\/worktree-creation-plugin-worktreecreate-hooks-registered-fi","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.300","markdown":"### Plugin WorktreeCreate hooks now run when --worktree creates a worktree\n\nWith --worktree, Claude Code now registers plugin worktree hooks before creating the worktree, and setup gains PR forge and resume options\n\n**Unclear.** How a reader asks Claude Code to reuse an existing worktree as it is is not stated.\n\n**What**\n\n`--worktree` starts Claude Code in a separate working copy of your project, called a worktree. Plugins can supply a hook for this. A hook is a small program that runs when a certain event happens, and the `WorktreeCreate` hook runs when a worktree is being created, replacing the default git behaviour.\n\nBefore this release, Claude Code did not register plugin worktree hooks before creating the worktree at startup, so a plugin's `WorktreeCreate` hook did not run. Startup now registers them first. Other changes in the same part of startup:\n\n- If registering the plugin hooks fails, Claude Code logs a warning saying the plugin's `WorktreeCreate` hook will not run.\n\n- Worktree setup now takes a pull request as a number plus a forge, meaning the hosting service the pull request lives on. Before, it took a bare number.\n\n- Setup takes a new `resumeAsIs` option, connected to cloud attach.\n\n- Setup takes a new final option that is on by default and controls one further setup step.\n\n- The record Claude Code logs when a worktree is created gains the fields `for_cloud_attach` and `resumed_existing`.\n\n- The root-privilege check is unchanged. Its message wording is also unchanged apart from the phrase \"Configure a WorktreeCreate hook\".\n\n**Why**\n\nIf you use a plugin that creates worktrees its own way, its `WorktreeCreate` hook can now run when you start Claude Code with `--worktree`. This could matter, for example, for version control systems other than git. If the hook still does not run, check the log for the new warning.\n\n- Area: Worktrees\n- Names: `--worktree`, `WorktreeCreate`\n- Tier: You'll notice\n- Useful: 3\/5\n- Signal: 1\/5\n- Scope: individual\n- Heads-up: no"}