Skip to content

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

feat: Add pre-commit hook to enforce output system usage

Maximilian Roos5523e3201807
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 385c6353d..6b3d09a15 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -38,6 +38,13 @@ repos:
language: pygrep
types: ["rust"]
entry: "dbg!"
+ - id: check-output-system
+ name: check-output-system
+ description: Commands using --internal must use crate::output::* functions
+ language: script
+ entry: scripts/check-output-system.sh
+ pass_filenames: false
+ files: "^src/commands/(worktree|merge)\\.rs$"
ci:
# Currently network access isn't supported in the CI product.
diff --git a/CLAUDE.md b/CLAUDE.md
index 65253eea8..6259c8a01 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -615,6 +615,78 @@ output::progress("πŸ’‘ Use 'wt list' to see all worktrees")?;
If the output function you need doesn't exist yet, follow the pattern in "Adding New Output Functions" above.
+### Architectural Constraint: --internal Commands Must Use Output System
+
+**CRITICAL: Commands that support `--internal` mode must NEVER use direct print macros (`print!()`, `println!()`, `eprint!()`, or `eprintln!()`).**
+
+Commands that support the `--internal` flag (switch, remove, merge) emit directives for shell wrapper integration. Using direct print statements bypasses the output system and causes directive leaks - directives become visible to users in interactive mode.
+
+#### The Problem
+
+When a command uses `println!()` directly:
+
+1. **Interactive mode**: Output appears correctly (luck, not design)
+2. **Directive mode**: Direct prints get concatenated with NUL-terminated directives, causing directives to leak into user-visible output
+
+**Example of the bug:**
+```
+πŸ”„ Starting (background):
+__WORKTRUNK_CD__/Users/name/workspace/repo.branch
+Created new worktree...
+```
+
+The `__WORKTRUNK_CD__` directive should be invisible, parsed only by the shell wrapper.
+
+#### The Solution
+
+**Commands supporting `--internal` must use `crate::output::*` functions exclusively:**
+
+```rust
+// ❌ NEVER DO THIS in commands that support --internal
+println!("πŸ”„ Starting operation...");
+print!("{}", formatted_output);
+eprintln!("Some progress message");
+eprint!("{}", error_message);
+
+// βœ… ALWAYS DO THIS
+crate::output::progress("πŸ”„ Starting operation...")?;
+crate::output::progress(formatted_output)?;
+crate::output::progress("Some progress message")?;
+crate::output::progress(error_message)?;
+```
+
+#### Which Commands Are Restricted
+
+Files that support `--internal` mode (see `scripts/check-output-system.sh`):
+
+- `src/commands/worktree.rs` (switch, remove commands)
+- `src/commands/merge.rs` (merge command)
+
+Other command files can use direct `println!()` if they never emit directives.
+
+#### Enforcement
+
+The restriction is enforced by:
+
+1. **Lint script**: `scripts/check-output-system.sh` checks restricted files for direct print usage
+2. **Integration tests**: `tests/integration_tests/shell_wrapper.rs` executes commands through the actual bash wrapper to catch directive leaks
+
+Run the lint script to verify compliance:
+```bash
+./scripts/check-output-system.sh
+```
+
+#### Why This Matters
+
+This constraint maintains architectural integrity:
+
+- **Separation of concerns**: Output formatting is centralized in the output system
+- **Mode transparency**: Commands don't need to know which mode they're running in
+- **Protocol correctness**: Directives are properly NUL-terminated and never leak
+- **Testability**: Shell integration can be tested end-to-end
+
+When adding new functionality to restricted commands, always ask: "Does this need output?" If yes, use `crate::output::progress()` or `crate::output::success()`, never direct prints.
+
## Testing Guidelines
### Testing with --execute Commands
diff --git a/scripts/check-output-system.sh b/scripts/check-output-system.sh
new file mode 100755
index 000000000..a3a900425
--- /dev/null
+++ b/scripts/check-output-system.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# Check that commands using --internal mode don't bypass the output system
+#
+# Commands that support --internal (switch, remove, merge) must use the output
+# system (crate::output::*) rather than direct println!/eprintln! calls.
+# This prevents directive leaks in shell wrapper integration.
+
+set -euo pipefail
+
+# Files that must use output system (support --internal mode)
+RESTRICTED_FILES=(
+ "src/commands/worktree.rs"
+ "src/commands/merge.rs"
+)
+
+# Allowed exceptions (test code, etc.)
+ALLOWED_PATTERNS=(
+ "spacing_test\.rs"
+ "command_approval\.rs"
+)
+
+exit_code=0
+
+for file in "${RESTRICTED_FILES[@]}"; do
+ if [[ ! -f "$file" ]]; then
+ continue
+ fi
+
+ # Check for direct print!/println!/eprint!/eprintln! usage
+ while IFS= read -r line; do
+ # Skip if it matches any allowed pattern
+ skip=false
+ for pattern in "${ALLOWED_PATTERNS[@]}"; do
+ if echo "$line" | grep -q "$pattern"; then
+ skip=true
+ break
+ fi
+ done
+
+ if [[ "$skip" == "true" ]]; then
+ continue
+ fi
+
+ echo "❌ Direct output in $line"
+ echo " Commands using --internal must use crate::output::* functions"
+ echo " Replace print!/println! with output::progress() or output::success()"
+ exit_code=1
+ done < <(grep -n "print!\|println!\|eprint!\|eprintln!" "$file" | grep -v "//.*print" || true)
+done
+
+if [[ $exit_code -eq 0 ]]; then
+ echo "βœ… Output system check passed"
+fi
+
+exit $exit_code
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index b33c9288b..8a72096e6 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -1,6 +1,6 @@
use worktrunk::config::{ProjectConfig, WorktrunkConfig};
use worktrunk::git::{GitError, Repository};
-use worktrunk::styling::{AnstyleStyle, CYAN, CYAN_BOLD, eprint, format_with_gutter, println};
+use worktrunk::styling::{AnstyleStyle, CYAN, CYAN_BOLD, format_with_gutter};
use super::command_executor::{CommandContext, prepare_project_commands};
use super::worktree::handle_push;
@@ -151,11 +151,13 @@ pub fn handle_merge(
}
// Print comprehensive summary
- println!();
+ crate::output::progress("")
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
handle_merge_summary_output(Some(&primary_worktree_dir))?;
} else {
// Print comprehensive summary (worktree preserved)
- println!();
+ crate::output::progress("")
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
handle_merge_summary_output(None)?;
}
@@ -233,11 +235,8 @@ fn handle_commit_changes(
// Display the generated commit message
let formatted_message = format_commit_message_for_display(&commit_message);
- print!("{}", format_with_gutter(&formatted_message, "", None));
-
- // Flush stdout to ensure message appears immediately (before any subsequent stderr output)
- use std::io::Write;
- let _ = std::io::stdout().flush();
+ crate::output::progress(format_with_gutter(&formatted_message, "", None))
+ .map_err(|e| GitError::CommandFailed(e.to_string()))?;
// Commit
repo.run_command(&["commit", "-m", &commit_message])
@@ -313,11 +312,8 @@ fn handle_squash(target_branch: &str) -> Result<Option<usize>, GitError> {
// Display the generated commit message
let formatted_message = format_commit_message_for_display(&commit_message);
- print!("{}", format_with_gutter(&formatted_message, "", None));
-
- // Flush stdout to ensure message appears immediately (before any subsequent stderr output)
- use std::io::Write;
- let _ = std::io::stdout().flush();
+ crate::output::progress(format_with_gutter(&formatted_message, "", None))
+ .map_err(|e| GitError::CommandFailed(e.to_string()))?;
// Reset to merge base (soft reset stages all changes)
repo.run_command(&["reset", "--soft", &merge_base])
@@ -358,19 +354,18 @@ fn run_pre_merge_commands(
"Pre-merge commands",
|_, command| {
let dim = AnstyleStyle::new().dimmed();
- println!("{dim}Skipping pre-merge command: {command}{dim:#}");
+ crate::output::progress(format!("{dim}Skipping pre-merge command: {command}{dim:#}"))
+ .ok();
},
)?;
for prepared in commands {
- use std::io::Write;
- use worktrunk::styling;
-
- println!(
+ crate::output::progress(format!(
"πŸ”„ {CYAN}Running pre-merge command {CYAN_BOLD}{name}{CYAN_BOLD:#}:{CYAN:#}",
name = prepared.name
- );
- eprint!("{}", format_with_gutter(&prepared.expanded, "", None)); // Gutter at column 0
- let _ = styling::stderr().flush();
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
+ crate::output::progress(format_with_gutter(&prepared.expanded, "", None))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
if let Err(e) = execute_command_in_worktree(worktree_path, &prepared.expanded) {
return Err(GitError::PreMergeCommandFailed {
@@ -422,7 +417,7 @@ fn execute_post_merge_commands(
"Post-merge commands",
|_, command| {
let dim = AnstyleStyle::new().dimmed();
- println!("{dim}Skipping command: {command}{dim:#}");
+ crate::output::progress(format!("{dim}Skipping command: {command}{dim:#}")).ok();
},
)?;
@@ -432,28 +427,27 @@ fn execute_post_merge_commands(
// Execute each command sequentially in the main worktree
for prepared in commands {
- use std::io::Write;
- println!(
+ crate::output::progress(format!(
"πŸ”„ {CYAN}Running post-merge command {CYAN_BOLD}{name}{CYAN_BOLD:#}:{CYAN:#}",
name = prepared.name
- );
- eprint!("{}", format_with_gutter(&prepared.expanded, "", None));
- let _ = std::io::stderr().flush();
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
+ crate::output::progress(format_with_gutter(&prepared.expanded, "", None))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
if let Err(e) = execute_command_in_worktree(main_worktree_path, &prepared.expanded) {
use worktrunk::styling::WARNING_EMOJI;
let warning_bold = WARNING.bold();
- println!(
+ crate::output::progress(format!(
"{WARNING_EMOJI} {WARNING}Command {warning_bold}{name}{warning_bold:#} failed: {e}{WARNING:#}",
name = prepared.name,
- );
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
// Continue with other commands even if one fails
}
}
- use std::io::Write;
- let _ = std::io::stdout().flush();
- let _ = std::io::stderr().flush();
+ crate::output::flush().map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
Ok(())
}
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index 051478998..c3122b33f 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -105,7 +105,7 @@ use worktrunk::config::{ProjectConfig, WorktrunkConfig};
use worktrunk::git::{GitError, Repository};
use worktrunk::styling::{
ADDITION, AnstyleStyle, CYAN, CYAN_BOLD, DELETION, GREEN, GREEN_BOLD, SUCCESS_EMOJI, WARNING,
- WARNING_EMOJI, eprint, format_with_gutter, println,
+ WARNING_EMOJI, format_with_gutter,
};
use super::command_executor::{CommandContext, prepare_project_commands};
@@ -161,9 +161,10 @@ pub fn handle_switch(
// Check if base flag was provided without create flag
if base.is_some() && !create {
- println!(
+ crate::output::progress(format!(
"{WARNING_EMOJI} {WARNING}--base flag is only used with --create, ignoring{WARNING:#}"
- );
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
}
// Check if worktree already exists for this branch
@@ -261,11 +262,15 @@ fn remove_current_worktree(repo: &Repository) -> Result<RemoveResult, GitError>
// Remove the worktree
if let Err(e) = repo.remove_worktree(&worktree_root) {
- println!("{WARNING_EMOJI} {WARNING}Failed to remove worktree: {e}{WARNING:#}");
- println!(
+ crate::output::progress(format!(
+ "{WARNING_EMOJI} {WARNING}Failed to remove worktree: {e}{WARNING:#}"
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
+ crate::output::progress(format!(
"You may need to run 'git worktree remove {}' manually",
worktree_root.display()
- );
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
}
Ok(RemoveResult::RemovedWorktree {
@@ -320,11 +325,15 @@ fn remove_worktree_by_name(repo: &Repository, branch_name: &str) -> Result<Remov
// Remove the worktree
if let Err(e) = repo.remove_worktree(&worktree_path) {
- println!("{WARNING_EMOJI} {WARNING}Failed to remove worktree: {e}{WARNING:#}");
- println!(
+ crate::output::progress(format!(
+ "{WARNING_EMOJI} {WARNING}Failed to remove worktree: {e}{WARNING:#}"
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
+ crate::output::progress(format!(
"You may need to run 'git worktree remove {}' manually",
worktree_path.display()
- );
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
}
// If we removed the current worktree, return to primary
@@ -419,7 +428,7 @@ fn execute_post_create_commands(
"Post-create commands",
|_, command| {
let dim = AnstyleStyle::new().dimmed();
- println!("{dim}Skipping command: {command}{dim:#}");
+ crate::output::progress(format!("{dim}Skipping command: {command}{dim:#}")).ok();
},
)?;
@@ -429,24 +438,23 @@ fn execute_post_create_commands(
// Execute each command sequentially
for prepared in commands {
- use std::io::Write;
- println!("πŸ”„ {CYAN}Executing (post-create):{CYAN:#}");
- eprint!("{}", format_with_gutter(&prepared.expanded, "", None)); // Gutter at column 0
- let _ = std::io::stderr().flush();
+ crate::output::progress(format!("πŸ”„ {CYAN}Executing (post-create):{CYAN:#}"))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
+ crate::output::progress(format_with_gutter(&prepared.expanded, "", None))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
if let Err(e) = execute_command_in_worktree(worktree_path, &prepared.expanded) {
let warning_bold = WARNING.bold();
- println!(
+ crate::output::progress(format!(
"{WARNING_EMOJI} {WARNING}Command {warning_bold}{name}{warning_bold:#} failed: {e}{WARNING:#}",
name = prepared.name,
- );
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
// Continue with other commands even if one fails
}
}
- use std::io::Write;
- let _ = std::io::stdout().flush();
- let _ = std::io::stderr().flush();
+ crate::output::flush().map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
Ok(())
}
@@ -478,7 +486,7 @@ fn spawn_post_start_commands(
"Post-start commands",
|_, command| {
let dim = AnstyleStyle::new().dimmed();
- println!("{dim}Skipping command: {command}{dim:#}");
+ crate::output::progress(format!("{dim}Skipping command: {command}{dim:#}")).ok();
},
)?;
@@ -488,10 +496,10 @@ fn spawn_post_start_commands(
// Spawn each command as a detached background process
for prepared in commands {
- use std::io::Write;
- println!("πŸ”„ {CYAN}Starting (background):{CYAN:#}");
- eprint!("{}", format_with_gutter(&prepared.expanded, "", None));
- let _ = std::io::stderr().flush();
+ crate::output::progress(format!("πŸ”„ {CYAN}Starting (background):{CYAN:#}"))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
+ crate::output::progress(format_with_gutter(&prepared.expanded, "", None))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
match spawn_detached(worktree_path, &prepared.expanded, &prepared.name) {
Ok(_log_path) => {
@@ -499,17 +507,16 @@ fn spawn_post_start_commands(
// Log file path not shown - only needed for debugging failures
}
Err(e) => {
- println!(
+ crate::output::progress(format!(
"{WARNING_EMOJI} {WARNING}Failed to spawn '{name}': {e}{WARNING:#}",
name = prepared.name,
- );
+ ))
+ .map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
}
}
}
- use std::io::Write;
- let _ = std::io::stdout().flush();
- let _ = std::io::stderr().flush();
+ crate::output::flush().map_err(|e| GitError::CommandFailed(format!("Output error: {}", e)))?;
Ok(())
}
diff --git a/tests/integration_tests/directives.rs b/tests/integration_tests/directives.rs
index 6b003ead8..ef0c796de 100644
--- a/tests/integration_tests/directives.rs
+++ b/tests/integration_tests/directives.rs
@@ -173,7 +173,7 @@ fn test_merge_internal_keep() {
.arg("--keep")
.current_dir(&feature_wt);
- assert_cmd_snapshot!(cmd, @"success: true\nexit_code: 0\n----- stdout -----\n\nKept worktree (use 'wt remove' to clean up)\0\n----- stderr -----");
+ assert_cmd_snapshot!(cmd, @"success: true\nexit_code: 0\n----- stdout -----\nKept worktree (use 'wt remove' to clean up)\0\n----- stderr -----");
});
}
@@ -229,6 +229,6 @@ fn test_merge_internal_remove() {
.arg("main")
.current_dir(&feature_wt);
- assert_cmd_snapshot!(cmd, @"success: true\nexit_code: 0\n----- stdout -----\n__WORKTRUNK_CD__[PATH]\0\nReturned to primary at [REPO]\0\n----- stderr -----");
+ assert_cmd_snapshot!(cmd, @"success: true\nexit_code: 0\n----- stdout -----\n__WORKTRUNK_CD__[PATH]\0Returned to primary at [REPO]\0\n----- stderr -----");
});
}
diff --git a/tests/integration_tests/mod.rs b/tests/integration_tests/mod.rs
index e8dc293e2..986281320 100644
--- a/tests/integration_tests/mod.rs
+++ b/tests/integration_tests/mod.rs
@@ -15,5 +15,6 @@ pub mod merge;
pub mod post_start_commands;
pub mod push;
pub mod remove;
+pub mod shell_wrapper;
pub mod spacing_edge_cases;
pub mod switch;
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rs
new file mode 100644
index 000000000..478982465
--- /dev/null
+++ b/tests/integration_tests/shell_wrapper.rs
@@ -0,0 +1,259 @@
+//! Shell wrapper integration tests
+//!
+//! Tests that verify the complete shell integration path - commands executed through
+//! the actual shell wrapper (_wt_exec in bash/zsh/fish).
+//!
+//! These tests ensure that:
+//! - Directives are never leaked to users
+//! - Output is properly formatted for humans
+//! - Shell integration works end-to-end as users experience it
+
+use crate::common::TestRepo;
+use insta::assert_snapshot;
+use insta_cmd::get_cargo_bin;
+use std::fs;
+use std::path::Path;
+use std::process::Command;
+
+/// Generate the bash wrapper script from template
+fn generate_bash_wrapper(_repo: &TestRepo) -> String {
+ let template_path = Path::new(env!("CARGO_MANIFEST_DIR"))
+ .join("templates")
+ .join("bash.sh");
+ let template = fs::read_to_string(&template_path).expect("Failed to read bash template");
+
+ // Simple template substitution (matches what `wt init` does)
+ template
+ .replace("{{ shell_name }}", "bash")
+ .replace("{{ cmd_prefix }}", "wt")
+}
+
+/// Execute a command through the bash shell wrapper
+///
+/// This simulates what actually happens when users run `wt switch`, etc. in their shell:
+/// 1. The `wt` function is defined (from shell integration)
+/// 2. It calls `_wt_exec --internal switch ...`
+/// 3. The wrapper parses NUL-delimited output and handles directives
+/// 4. Users see only the final human-friendly output
+///
+/// Returns the combined stdout+stderr output as users would see it
+fn exec_through_bash_wrapper(repo: &TestRepo, subcommand: &str, args: &[&str]) -> String {
+ let wrapper_script = generate_bash_wrapper(repo);
+
+ // Get the path to wt binary
+ let wt_bin = get_cargo_bin("wt");
+
+ // Build the full script that sources the wrapper and runs the command
+ let mut script = String::new();
+ script.push_str("set -e\n"); // Exit on error
+ script.push_str(&format!("export WORKTRUNK_BIN='{}'\n", wt_bin.display()));
+ script.push_str(&format!(
+ "export WORKTRUNK_CONFIG_PATH='{}'\n",
+ repo.test_config_path().display()
+ ));
+ script.push_str("export CLICOLOR_FORCE=1\n"); // Force colors for snapshot testing
+
+ // Source the wrapper
+ script.push_str(&wrapper_script);
+ script.push_str("\n");
+
+ // Run the command
+ script.push_str("wt ");
+ script.push_str(subcommand);
+ for arg in args {
+ script.push_str(" ");
+ // Quote arguments with spaces
+ if arg.contains(' ') {
+ script.push_str("'");
+ script.push_str(arg);
+ script.push_str("'");
+ } else {
+ script.push_str(arg);
+ }
+ }
+ script.push_str("\n");
+
+ // Execute through bash
+ let mut cmd = Command::new("bash");
+ cmd.arg("-c").arg(&script).current_dir(repo.root_path());
+
+ // Configure git environment
+ repo.clean_cli_env(&mut cmd);
+
+ let output = cmd.output().expect("Failed to execute bash wrapper");
+
+ // Combine stdout and stderr as users would see in a terminal
+ let mut combined = String::from_utf8_lossy(&output.stdout).to_string();
+ if !output.stderr.is_empty() {
+ combined.push_str(&String::from_utf8_lossy(&output.stderr));
+ }
+
+ // Check that command succeeded
+ if !output.status.success() {
+ panic!(
+ "Command failed with exit code: {:?}\nOutput:\n{}",
+ output.status.code(),
+ combined
+ );
+ }
+
+ combined
+}
+
+/// Assert that output contains no directive leaks
+fn assert_no_directive_leaks(output: &str) {
+ assert!(
+ !output.contains("__WORKTRUNK_CD__"),
+ "Output contains leaked __WORKTRUNK_CD__ directive:\n{}",
+ output
+ );
+ assert!(
+ !output.contains("__WORKTRUNK_EXEC__"),
+ "Output contains leaked __WORKTRUNK_EXEC__ directive:\n{}",
+ output
+ );
+}
+
+#[test]
+fn test_switch_create_through_wrapper_no_directive_leak() {
+ let repo = TestRepo::new();
+ repo.commit("Initial commit");
+
+ let output = exec_through_bash_wrapper(&repo, "switch", &["--create", "feature"]);
+
+ // The critical assertion: directives must never appear in user-facing output
+ assert_no_directive_leaks(&output);
+
+ // Normalize paths in output for snapshot testing
+ let normalized = regex::Regex::new(r"/private/var/folders/[^/]+/[^/]+/T/\.tmp[^/]+")
+ .unwrap()
+ .replace_all(&output, "[TMPDIR]");
+
+ // Snapshot the output for regression testing
+ assert_snapshot!(normalized.as_ref());
+}
+
+#[test]
+fn test_switch_with_post_start_command_no_directive_leak() {
+ let repo = TestRepo::new();
+ repo.commit("Initial commit");
+
+ // Configure a post-start command in the project config (this is where the bug manifests)
+ // The println! in handle_post_start_commands causes directive leaks
+ let config_dir = repo.root_path().join(".config");
+ fs::create_dir_all(&config_dir).expect("Failed to create .config dir");
+ fs::write(
+ config_dir.join("wt.toml"),
+ r#"post-start-command = "echo 'test command executed'""#,
+ )
+ .expect("Failed to write project config");
+
+ repo.commit("Add post-start command");
+
+ // Pre-approve the command in user config
+ fs::write(
+ repo.test_config_path(),
+ r#"worktree-path = "../{main-worktree}.{branch}"
+
+[[approved-commands]]
+project = "test-repo"
+command = "echo 'test command executed'"
+"#,
+ )
+ .expect("Failed to write user config");
+
+ let output = exec_through_bash_wrapper(&repo, "switch", &["--create", "feature-with-hooks"]);
+
+ // The critical assertion: directives must never appear in user-facing output
+ // This is where the bug occurs - "πŸ”„ Starting (background):" is printed with println!
+ // which causes it to concatenate with the directive
+ assert_no_directive_leaks(&output);
+
+ // Normalize paths in output for snapshot testing
+ let normalized = regex::Regex::new(r"/private/var/folders/[^/]+/[^/]+/T/\.tmp[^/]+")
+ .unwrap()
+ .replace_all(&output, "[TMPDIR]");
+
+ // Snapshot the output
+ assert_snapshot!(normalized.as_ref());
+}
+
+#[test]
+fn test_switch_with_execute_through_wrapper() {
+ let repo = TestRepo::new();
+ repo.commit("Initial commit");
+
+ // Use --force to skip approval prompt in tests
+ let output = exec_through_bash_wrapper(
+ &repo,
+ "switch",
+ &[
+ "--create",
+ "test-exec",
+ "--execute",
+ "echo executed",
+ "--force",
+ ],
+ );
+
+ // No directives should leak
+ assert_no_directive_leaks(&output);
+
+ // The executed command output should appear
+ assert!(
+ output.contains("executed"),
+ "Execute command output missing"
+ );
+
+ // Normalize paths in output for snapshot testing
+ let normalized = regex::Regex::new(r"/private/var/folders/[^/]+/[^/]+/T/\.tmp[^/]+")
+ .unwrap()
+ .replace_all(&output, "[TMPDIR]");
+
+ // Snapshot the output
+ assert_snapshot!(normalized.as_ref());
+}
+
+#[test]
+fn test_remove_through_wrapper_no_directive_leak() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+
+ // Create a worktree to remove
+ repo.add_worktree("to-remove", "to-remove");
+
+ let output = exec_through_bash_wrapper(&repo, "remove", &["to-remove"]);
+
+ // No directives should leak
+ assert_no_directive_leaks(&output);
+
+ // Normalize paths in output for snapshot testing
+ let normalized = regex::Regex::new(r"/private/var/folders/[^/]+/[^/]+/T/\.tmp[^/]+")
+ .unwrap()
+ .replace_all(&output, "[TMPDIR]");
+
+ // Snapshot the output
+ assert_snapshot!(normalized.as_ref());
+}
+
+#[test]
+fn test_merge_through_wrapper_no_directive_leak() {
+ let mut repo = TestRepo::new();
+ repo.commit("Initial commit");
+
+ // Create a feature branch
+ repo.add_worktree("feature", "feature");
+
+ let output = exec_through_bash_wrapper(&repo, "merge", &["main"]);
+
+ // No directives should leak
+ assert_no_directive_leaks(&output);
+
+ // Normalize paths in output for snapshot testing
+ let normalized = regex::Regex::new(r"/private/var/folders/[^/]+/[^/]+/T/\.tmp[^/]+")
+ .unwrap()
+ .replace_all(&output, "[TMPDIR]");
+
+ // Snapshot the output
+ assert_snapshot!(normalized.as_ref());
+}
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__merge_through_wrapper_no_directive_leak.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__merge_through_wrapper_no_directive_leak.snap
new file mode 100644
index 000000000..257f059b0
--- /dev/null
+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__merge_through_wrapper_no_directive_leak.snap
@@ -0,0 +1,5 @@
+---
+source: tests/integration_tests/shell_wrapper.rs
+expression: output
+---
+Already on main, nothing to merge
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__remove_through_wrapper_no_directive_leak.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__remove_through_wrapper_no_directive_leak.snap
new file mode 100644
index 000000000..822ddf544
--- /dev/null
+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__remove_through_wrapper_no_directive_leak.snap
@@ -0,0 +1,5 @@
+---
+source: tests/integration_tests/shell_wrapper.rs
+expression: output
+---
+Removed worktree for to-remove
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_create_through_wrapper_no_directive_leak.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_create_through_wrapper_no_directive_leak.snap
new file mode 100644
index 000000000..b66a41aa2
--- /dev/null
+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_create_through_wrapper_no_directive_leak.snap
@@ -0,0 +1,5 @@
+---
+source: tests/integration_tests/shell_wrapper.rs
+expression: normalized.as_ref()
+---
+Created new worktree for feature at [TMPDIR]/test-repo.feature
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_with_execute_through_wrapper.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_with_execute_through_wrapper.snap
new file mode 100644
index 000000000..884eb3b3b
--- /dev/null
+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_with_execute_through_wrapper.snap
@@ -0,0 +1,6 @@
+---
+source: tests/integration_tests/shell_wrapper.rs
+expression: normalized.as_ref()
+---
+Created new worktree for test-exec at [TMPDIR]/test-repo.test-exec
+executed
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_with_post_start_command_no_directive_leak.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_with_post_start_command_no_directive_leak.snap
new file mode 100644
index 000000000..97233a8db
--- /dev/null
+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__switch_with_post_start_command_no_directive_leak.snap
@@ -0,0 +1,5 @@
+---
+source: tests/integration_tests/shell_wrapper.rs
+expression: normalized.as_ref()
+---
+Created new worktree for feature-with-hooks at [TMPDIR]/test-repo.feature-with-hooks
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_and_squash.snap b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_and_squash.snap
index ba9e41004..29becd2bb 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_and_squash.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_and_squash.snap
@@ -12,12 +12,13 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_COMMIT_GENERATION__ARGS: "fix: update file 1 content"
WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpRCPkNs/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpjf00t9/test-config.toml
---
success: true
exit_code: 0
@@ -26,6 +27,7 @@ exit_code: 0
πŸ”„ Committing uncommitted changes...
πŸ”„ Generating commit message...
  WIP: Auto-commit before merge
+
βœ… Committed changes
πŸ”„ Squashing 3 commits into one...
πŸ”„ Generating squash commit message...
@@ -35,6 +37,7 @@ exit_code: 0
  - feat: add file 1
  - feat: add file 2
  - WIP: Auto-commit before merge
+
βœ… Squashed 3 commits into one
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_deterministic.snap b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_deterministic.snap
index 828ef5ca3..66c40758d 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_deterministic.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_deterministic.snap
@@ -11,10 +11,11 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpR2o3kf/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfVoqsS/test-config.toml
---
success: true
exit_code: 0
@@ -23,6 +24,7 @@ exit_code: 0
πŸ”„ Committing uncommitted changes...
πŸ”„ Generating commit message...
  WIP: Auto-commit before merge
+
βœ… Committed changes
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 2 commits to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_llm.snap b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_llm.snap
index 52134e882..1001cdf5a 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_llm.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_llm.snap
@@ -11,12 +11,13 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_COMMIT_GENERATION__ARGS: "fix: improve auth validation logic"
WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpk7hPdt/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpyISaoT/test-config.toml
---
success: true
exit_code: 0
@@ -25,6 +26,7 @@ exit_code: 0
πŸ”„ Committing uncommitted changes...
πŸ”„ Generating commit message...
  WIP: Auto-commit before merge
+
βœ… Committed changes
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 2 commits to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_message.snap b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_message.snap
index f40165d4c..d1618b915 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_message.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_message.snap
@@ -13,12 +13,13 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_COMMIT_GENERATION__ARGS: "feat: complete user dashboard"
WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpVLVTF2/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpNYiicC/test-config.toml
---
success: true
exit_code: 0
@@ -27,6 +28,7 @@ exit_code: 0
πŸ”„ Committing uncommitted changes...
πŸ”„ Generating commit message...
  WIP: Auto-commit before merge
+
βœ… Committed changes
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 2 commits to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap b/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
index 0707b0435..defd2fa11 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
@@ -11,10 +11,11 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfoGsi5/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpbdVTnG/test-config.toml
---
success: true
exit_code: 0
@@ -23,6 +24,7 @@ exit_code: 0
πŸ”„ Committing uncommitted changes...
πŸ”„ Generating commit message...
  WIP: Auto-commit before merge
+
βœ… Committed changes
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap
index b49281eb6..4e1a1781d 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap
@@ -12,10 +12,11 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpEaSRwb/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpUHOAYS/test-config.toml
---
success: true
exit_code: 0
@@ -31,10 +32,11 @@ exit_code: 0
βœ… Pushed to main (1 commit, 1 file, +1) 
πŸ”„ Running post-merge command cmd:
+  exit 1
+
🟑 Command cmd failed: Command failed with exit code: exit status: 1
πŸ”„ Cleaning up worktree...
βœ… Returned to primary at [REPO]
----- stderr -----
-  exit 1
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap
index 4f72306dc..f1ea7e888 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_named.snap
@@ -12,10 +12,11 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp7n7ThK/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpopy8pE/test-config.toml
---
success: true
exit_code: 0
@@ -31,11 +32,13 @@ exit_code: 0
βœ… Pushed to main (1 commit, 1 file, +1) 
πŸ”„ Running post-merge command deploy:
+  echo 'Deploying branch feature' > deploy.txt
+
πŸ”„ Running post-merge command notify:
+  echo 'Merge to main complete' > notify.txt
+
πŸ”„ Cleaning up worktree...
βœ… Returned to primary at [REPO]
----- stderr -----
-  echo 'Deploying branch feature' > deploy.txt
-  echo 'Merge to main complete' > notify.txt
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_success.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_success.snap
index b5276fd9a..4af969ce4 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_success.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_success.snap
@@ -12,10 +12,11 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpf378rG/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpmdFOXu/test-config.toml
---
success: true
exit_code: 0
@@ -31,9 +32,10 @@ exit_code: 0
βœ… Pushed to main (1 commit, 1 file, +1) 
πŸ”„ Running post-merge command cmd:
+  echo 'merged feature to main' > post-merge-ran.txt
+
πŸ”„ Cleaning up worktree...
βœ… Returned to primary at [REPO]
----- stderr -----
-  echo 'merged feature to main' > post-merge-ran.txt
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_combined_output.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_combined_output.snap
index c224b5d42..0dc798304 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_combined_output.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_combined_output.snap
@@ -6,10 +6,12 @@ Exit code: 0
πŸ”„ Validating merge...
πŸ”„ Running pre-merge command first:
  echo 'STDOUT-FROM-FIRST' && echo 'STDERR-FROM-FIRST' >&2
+
STDOUT-FROM-FIRST
STDERR-FROM-FIRST
πŸ”„ Running pre-merge command second:
  echo 'STDOUT-FROM-SECOND' && echo 'STDERR-FROM-SECOND' >&2
+
STDOUT-FROM-SECOND
STDERR-FROM-SECOND
πŸ”„ Rebasing onto main...
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap
index fe5315245..017a5f023 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap
@@ -12,19 +12,21 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpV2uaP9/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpbUwp56/test-config.toml
---
success: false
exit_code: 1
----- stdout -----
πŸ”„ Validating merge...
πŸ”„ Running pre-merge command cmd:
+  exit 1
+
----- stderr -----
-  exit 1
❌ Pre-merge command failed: cmd
Command failed with exit code: exit status: 1
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_named.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_named.snap
index a1ac8fdb3..e568740a3 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_named.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_named.snap
@@ -12,18 +12,25 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpp8Gpxi/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp3zDJ9v/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Validating merge...
πŸ”„ Running pre-merge command format:
+  exit 0
+
πŸ”„ Running pre-merge command lint:
+  exit 0
+
πŸ”„ Running pre-merge command test:
+  exit 0
+
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
@@ -38,6 +45,3 @@ exit_code: 0
βœ… Returned to primary at [REPO]
----- stderr -----
-  exit 0
-  exit 0
-  exit 0
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_stdout_stderr_ordering.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_stdout_stderr_ordering.snap
index 9fa914301..0e3c6511b 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_stdout_stderr_ordering.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_stdout_stderr_ordering.snap
@@ -12,17 +12,22 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpYmlz8I/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpSpc2U4/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Validating merge...
πŸ”„ Running pre-merge command check1:
+  [PROJECT_ROOT]/tests/fixtures/mixed-output.sh check1 3
+
πŸ”„ Running pre-merge command check2:
+  [PROJECT_ROOT]/tests/fixtures/mixed-output.sh check2 3
+
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
@@ -37,8 +42,6 @@ exit_code: 0
βœ… Returned to primary at [REPO]
----- stderr -----
-  [PROJECT_ROOT]/tests/fixtures/mixed-output.sh
-  check1 3
[check1] stdout line 1
[check1] stderr line 1
[check1] stdout line 2
@@ -47,8 +50,6 @@ exit_code: 0
[check1] stderr line 3
[check1] stdout complete
[check1] stderr complete
-  [PROJECT_ROOT]/tests/fixtures/mixed-output.sh
-  check2 3
[check2] stdout line 1
[check2] stderr line 1
[check2] stdout line 2
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_success.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_success.snap
index d4b171047..41717053e 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_success.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_success.snap
@@ -12,16 +12,19 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpv4BWZG/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpomJvjp/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Validating merge...
πŸ”„ Running pre-merge command cmd:
+  exit 0
+
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
@@ -36,4 +39,3 @@ exit_code: 0
βœ… Returned to primary at [REPO]
----- stderr -----
-  exit 0
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
index 7e25fe72d..e12f1ad3f 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
@@ -12,10 +12,11 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpeMdAoH/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpzHUxKY/test-config.toml
---
success: true
exit_code: 0
@@ -29,6 +30,7 @@ exit_code: 0
  - feat: add file 1
  - fix: update logic
  - docs: update readme
+
βœ… Squashed 3 commits into one
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
index 74077021c..629fff671 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
@@ -12,11 +12,12 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_COMMIT_GENERATION__COMMAND: nonexistent-llm-command
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpB5jNHK/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpsbfQSr/test-config.toml
---
success: true
exit_code: 0
@@ -29,6 +30,7 @@ exit_code: 0
  Combined commits:
  - feat: new feature
  - fix: bug fix
+
βœ… Squashed 2 commits into one
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
index 842cb3be4..0c7842942 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
@@ -12,13 +12,14 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_COMMIT_GENERATION__ARGS__0: "-c"
WORKTRUNK_COMMIT_GENERATION__ARGS__1: "cat >/dev/null && echo 'feat: implement user authentication system'"
WORKTRUNK_COMMIT_GENERATION__COMMAND: sh
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpEpPXtB/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpmCA23B/test-config.toml
---
success: true
exit_code: 0
@@ -31,6 +32,7 @@ exit_code: 0
  Combined commits:
  - feat: add authentication
  - fix: handle edge case
+
βœ… Squashed 2 commits into one
πŸ”„ Rebasing onto main...
πŸ”„ Pushing 1 commit to main @ [SHA]
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 23d958c7a..5c105d4a5 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
@@ -12,20 +12,23 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp8Rk5dB/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp3ewwWu/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Executing (post-create):
+  echo 'Setup done' > setup.txt
+
πŸ”„ Starting (background):
+  sleep 0.5 && echo 'Server running' > server.txt
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'Setup done' > setup.txt
-  sleep 0.5 && echo 'Server running' > server.txt
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap b/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap
index 734b26d5d..9e1a13f66 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__execute_with_post_start.snap
@@ -14,16 +14,18 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpvNFfsG/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpIjv95o/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Starting (background):
+  echo 'Background task' > background.txt
+
βœ… Created new worktree for feature at [REPO].feature
----- stderr -----
-  echo 'Background task' > background.txt
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 d93e90739..bd3d0f29b 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
@@ -12,19 +12,21 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp4TBmYZ/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpTCxwzC/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Executing (post-create):
+  exit 1
+
🟑 Command cmd failed: Command failed with exit code: exit status: 1
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  exit 1
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiple_commands_array.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiple_commands_array.snap
index 5349b1064..b2877cd7d 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiple_commands_array.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiple_commands_array.snap
@@ -12,22 +12,25 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpBMuWNX/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpsmacvw/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Executing (post-create):
+  echo 'First'
+
πŸ”„ Executing (post-create):
+  echo 'Second'
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'First'
First
-  echo 'Second'
Second
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 9480999c2..ce03d0b02 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
@@ -12,22 +12,25 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpyGUlO6/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpggIPgR/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Executing (post-create):
+  echo 'Installing deps'
+
πŸ”„ Executing (post-create):
+  echo 'Running setup'
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'Installing deps'
Installing deps
-  echo 'Running setup'
Running setup
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 b05b82735..c412b050f 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
@@ -12,19 +12,21 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpYRpRMc/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpZMSoxL/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Executing (post-create):
+  echo 'Setup complete'
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'Setup complete'
Setup complete
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 4df5cc89c..51e771670 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
@@ -12,28 +12,33 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJGXiTv/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpEM2Izh/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Executing (post-create):
-πŸ”„ Executing (post-create):
-πŸ”„ Executing (post-create):
-πŸ”„ Executing (post-create):
-βœ… Created new worktree for feature/test at [REPO].feature-test
-
-To enable automatic cd, run: wt configure-shell
-
------ stderr -----
  echo 'Repo: test-repo' > info.txt
+
+πŸ”„ Executing (post-create):
  echo 'Branch: feature-test' >> info.txt
+
+πŸ”„ Executing (post-create):
  echo 'Worktree:
  [REPO].feature-test'
  >> info.txt
+
+πŸ”„ Executing (post-create):
  echo 'Root:
  [REPO]'
  >> info.txt
+
+βœ… Created new worktree for feature/test at [REPO].feature-test
+
+To enable automatic cd, run: wt configure-shell
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap
index 81cd2ac6c..f2e93bb9a 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_complex_shell.snap
@@ -12,20 +12,22 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpQ1olMT/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpEEHf2b/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Starting (background):
+  echo 'line1
+  line2
+  line3' | grep line2 > filtered.txt
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'line1
-  line2
-  line3' | grep line2 > filtered.txt
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap
index 68077ec5a..860a5bc14 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_invalid_command.snap
@@ -12,18 +12,20 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpeVTM7X/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpB7MUEg/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Starting (background):
+  echo 'unclosed quote
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'unclosed quote
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap
index b2ca5b071..fd58f8a99 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_log_captures_output.snap
@@ -12,18 +12,20 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpD72dMX/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp49oM06/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Starting (background):
+  echo 'stdout output' && echo 'stderr output' >&2
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'stdout output' && echo 'stderr output' >&2
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap
index a482e13c9..ed4f9a29b 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_multiple_background.snap
@@ -12,20 +12,23 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpZRNtMz/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmplFMHEn/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Starting (background):
+  echo 'Task 1 running' > task1.txt
+
πŸ”„ Starting (background):
+  echo 'Task 2 running' > task2.txt
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'Task 1 running' > task1.txt
-  echo 'Task 2 running' > task2.txt
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap
index 86aa70a15..38694eef1 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_separate_logs.snap
@@ -12,22 +12,26 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpUAadHA/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpURXoki/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Starting (background):
+  echo 'TASK1_OUTPUT'
+
πŸ”„ Starting (background):
+  echo 'TASK2_OUTPUT'
+
πŸ”„ Starting (background):
+  echo 'TASK3_OUTPUT'
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  echo 'TASK1_OUTPUT'
-  echo 'TASK2_OUTPUT'
-  echo 'TASK3_OUTPUT'
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap
index 682840746..9f838301e 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap
@@ -12,18 +12,20 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpo7xtAh/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJzrX60/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
πŸ”„ Starting (background):
+  sleep 1 && echo 'Background task done' > background.txt
+
βœ… Created new worktree for feature at [REPO].feature
To enable automatic cd, run: wt configure-shell
----- stderr -----
-  sleep 1 && echo 'Background task done' > background.txt