Skip to content

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

Add blank line before prompts, not after (#874)

Maximilian Roosa684fecb2146
diff --git a/.claude/skills/writing-user-outputs/SKILL.md b/.claude/skills/writing-user-outputs/SKILL.md
index 948f62a53..181e7bd0e 100644
--- a/.claude/skills/writing-user-outputs/SKILL.md
+++ b/.claude/skills/writing-user-outputs/SKILL.md
@@ -463,31 +463,34 @@ parsing.
Specific rules:
- **No leading/trailing blanks** — Start immediately, end cleanly
-- **One blank after prompts** — Separate user input from results
+- **Blank before prompts, not after** — Signal "pause, something interactive is
+ happening" before the prompt; once the user responds, output flows continuously
- **One blank between phases** — When a sub-operation completes and a different
operation begins, add a blank line to visually separate them
- **Never double blanks** — One blank line maximum between elements
-**Phase separation:** A "phase" is a logically distinct operation. Examples:
-
-- First-time config setup completing → main command workflow starting
-- Interactive prompt with results → unrelated command output
-- One complete sub-operation → another unrelated sub-operation
+**Prompt spacing:** A blank line before the prompt signals "something different
+is about to happen" and gives the user's eye a natural stopping point before they
+need to read and respond. No blank line after — the user's input ends the
+interactive moment and subsequent output flows naturally from that decision.
```
-❯ Configure claude for commit messages? [y/N/?] y
+◎ Detecting available LLM tools...
+❯ Configure claude for commit messages? [y/N/?] y
✓ Added to user config:
┃ [commit.generation]
┃ command = "..."
↳ View config: wt config show
- ← Blank line separates phases
+
▲ Auto-staging 1 untracked path:
┃ a
◎ Generating commit message...
```
-The blank line signals "that's done, now we're doing something else."
+**Phase separation:** A "phase" is a logically distinct operation. The blank
+line between the hint and warning above signals "config setup is done, now we're
+doing the main command workflow."
**Interactive prompts** must flush stderr before blocking on stdin:
diff --git a/src/commands/command_approval.rs b/src/commands/command_approval.rs
index ed2827375..1dd330593 100644
--- a/src/commands/command_approval.rs
+++ b/src/commands/command_approval.rs
@@ -122,7 +122,6 @@ fn prompt_for_batch_approval(commands: &[&HookCommand], project_id: &str) -> any
"{WARNING_SYMBOL} <yellow><bold>{project_name}</> needs approval to execute <bold>{count}</> command{plural}:</>"
)
);
- eprintln!();
for cmd in commands {
// Format as: {phase} {bold}{name}{bold:#}:
@@ -144,7 +143,8 @@ fn prompt_for_batch_approval(commands: &[&HookCommand], project_id: &str) -> any
return Err(GitError::NotInteractive.into());
}
- // Flush stderr before showing prompt to ensure all output is visible
+ // Blank line before prompt for visual separation
+ worktrunk::styling::eprintln!();
stderr().flush()?;
eprint!(
@@ -156,7 +156,8 @@ fn prompt_for_batch_approval(commands: &[&HookCommand], project_id: &str) -> any
let mut response = String::new();
io::stdin().read_line(&mut response)?;
- eprintln!();
+ // End the prompt line on stderr (user's input went to stdin, not stderr)
+ worktrunk::styling::eprintln!();
Ok(response.trim().eq_ignore_ascii_case("y"))
}
diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rs
index c310fe650..f63f32b2f 100644
--- a/src/commands/configure_shell.rs
+++ b/src/commands/configure_shell.rs
@@ -736,6 +736,8 @@ pub fn prompt_for_install(
/// Prompt user for yes/no confirmation (simple [y/N] prompt)
fn prompt_yes_no() -> Result<bool, String> {
+ // Blank line before prompt for visual separation
+ eprintln!();
eprint!(
"{} ",
prompt_message(color_print::cformat!("Proceed? <bold>[y/N]</>"))
@@ -747,6 +749,7 @@ fn prompt_yes_no() -> Result<bool, String> {
.read_line(&mut input)
.map_err(|e| e.to_string())?;
+ // End the prompt line on stderr (user's input went to stdin, not stderr)
eprintln!();
let response = input.trim().to_lowercase();
diff --git a/src/output/commit_generation.rs b/src/output/commit_generation.rs
index e391df0b0..b06ae411b 100644
--- a/src/output/commit_generation.rs
+++ b/src/output/commit_generation.rs
@@ -4,7 +4,7 @@
//! attempt a commit without configuration. Detects available tools (claude, codex)
//! and offers to auto-configure the recommended settings.
-use std::io::{self, IsTerminal, Write};
+use std::io::{self, IsTerminal};
use color_print::cformat;
use worktrunk::config::UserConfig;
@@ -137,9 +137,6 @@ pub fn prompt_commit_generation(config: &mut UserConfig) -> anyhow::Result<bool>
let config_preview = format!("[commit.generation]\ncommand = {formatted_command}");
// Show prompt with preview on ?
- eprintln!();
- io::stderr().flush()?;
-
let response = prompt_yes_no_preview(
&cformat!("Configure <bold>{tool}</> for commit messages?"),
|| {
diff --git a/src/output/prompt.rs b/src/output/prompt.rs
index 4173b3ab3..bd27e0e0d 100644
--- a/src/output/prompt.rs
+++ b/src/output/prompt.rs
@@ -41,6 +41,9 @@ pub fn prompt_yes_no_preview(
prompt_text: &str,
show_preview: impl Fn(),
) -> io::Result<PromptResponse> {
+ // Blank line before first prompt for visual separation
+ worktrunk::styling::eprintln!();
+
loop {
eprint!(
"{}",
@@ -51,19 +54,19 @@ pub fn prompt_yes_no_preview(
let mut input = String::new();
io::stdin().read_line(&mut input)?;
+ // End the prompt line on stderr (user's input went to stdin, not stderr)
+ worktrunk::styling::eprintln!();
+
let response = input.trim().to_lowercase();
match response.as_str() {
"y" | "yes" => {
- worktrunk::styling::eprintln!();
return Ok(PromptResponse::Accepted);
}
"?" => {
- worktrunk::styling::eprintln!();
show_preview();
// Loop back to prompt again
}
_ => {
- worktrunk::styling::eprintln!();
return Ok(PromptResponse::Declined);
}
}
diff --git a/src/output/shell_integration.rs b/src/output/shell_integration.rs
index a6b44e152..b35e938f0 100644
--- a/src/output/shell_integration.rs
+++ b/src/output/shell_integration.rs
@@ -423,7 +423,6 @@ pub fn prompt_shell_integration(
// TTY + first time: Show interactive prompt
// Accepting installs for all shells with config files (same as `wt config shell install`)
- eprintln!();
let confirmed = prompt_for_install(
&scan.configured,
&scan.completion_results,
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 9201bd304..d5ab1a331 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
@@ -5,9 +5,9 @@ expression: "&output"
y
▲ repo needs approval to execute 1 command:
-
○ post-create:
  echo 'test command'
+
❯ Allow and remember? [y/N]
◎ Running post-create project hook @ _REPO_.test-approve:
  echo 'test command'
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
index 8b2848d52..48941b003 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
@@ -5,9 +5,9 @@ expression: "&output"
n
▲ repo needs approval to execute 1 command:
-
○ post-create:
  echo 'test command'
+
❯ Allow and remember? [y/N]
○ Commands declined, continuing worktree creation
✓ Created branch test-decline from main and worktree @ _REPO_.test-decline
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 c3ce153a7..73e620df3 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
@@ -5,11 +5,11 @@ expression: "&output"
y
▲ repo needs approval to execute 2 commands:
-
○ post-create first:
  echo 'First command'
○ post-create third:
  echo 'Third command'
+
❯ Allow and remember? [y/N]
◎ Running post-create project:first @ _REPO_.test-mixed-accept:
  echo 'First command'
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
index 9d72c2670..0a5605895 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
@@ -5,11 +5,11 @@ expression: "&output"
n
▲ repo needs approval to execute 2 commands:
-
○ post-create first:
  echo 'First command'
○ post-create third:
  echo 'Third command'
+
❯ Allow and remember? [y/N]
○ Commands declined, continuing worktree creation
✓ Created branch test-mixed-decline from main and worktree @ _REPO_.test-mixed-decline
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 1edd21aef..8da2510f4 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
@@ -5,13 +5,13 @@ expression: "&output"
y
▲ repo needs approval to execute 3 commands:
-
○ post-create first:
  echo 'First command'
○ post-create second:
  echo 'Second command'
○ post-create third:
  echo 'Third command'
+
❯ Allow and remember? [y/N]
◎ Running post-create project:first @ _REPO_.test-multi:
  echo 'First command'
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 990445f90..6eefc7061 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
@@ -5,13 +5,13 @@ expression: "&output"
y
▲ repo needs approval to execute 3 commands:
-
○ post-create install:
  echo 'Installing dependencies...'
○ post-create build:
  echo 'Building project...'
○ post-create test:
  echo 'Running tests...'
+
❯ Allow and remember? [y/N]
◎ Running post-create project:install @ _REPO_.test-named:
  echo 'Installing dependencies...'
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 23b8eec7c..2e9b7fb89 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
@@ -5,9 +5,9 @@ expression: "&output"
y
▲ repo needs approval to execute 1 command:
-
○ post-create:
  echo 'test command'
+
❯ 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.
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_remove_decline.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_remove_decline.snap
index d918305c5..d86bd6d6f 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_remove_decline.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_remove_decline.snap
@@ -5,9 +5,9 @@ expression: "&output"
n
▲ repo needs approval to execute 1 command:
-
○ pre-remove:
  echo 'pre-remove hook'
+
❯ Allow and remember? [y/N]
○ Commands declined, continuing removal
◎ Removing to-remove worktree & branch in background (ancestor of main, ⊂)
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap
index 7d5270797..efeca084d 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap
@@ -37,7 +37,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 1 command:
-
○ post-create:
  echo 'test command'
✗ Cannot prompt for approval in non-interactive environment
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap
index b73f7fd39..93020c11b 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ repo needs approval to execute 2 commands:
-
○ post-create first:
  echo 'First command'
○ post-create third:
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap
index 0fe04a921..6c388280d 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 4 commands:
-
○ post-create branch:
  echo 'Branch: {{ branch }}'
○ post-create worktree:
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap
index 4820d1dd7..1f5292c72 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 3 commands:
-
○ post-create install:
  echo 'Installing dependencies...'
○ post-create build:
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap
index e377061df..099b5e106 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 1 command:
-
○ post-create:
  echo 'Worktree path: {{ worktree_path }}'
✗ Cannot prompt for approval in non-interactive environment
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap b/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap
index b73f7fd39..93020c11b 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ repo needs approval to execute 2 commands:
-
○ post-create first:
  echo 'First command'
○ post-create third:
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_all_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_all_requires_approval.snap
index 7e0924acc..efd678871 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_all_requires_approval.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_all_requires_approval.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 2 commands:
-
○ pre-merge test:
  echo 'Running project test'
○ pre-merge lint:
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_requires_approval.snap
index f1c6660b0..890a07bba 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_requires_approval.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__project_prefix_requires_approval.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 1 command:
-
○ pre-merge test:
  echo 'Running project test'
✗ Cannot prompt for approval in non-interactive environment
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap
index 9889050ec..ee3bb4f6b 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 1 command:
-
○ post-merge:
  echo 'Post-merge cleanup for {{ branch }}'
✗ Cannot prompt for approval in non-interactive environment
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap
index cdb3766fd..2cc967648 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 1 command:
-
○ pre-merge:
  echo 'Running pre-merge checks on {{ branch }}'
✗ Cannot prompt for approval in non-interactive environment
diff --git a/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_second_run.snap b/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_second_run.snap
index 0b9c27076..94679d2ec 100644
--- a/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_second_run.snap
+++ b/tests/snapshots/integration__integration_tests__approval_ui__yes_does_not_save_approvals_second_run.snap
@@ -7,7 +7,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 1 command:
-
○ post-create:
  echo 'test command' > output.txt
✗ Cannot prompt for approval in non-interactive environment
diff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_already_approved.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_already_approved.snap
index 1b26a0e4c..767dc5fe5 100644
--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_already_approved.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_already_approved.snap
@@ -37,7 +37,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 1 command:
-
○ post-create:
  echo 'test'
✗ Cannot prompt for approval in non-interactive environment
diff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap
index f83f26cb3..185c9f560 100644
--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap
+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap
@@ -38,7 +38,6 @@ exit_code: 1
----- stderr -----
▲ origin needs approval to execute 1 command:
-
○ post-create:
  echo 'test'
✗ Cannot prompt for approval in non-interactive environment
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_approval_prompt.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_approval_prompt.snap
index 0d6e997c5..5c92d9d60 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_approval_prompt.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__readme_example_approval_prompt.snap
@@ -5,11 +5,11 @@ expression: prompt_only
n
▲ repo needs approval to execute 3 commands:
-
○ post-create install:
echo 'Installing dependencies...'
○ post-create build:
echo 'Building project...'
○ post-create test:
echo 'Running tests...'
+
❯ Allow and remember? [y/N]