Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

refactor: replace fragmented hooks_display_path with compute_hooks_display_path (#419)

Maximilian Roos93596af7e327
diff --git a/.claude/rules/cli-output-formatting.md b/.claude/rules/cli-output-formatting.md
index 171edd015..a9f19408c 100644
--- a/.claude/rules/cli-output-formatting.md
+++ b/.claude/rules/cli-output-formatting.md
@@ -63,6 +63,49 @@ Stats are truly optional context. Reasons answer "why is this safe/happening?"
and belong with the main message. Symbols within reason parentheses still render
in their native styling (see "Symbol styling" below).
+**Show path when hooks run in a different directory:** When hooks run in a
+worktree other than the user's current (or eventual) location, show the path.
+Use `output::compute_hooks_display_path(hooks_run_at, user_location)` which
+returns `Some(hooks_run_at)` when different from `user_location`, or `None`
+when they match.
+
+There are two cases for determining `user_location`:
+
+1. **Pre-hooks** — User is at cwd when hooks run. Use cwd as user_location.
+ Example: `wt step commit` runs pre-commit hooks in the current worktree.
+
+2. **Post-hooks** — User will be at destination if shell integration is active.
+ Check `is_shell_integration_active()` to determine user_location.
+ Examples: post-switch, post-start, post-create, post-merge hooks.
+
+```rust
+// Pre-hooks: user is at cwd when hooks run
+let cwd = std::env::current_dir().unwrap_or_else(|_| ctx.worktree_path.to_path_buf());
+let display_path = crate::output::compute_hooks_display_path(ctx.worktree_path, &cwd);
+
+// Post-hooks: user will be at destination if shell integration active
+let user_location = if crate::output::is_shell_integration_active() {
+ destination_path.to_path_buf()
+} else {
+ std::env::current_dir().unwrap_or_else(|_| destination_path.to_path_buf())
+};
+let display_path = crate::output::compute_hooks_display_path(&destination_path, &user_location);
+
+// Simpler post-hook case when destination == worktree_path
+let display_path = if crate::output::is_shell_integration_active() {
+ None // Shell will cd there
+} else {
+ Some(destination_path.as_path())
+};
+```
+
+Omit the path when the user is (or will be) in the worktree where hooks run:
+
+- **User is already there and will stay**: Pre-merge hooks, pre-commit hooks
+ when cwd matches worktree_path
+- **User will cd there via shell integration**: Post-switch, post-start, and
+ post-merge hooks when shell integration is active
+
**Avoid pronouns with cross-message referents:** Hints appear as separate
messages from errors. Don't use pronouns like "it" that refer to something
mentioned in the error message.
diff --git a/src/commands/commit.rs b/src/commands/commit.rs
index 89be4a31d..d0a219ae8 100644
--- a/src/commands/commit.rs
+++ b/src/commands/commit.rs
@@ -167,6 +167,9 @@ impl CommitOptions<'_> {
.collect();
// Run pre-commit hooks (user first, then project)
+ // Pre-hook: user is at cwd when hooks run
+ let cwd =
+ std::env::current_dir().unwrap_or_else(|_| self.ctx.worktree_path.to_path_buf());
super::hooks::run_hook_with_filter(
self.ctx,
self.ctx.config.hooks.pre_commit.as_ref(),
@@ -176,8 +179,8 @@ impl CommitOptions<'_> {
HookType::PreCommit,
&extra_vars,
HookFailureStrategy::FailFast,
- None, // name_filter: run all hooks
- None, // display_path: running in expected directory
+ None,
+ crate::output::compute_hooks_display_path(self.ctx.worktree_path, &cwd),
)
.map_err(worktrunk::git::add_hook_skip_hint)?;
}
diff --git a/src/commands/hook_commands.rs b/src/commands/hook_commands.rs
index 23a134b40..295a8d4a9 100644
--- a/src/commands/hook_commands.rs
+++ b/src/commands/hook_commands.rs
@@ -88,6 +88,8 @@ pub fn run_hook(hook_type: HookType, yes: bool, name_filter: Option<&str>) -> an
.as_ref()
.and_then(|c| c.hooks.post_create.as_ref());
require_hooks(user_config, project_config, hook_type)?;
+ // Manual wt hook: user is always at cwd (no cd happens)
+ let cwd = std::env::current_dir().unwrap_or_else(|_| ctx.worktree_path.to_path_buf());
run_hook_with_filter(
&ctx,
user_config,
@@ -96,7 +98,7 @@ pub fn run_hook(hook_type: HookType, yes: bool, name_filter: Option<&str>) -> an
&[],
HookFailureStrategy::FailFast,
name_filter,
- None,
+ crate::output::compute_hooks_display_path(ctx.worktree_path, &cwd),
)
}
HookType::PostStart => {
@@ -150,6 +152,8 @@ pub fn run_hook(hook_type: HookType, yes: bool, name_filter: Option<&str>) -> an
.into_iter()
.map(|t| ("target", t))
.collect();
+ // Manual wt hook: user is always at cwd (no cd happens)
+ let cwd = std::env::current_dir().unwrap_or_else(|_| ctx.worktree_path.to_path_buf());
run_hook_with_filter(
&ctx,
user_config,
@@ -158,7 +162,7 @@ pub fn run_hook(hook_type: HookType, yes: bool, name_filter: Option<&str>) -> an
&extra_vars,
HookFailureStrategy::FailFast,
name_filter,
- None,
+ crate::output::compute_hooks_display_path(ctx.worktree_path, &cwd),
)
}
HookType::PreMerge => {
@@ -170,10 +174,24 @@ pub fn run_hook(hook_type: HookType, yes: bool, name_filter: Option<&str>) -> an
}
HookType::PostMerge => {
// Use current branch as target (matches approval prompt for wt hook)
- // No display_path - user is already in the directory where hooks run
- execute_post_merge_commands(&ctx, ctx.branch_or_head(), name_filter, None)
+ // Manual wt hook: user is always at cwd (no cd happens)
+ let cwd = std::env::current_dir().unwrap_or_else(|_| ctx.worktree_path.to_path_buf());
+ execute_post_merge_commands(
+ &ctx,
+ ctx.branch_or_head(),
+ name_filter,
+ crate::output::compute_hooks_display_path(ctx.worktree_path, &cwd),
+ )
+ }
+ HookType::PreRemove => {
+ // Manual wt hook: user is always at cwd (no cd happens)
+ let cwd = std::env::current_dir().unwrap_or_else(|_| ctx.worktree_path.to_path_buf());
+ execute_pre_remove_commands(
+ &ctx,
+ name_filter,
+ crate::output::compute_hooks_display_path(ctx.worktree_path, &cwd),
+ )
}
- HookType::PreRemove => execute_pre_remove_commands(&ctx, name_filter),
}
}
diff --git a/src/commands/hooks.rs b/src/commands/hooks.rs
index 127280c8d..8ce34da13 100644
--- a/src/commands/hooks.rs
+++ b/src/commands/hooks.rs
@@ -234,8 +234,8 @@ pub(crate) fn check_name_filter_matched(
/// Runs user hooks first, then project hooks sequentially. Handles name filtering
/// and returns an error if a name filter was provided but no matching command found.
///
-/// `display_path`: When `Some`, shows the path in hook announcements. Use when hooks
-/// run in a different directory than where the user invoked the command.
+/// `display_path`: Pass `ctx.hooks_display_path()` for automatic detection, or
+/// explicit `Some(path)` when hooks run somewhere the user won't be cd'd to.
#[allow(clippy::too_many_arguments)]
pub fn run_hook_with_filter(
ctx: &CommandContext,
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index 03f89bd69..82c74d053 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -262,7 +262,12 @@ pub fn handle_merge(opts: MergeOptions<'_>) -> anyhow::Result<()> {
Some(destination_path.as_path())
} else {
// Worktree removed — show path only if shell integration won't cd there
- crate::output::hooks_display_path(&destination_path)
+ // Post-hook: user will be at destination if shell integration active
+ if crate::output::is_shell_integration_active() {
+ None // Shell will cd there
+ } else {
+ Some(destination_path.as_path())
+ }
};
execute_post_merge_commands(&ctx, &target_branch, None, display_path)?;
}
@@ -280,6 +285,8 @@ pub fn run_pre_merge_commands(
target_branch: &str,
name_filter: Option<&str>,
) -> anyhow::Result<()> {
+ // Pre-hook: user is at cwd when hooks run
+ let cwd = std::env::current_dir().unwrap_or_else(|_| ctx.worktree_path.to_path_buf());
run_hook_with_filter(
ctx,
ctx.config.hooks.pre_merge.as_ref(),
@@ -288,7 +295,7 @@ pub fn run_pre_merge_commands(
&[("target", target_branch)],
HookFailureStrategy::FailFast,
name_filter,
- None, // No path display - running in expected directory
+ crate::output::compute_hooks_display_path(ctx.worktree_path, &cwd),
)
.map_err(worktrunk::git::add_hook_skip_hint)
}
@@ -298,8 +305,8 @@ pub fn run_pre_merge_commands(
/// Runs user hooks first, then project hooks.
/// Approval is handled at the gate (command entry point).
///
-/// `display_path`: When `Some`, shows the path in hook announcements. Pass this when
-/// the worktree is preserved and the user's shell remains in a different directory.
+/// `display_path`: Pass `ctx.hooks_display_path()` for automatic detection, or
+/// explicit `Some(path)` when hooks run somewhere the user won't be cd'd to.
pub fn execute_post_merge_commands(
ctx: &CommandContext,
target_branch: &str,
@@ -329,9 +336,13 @@ pub fn execute_post_merge_commands(
/// Runs user hooks first, then project hooks.
/// Runs before a worktree is removed. Non-zero exit aborts the removal.
/// Approval is handled at the gate (command entry point).
+///
+/// `display_path`: Pass `ctx.hooks_display_path()` for automatic detection, or
+/// explicit `Some(path)` when hooks run somewhere the user won't be cd'd to.
pub fn execute_pre_remove_commands(
ctx: &CommandContext,
name_filter: Option<&str>,
+ display_path: Option<&Path>,
) -> anyhow::Result<()> {
let project_config = ctx.repo.load_project_config()?;
@@ -345,7 +356,7 @@ pub fn execute_pre_remove_commands(
&[],
HookFailureStrategy::FailFast,
name_filter,
- None, // No path display - running in expected directory
+ display_path,
)
.map_err(worktrunk::git::add_hook_skip_hint)
}
diff --git a/src/commands/step_commands.rs b/src/commands/step_commands.rs
index 5e580edd8..6728ac2b4 100644
--- a/src/commands/step_commands.rs
+++ b/src/commands/step_commands.rs
@@ -134,7 +134,9 @@ pub fn handle_squash(
}
// Run pre-commit hooks (user first, then project)
+ // Pre-hook: user is at cwd when hooks run
if !skip_pre_commit {
+ let cwd = std::env::current_dir().unwrap_or_else(|_| ctx.worktree_path.to_path_buf());
let extra_vars = [("target", target_branch.as_str())];
run_hook_with_filter(
&ctx,
@@ -146,7 +148,7 @@ pub fn handle_squash(
&extra_vars,
HookFailureStrategy::FailFast,
None,
- None,
+ crate::output::compute_hooks_display_path(ctx.worktree_path, &cwd),
)
.map_err(worktrunk::git::add_hook_skip_hint)?;
}
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index 8b26cbd91..7ccc843ae 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -759,8 +759,16 @@ impl<'a> CommandContext<'a> {
/// Execute post-create commands sequentially (blocking)
///
/// Runs user hooks first, then project hooks.
+ /// Shows path in hook announcements when shell integration isn't active (user's shell
+ /// won't cd to the new worktree, so they need to know where hooks ran).
pub fn execute_post_create_commands(&self) -> anyhow::Result<()> {
let project_config = self.repo.load_project_config()?;
+ // Post-hook: user will be at worktree_path if shell integration active
+ let user_location = if crate::output::is_shell_integration_active() {
+ self.worktree_path.to_path_buf()
+ } else {
+ std::env::current_dir().unwrap_or_else(|_| self.worktree_path.to_path_buf())
+ };
super::hooks::run_hook_with_filter(
self,
self.config.hooks.post_create.as_ref(),
@@ -771,7 +779,7 @@ impl<'a> CommandContext<'a> {
&[],
HookFailureStrategy::Warn,
None,
- None, // No path display - running in expected directory
+ crate::output::compute_hooks_display_path(self.worktree_path, &user_location),
)
}
diff --git a/src/output/global.rs b/src/output/global.rs
index 63486bb28..ffa8f8c9c 100644
--- a/src/output/global.rs
+++ b/src/output/global.rs
@@ -276,17 +276,36 @@ pub fn is_shell_integration_active() -> bool {
has_directive_file()
}
-/// Returns `Some(path)` when shell integration isn't active, `None` otherwise.
+/// Compute whether to show "@ path" in hook announcements.
///
-/// Use this to decide whether hook announcements should show "@ path".
-/// When shell integration is active, the user's shell will cd to the path automatically,
-/// so no annotation is needed. When inactive, showing the path helps users understand
-/// where hooks are running.
-pub fn hooks_display_path(path: &std::path::Path) -> Option<&std::path::Path> {
- if is_shell_integration_active() {
+/// Returns `Some(hooks_run_at)` when the user's shell is (or will be) somewhere
+/// else, so the path annotation helps them understand where hooks executed.
+/// Returns `None` when no annotation is needed because the user is (or will be)
+/// at the hook location.
+///
+/// # Arguments
+///
+/// * `hooks_run_at` - The directory where hooks will execute
+/// * `user_location` - Where the user's shell is (or will be) when they see the output
+///
+/// # Determining `user_location`
+///
+/// For **pre-hooks** (pre-commit, pre-merge, pre-remove): pass `cwd` - the user
+/// sees hook output while at their current location.
+///
+/// For **post-hooks** (post-create, post-merge, post-switch, post-start): pass
+/// where the user **will be** after the command. If shell integration is active
+/// and a cd directive was emitted, that's the target path. Otherwise it's `cwd`.
+///
+/// For **manual `wt hook`**: always pass `cwd` - no cd happens.
+pub fn compute_hooks_display_path<'a>(
+ hooks_run_at: &'a std::path::Path,
+ user_location: &std::path::Path,
+) -> Option<&'a std::path::Path> {
+ if hooks_run_at == user_location {
None
} else {
- Some(path)
+ Some(hooks_run_at)
}
}
@@ -295,6 +314,21 @@ mod tests {
use super::*;
use std::path::PathBuf;
+ #[test]
+ fn test_compute_hooks_display_path_same_location() {
+ let path = PathBuf::from("/repo/worktree");
+ let result = compute_hooks_display_path(&path, &path);
+ assert!(result.is_none(), "Should return None when paths match");
+ }
+
+ #[test]
+ fn test_compute_hooks_display_path_different_location() {
+ let hooks_run_at = PathBuf::from("/repo/feature");
+ let user_location = PathBuf::from("/repo/main");
+ let result = compute_hooks_display_path(&hooks_run_at, &user_location);
+ assert_eq!(result, Some(hooks_run_at.as_path()));
+ }
+
#[test]
fn test_lazy_init_does_not_panic() {
// Verify lazy initialization doesn't panic.
diff --git a/src/output/handlers.rs b/src/output/handlers.rs
index 168776854..c1ed55b45 100644
--- a/src/output/handlers.rs
+++ b/src/output/handlers.rs
@@ -519,8 +519,13 @@ fn spawn_post_switch_after_remove(
&repo_root,
false, // force=false for CommandContext
);
- // Show path when shell integration isn't active — the cd directive won't take effect
- ctx.spawn_post_switch_commands(super::hooks_display_path(main_path))
+ // Post-hook: user will be at main_path if shell integration active
+ let display_path = if super::is_shell_integration_active() {
+ None // Shell will cd there
+ } else {
+ Some(main_path)
+ };
+ ctx.spawn_post_switch_commands(display_path)
}
/// Handle output for RemovedWorktree removal
@@ -558,7 +563,13 @@ fn handle_removed_worktree_output(
main_path,
false, // force=false for CommandContext (not approval-related)
);
- execute_pre_remove_commands(&ctx, None)?;
+ // Show path when removing a different worktree (user is elsewhere)
+ let display_path = if changed_directory {
+ None // User was already here
+ } else {
+ Some(worktree_path) // Show path when user is elsewhere
+ };
+ execute_pre_remove_commands(&ctx, None, display_path)?;
}
// Handle detached HEAD case (no branch known)
diff --git a/src/output/mod.rs b/src/output/mod.rs
index fc23fcd55..fbffa780b 100644
--- a/src/output/mod.rs
+++ b/src/output/mod.rs
@@ -34,8 +34,8 @@ pub mod shell_integration;
// Re-export the public API
pub use global::{
- blank, change_directory, execute, flush, hooks_display_path, is_shell_integration_active,
- print, stdout, terminate_output,
+ blank, change_directory, compute_hooks_display_path, execute, flush,
+ is_shell_integration_active, print, stdout, terminate_output,
};
// Re-export output handlers
pub use handlers::{
diff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rs
index 03fb4dfd3..d67c33b9b 100644
--- a/tests/integration_tests/user_hooks.rs
+++ b/tests/integration_tests/user_hooks.rs
@@ -776,6 +776,48 @@ fn test_standalone_hook_pre_commit(repo: TestRepo) {
assert!(content.contains("STANDALONE_PRE_COMMIT"));
}
+/// Test `wt hook post-merge` standalone execution
+#[rstest]
+fn test_standalone_hook_post_merge(repo: TestRepo) {
+ // Write project config with post-merge hook
+ repo.write_project_config(r#"post-merge = "echo 'STANDALONE_POST_MERGE' > hook_ran.txt""#);
+
+ let mut cmd = crate::common::wt_command();
+ cmd.current_dir(repo.root_path());
+ cmd.env("WORKTRUNK_CONFIG_PATH", repo.test_config_path());
+ cmd.args(["hook", "post-merge", "--yes"]);
+
+ let output = cmd.output().unwrap();
+ assert!(output.status.success(), "wt hook post-merge should succeed");
+
+ // Hook should have run
+ let marker = repo.root_path().join("hook_ran.txt");
+ assert!(marker.exists(), "post-merge hook should have run");
+ let content = fs::read_to_string(&marker).unwrap();
+ assert!(content.contains("STANDALONE_POST_MERGE"));
+}
+
+/// Test `wt hook pre-remove` standalone execution
+#[rstest]
+fn test_standalone_hook_pre_remove(repo: TestRepo) {
+ // Write project config with pre-remove hook
+ repo.write_project_config(r#"pre-remove = "echo 'STANDALONE_PRE_REMOVE' > hook_ran.txt""#);
+
+ let mut cmd = crate::common::wt_command();
+ cmd.current_dir(repo.root_path());
+ cmd.env("WORKTRUNK_CONFIG_PATH", repo.test_config_path());
+ cmd.args(["hook", "pre-remove", "--yes"]);
+
+ let output = cmd.output().unwrap();
+ assert!(output.status.success(), "wt hook pre-remove should succeed");
+
+ // Hook should have run
+ let marker = repo.root_path().join("hook_ran.txt");
+ assert!(marker.exists(), "pre-remove hook should have run");
+ let content = fs::read_to_string(&marker).unwrap();
+ assert!(content.contains("STANDALONE_PRE_REMOVE"));
+}
+
/// Test `wt hook post-create` fails when no hooks configured
#[rstest]
fn test_standalone_hook_no_hooks_configured(repo: TestRepo) {
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
index f2942f409..7c57016eb 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
@@ -9,7 +9,7 @@ y
○ post-create:
  echo 'test command'
❯ Allow and remember? [y/N]
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_/repo.BRANCH:
  echo 'test command'
test command
✓ Created new worktree for test-approve from main @ _REPO_/repo.BRANCH
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
index 703089334..5c360698e 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
@@ -11,13 +11,13 @@ y
○ post-create third:
  echo 'Third command'
❯ Allow and remember? [y/N]
-◎ Running post-create project:first:
+◎ Running post-create project:first @ _REPO_/repo.BRANCH:
  echo 'First command'
First command
-◎ Running post-create project:second:
+◎ Running post-create project:second @ _REPO_/repo.BRANCH:
  echo 'Second command'
Second command
-◎ Running post-create project:third:
+◎ Running post-create project:third @ _REPO_/repo.BRANCH:
  echo 'Third command'
Third command
✓ Created new worktree for test-mixed-accept from main @ _REPO_/repo.BRANCH
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
index b56d0ed1e..6f02000e5 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
@@ -13,13 +13,13 @@ y
○ post-create third:
  echo 'Third command'
❯ Allow and remember? [y/N]
-◎ Running post-create project:first:
+◎ Running post-create project:first @ _REPO_/repo.BRANCH:
  echo 'First command'
First command
-◎ Running post-create project:second:
+◎ Running post-create project:second @ _REPO_/repo.BRANCH:
  echo 'Second command'
Second command
-◎ Running post-create project:third:
+◎ Running post-create project:third @ _REPO_/repo.BRANCH:
  echo 'Third command'
Third command
✓ Created new worktree for test-multi from main @ _REPO_/repo.BRANCH
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
index ed36a3bec..003f9ea93 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
@@ -13,13 +13,13 @@ y
○ post-create test:
  echo 'Running tests...'
❯ Allow and remember? [y/N]
-◎ Running post-create project:install:
+◎ Running post-create project:install @ _REPO_/repo.BRANCH:
  echo 'Installing dependencies...'
Installing dependencies...
-◎ Running post-create project:build:
+◎ Running post-create project:build @ _REPO_/repo.BRANCH:
  echo 'Building project...'
Building project...
-◎ Running post-create project:test:
+◎ Running post-create project:test @ _REPO_/repo.BRANCH:
  echo 'Running tests...'
Running tests...
✓ Created new worktree for test-named from main @ _REPO_/repo.BRANCH
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
index b298178ed..db451960e 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
@@ -11,7 +11,7 @@ y
❯ Allow and remember? [y/N]
▲ Failed to save command approval: Failed to write config file: Permission denied (os error 13)
↳ Approval will be requested again next time.
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_/repo.BRANCH:
  echo 'test command'
test command
✓ Created new worktree for test-permission from main @ _REPO_/repo.BRANCH
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__already_approved_skip_prompt.snap b/tests/snapshots/integration__integration_tests__approval_ui__already_approved_skip_prompt.snap
index 79424d929..ee451bede 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__already_approved_skip_prompt.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__already_approved_skip_prompt.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.test-approved:
  echo 'approved' > output.txt
✓ Created new worktree for test-approved from main @ _REPO_.test-approved
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__yes_bypasses_tty_check.snap b/tests/snapshots/integration__integration_tests__approval_ui__yes_bypasses_tty_check.snap
index a8733839e..3340d9293 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__yes_bypasses_tty_check.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__yes_bypasses_tty_check.snap
@@ -33,7 +33,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.test-yes-tty:
  echo 'test command'
test command
✓ Created new worktree for test-yes-tty from main @ _REPO_.test-yes-tty
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_first_run.snap b/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_first_run.snap
index ea2243182..b8762bbb1 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_first_run.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_first_run.snap
@@ -33,7 +33,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.test-yes:
  echo 'test command' > output.txt
✓ Created new worktree for test-yes from main @ _REPO_.test-yes
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap b/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap
index 7d250c7b4..c667e8c42 100644
--- a/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap
+++ b/tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap
@@ -33,7 +33,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project:install:
+◎ Running post-create project:install @ _REPO_.feature-x:
  uv sync
Resolved 24 packages in 145ms
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap b/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap
index fb0ab5650..e9257017d 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.feature:
  echo 'Setup done' > setup.txt
✓ Created new worktree for feature from main @ _REPO_.feature
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_default_branch_template.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_default_branch_template.snap
index 24000f26c..8351ee3aa 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_default_branch_template.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_default_branch_template.snap
@@ -33,7 +33,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.feature:
  echo 'Default: main' > default.txt
✓ Created new worktree for feature from main @ _REPO_.feature
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap
index 7801e4524..7be438b83 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_failing_command.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.feature:
  exit 1
▲ Command failed: exit status: 1
✓ Created new worktree for feature from main @ _REPO_.feature
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_git_variables_template.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_git_variables_template.snap
index 31a81bf3d..863cfe78a 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_git_variables_template.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_git_variables_template.snap
@@ -33,13 +33,13 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project:commit:
+◎ Running post-create project:commit @ _REPO_.feature:
  echo 'Commit: 5caad75ed9319b7bd5c35c626d7051d252f987e7' > git_vars.txt
-◎ Running post-create project:short:
+◎ Running post-create project:short @ _REPO_.feature:
  echo 'Short: 5caad75' >> git_vars.txt
-◎ Running post-create project:remote:
+◎ Running post-create project:remote @ _REPO_.feature:
  echo 'Remote: origin' >> git_vars.txt
-◎ Running post-create project:worktree_name:
+◎ Running post-create project:worktree_name @ _REPO_.feature:
  echo 'Worktree Name: repo.feature' >> git_vars.txt
✓ Created new worktree for feature from main @ _REPO_.feature
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap
index 70df6aaeb..1d57f323e 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.feature:
  if [ ! -f test.txt ]; then
   echo 'File does not exist' > result.txt
  else
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_named_commands.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_named_commands.snap
index 79b6be1e8..0f144c8d6 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_named_commands.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_named_commands.snap
@@ -32,10 +32,10 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project:install:
+◎ Running post-create project:install @ _REPO_.feature:
  echo 'Installing deps'
Installing deps
-◎ Running post-create project:setup:
+◎ Running post-create project:setup @ _REPO_.feature:
  echo 'Running setup'
Running setup
✓ Created new worktree for feature from main @ _REPO_.feature
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_single_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_single_command.snap
index f403dad68..3b76339b5 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_single_command.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_single_command.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.feature:
  echo 'Setup complete'
Setup complete
✓ Created new worktree for feature from main @ _REPO_.feature
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_template_expansion.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_template_expansion.snap
index e69b2d9c8..51af0b40d 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_template_expansion.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_template_expansion.snap
@@ -32,15 +32,15 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project:repo:
+◎ Running post-create project:repo @ _REPO_.feature-test:
  echo 'Repo: repo' > info.txt
-◎ Running post-create project:branch:
+◎ Running post-create project:branch @ _REPO_.feature-test:
  echo 'Branch: feature/test' >> info.txt
-◎ Running post-create project:hash_port:
+◎ Running post-create project:hash_port @ _REPO_.feature-test:
  echo 'Port: 18064' >> info.txt
-◎ Running post-create project:worktree:
+◎ Running post-create project:worktree @ _REPO_.feature-test:
  echo 'Worktree: _REPO_.feature-test' >> info.txt
-◎ Running post-create project:root:
+◎ Running post-create project:root @ _REPO_.feature-test:
  echo 'Root: _REPO_' >> info.txt
✓ Created new worktree for feature/test from main @ _REPO_.feature-test
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap
index e9945d948..a5c0c4f0f 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap
@@ -33,7 +33,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.feature:
  echo 'Upstream: ' > upstream.txt
✓ Created new worktree for feature from main @ _REPO_.feature
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_executes.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_executes.snap
index c56be2e59..5e6c90fd1 100644
--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_executes.snap
+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_executes.snap
@@ -33,7 +33,7 @@ exit_code: 0
----- stderr -----
◎ Removing feature-hook worktree...
-◎ Running pre-remove project hook:
+◎ Running pre-remove project hook @ _REPO_.feature-hook:
  echo 'About to remove worktree'
About to remove worktree
✓ Removed feature-hook worktree & branch (same commit as main, _)
diff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap
index 3fa4909f1..4cbc2648a 100644
--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap
+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap
@@ -33,7 +33,7 @@ exit_code: 1
----- stderr -----
◎ Removing feature-fail worktree...
-◎ Running pre-remove project hook:
+◎ Running pre-remove project hook @ _REPO_.feature-fail:
  exit 1
✗ pre-remove command failed: exit status: 1
↳ To skip pre-remove hooks, re-run with --no-verify
diff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_template_variables.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_template_variables.snap
index 7edc7d994..68b6b6b49 100644
--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_template_variables.snap
+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_template_variables.snap
@@ -33,13 +33,13 @@ exit_code: 0
----- stderr -----
◎ Removing feature-templates worktree...
-◎ Running pre-remove project:branch:
+◎ Running pre-remove project:branch @ _REPO_.feature-templates:
  echo 'Branch: feature-templates'
Branch: feature-templates
-◎ Running pre-remove project:worktree:
+◎ Running pre-remove project:worktree @ _REPO_.feature-templates:
  echo 'Worktree: _REPO_.feature-templates'
Worktree: _REPO_.feature-templates
-◎ Running pre-remove project:worktree_name:
+◎ Running pre-remove project:worktree_name @ _REPO_.feature-templates:
  echo 'Name: repo.feature-templates'
Name: repo.feature-templates
✓ Removed feature-templates worktree & branch (same commit as main, _)
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_hook_template_vars.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_hook_template_vars.snap
index 7d661bcbf..bb6068596 100644
--- a/tests/snapshots/integration__integration_tests__user_hooks__user_hook_template_vars.snap
+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_hook_template_vars.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create user:vars:
+◎ Running post-create user:vars @ _REPO_.feature:
  echo 'repo=repo branch=feature' > template_vars.txt
✓ Created new worktree for feature from main @ _REPO_.feature
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_before_project.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_before_project.snap
index a7b8e3750..af109f4cc 100644
--- a/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_before_project.snap
+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_before_project.snap
@@ -32,9 +32,9 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create user:log:
+◎ Running post-create user:log @ _REPO_.feature:
  echo 'USER_HOOK' >> hook_order.txt
-◎ Running post-create project hook:
+◎ Running post-create project hook @ _REPO_.feature:
  echo 'PROJECT_HOOK' >> hook_order.txt
✓ Created new worktree for feature from main @ _REPO_.feature
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_no_approval.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_no_approval.snap
index 78940e3b4..16e6ffd7f 100644
--- a/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_no_approval.snap
+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_hooks_no_approval.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create user:setup:
+◎ Running post-create user:setup @ _REPO_.feature:
  echo 'NO_APPROVAL_NEEDED' > no_approval.txt
✓ Created new worktree for feature from main @ _REPO_.feature
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_executes.snap
index f3596aa2f..f736c41cc 100644
--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_executes.snap
+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_executes.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create user:log:
+◎ Running post-create user:log @ _REPO_.feature:
  echo 'USER_POST_CREATE_RAN' > user_hook_marker.txt
✓ Created new worktree for feature from main @ _REPO_.feature
▲ Cannot change directory — shell integration not installed
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_failure.snap
index 90bc0bc33..6d8479374 100644
--- a/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_failure.snap
+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_post_create_failure.snap
@@ -32,7 +32,7 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running post-create user:failing:
+◎ Running post-create user:failing @ _REPO_.feature:
  exit 1
▲ Command failing failed: exit status: 1
✓ Created new worktree for feature from main @ _REPO_.feature
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap
index 2caeb3fad..467ea1c81 100644
--- a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap
+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap
@@ -32,6 +32,6 @@ exit_code: 0
----- stdout -----
----- stderr -----
-◎ Running pre-remove user:cleanup:
+◎ Running pre-remove user:cleanup @ _REPO_.feature:
  echo 'USER_PRE_REMOVE_RAN' > ../user_preremove_marker.txt
◎ Removing feature worktree & branch in background (--force-delete)
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap
index e330a6362..201880299 100644
--- a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap
+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap
@@ -32,7 +32,7 @@ exit_code: 1
----- stdout -----
----- stderr -----
-◎ Running pre-remove user:block:
+◎ Running pre-remove user:block @ _REPO_.feature:
  exit 1
✗ pre-remove command failed: block: exit status: 1
↳ To skip pre-remove hooks, re-run with --no-verify