Skip to content

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

fix: disable clap text wrapping to preserve markdown tables (#436)

Maximilian Roos87ba49a907bd
diff --git a/src/cli.rs b/src/cli.rs
index 86c862ea4..5be5a8df3 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -134,6 +134,9 @@ pub enum OutputFormat {
#[command(disable_help_subcommand = true)]
#[command(styles = help_styles())]
#[command(arg_required_else_help = true)]
+// Disable clap's text wrapping - we handle wrapping in the markdown renderer.
+// This prevents clap from breaking markdown tables by wrapping their rows.
+#[command(term_width = 0)]
#[command(after_long_help = "\
Getting started
diff --git a/src/main.rs b/src/main.rs
index c567681d3..d6bbd0d92 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -214,12 +214,13 @@ fn maybe_handle_help_with_pager() -> bool {
ErrorKind::DisplayHelp | ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand => {
// err.render() returns a StyledStr containing ANSI codes.
// Use .ansi() to preserve them; .to_string() strips ANSI codes.
- let mut help = err.render().ansi().to_string();
+ let clap_output = err.render().ansi().to_string();
- // Render markdown sections to ANSI, wrapping prose to terminal width
- // (tables stay unwrapped to preserve column alignment)
+ // Render markdown sections (tables, code blocks, prose) with proper wrapping.
+ // Since we disabled clap's wrapping above, our renderer controls all line breaks.
let width = worktrunk::styling::get_terminal_width();
- help = md_help::render_markdown_in_help_with_width(&help, Some(width));
+ let help =
+ md_help::render_markdown_in_help_with_width(&clap_output, Some(width));
// show_help_in_pager checks if stdout or stderr is a TTY.
// If neither is a TTY (e.g., `wt --help &>file`), it skips the pager.
diff --git a/src/md_help.rs b/src/md_help.rs
index 3f4760343..ce8ce536d 100644
--- a/src/md_help.rs
+++ b/src/md_help.rs
@@ -105,6 +105,7 @@ pub fn render_markdown_in_help_with_width(help: &str, width: Option<usize>) -> S
// Prose text - wrap if width is specified
let formatted = render_inline_formatting(line);
if let Some(w) = width {
+ // wrap_styled_text preserves leading indentation on continuation lines
for wrapped_line in wrap_styled_text(&formatted, w) {
result.push_str(&wrapped_line);
result.push('\n');
@@ -711,4 +712,34 @@ mod tests {
// Should NOT have separator line
assert!(!result.contains('─'));
}
+
+ #[test]
+ fn test_render_markdown_in_help_table_wrapping() {
+ // Test the full render_markdown_in_help_with_width function
+ // which is what actually runs on the help text
+ let help = r#"### Other environment variables
+
+| Variable | Purpose |
+|----------|---------|
+| `WORKTRUNK_BIN` | Override binary path for shell wrappers (useful for testing dev builds) |
+| WORKTRUNK_CONFIG_PATH | Override user config file location |
+| `WORKTRUNK_MAX_CONCURRENT_COMMANDS` | Max parallel git commands (default: 32). Lower if hitting resource limits. |
+| NO_COLOR | Disable colored output (standard) |
+"#;
+ let rendered = render_markdown_in_help_with_width(help, Some(80));
+
+ // Check for pipe characters
+ for line in rendered.lines() {
+ assert!(
+ !line.trim_start().starts_with("| "),
+ "Line should not start with '| ': {:?}",
+ line
+ );
+ assert!(
+ !line.trim_end().ends_with(" |"),
+ "Line should not end with ' |': {:?}",
+ line
+ );
+ }
+ }
}
diff --git a/src/styling/format.rs b/src/styling/format.rs
index 6aa90d972..d5f19b413 100644
--- a/src/styling/format.rs
+++ b/src/styling/format.rs
@@ -146,18 +146,37 @@ pub fn format_with_gutter(content: &str, max_width: Option<usize>) -> String {
/// IMPORTANT: wrap_ansi only restores foreground colors on continuation lines,
/// not text attributes like dim. We detect this and prepend dim (\x1b[2m) to
/// continuation lines that start with a color code, ensuring consistent dimming.
+///
+/// Leading indentation is preserved: if the input starts with spaces, continuation
+/// lines will have the same indentation (wrapping happens within the remaining width).
pub fn wrap_styled_text(styled: &str, max_width: usize) -> Vec<String> {
if max_width == 0 {
return vec![styled.to_string()];
}
+ // Detect leading indentation (spaces before any content or ANSI codes)
+ let leading_spaces = styled.chars().take_while(|c| *c == ' ').count();
+ let indent = " ".repeat(leading_spaces);
+ let content = &styled[leading_spaces..];
+
+ // Handle whitespace-only or empty content
+ if content.is_empty() {
+ return vec![styled.to_string()];
+ }
+
+ // Calculate width for content (excluding indent)
+ let content_width = max_width.saturating_sub(leading_spaces);
+ if content_width < 10 {
+ // Width too narrow for meaningful wrapping
+ return vec![styled.to_string()];
+ }
+
+ // wrap_ansi returns a string with '\n' at wrap points, preserving ANSI styles
// Preserve leading whitespace (wrap_ansi's default trims it)
let options = wrap_ansi::WrapOptions::builder()
.trim_whitespace(false)
.build();
-
- // wrap_ansi returns a string with '\n' at wrap points, preserving ANSI styles
- let wrapped = wrap_ansi::wrap_ansi(styled, max_width, Some(options));
+ let wrapped = wrap_ansi::wrap_ansi(content, content_width, Some(options));
if wrapped.is_empty() {
return vec![String::new()];
@@ -189,12 +208,14 @@ pub fn wrap_styled_text(styled: &str, max_width: usize) -> Vec<String> {
// We restore dim for lines that start with a color code. This is safe
// because format_bash_with_gutter_impl always starts lines with dim,
// so any wrapped continuation should also be dimmed.
- if i > 0 && trimmed.starts_with("\x1b[3") {
- // Prepend dim before the color code
- result.push(format!("\x1b[2m{trimmed}"));
+ let with_dim = if i > 0 && trimmed.starts_with("\x1b[3") {
+ format!("\x1b[2m{trimmed}")
} else {
- result.push(trimmed.to_owned());
- }
+ trimmed.to_owned()
+ };
+
+ // Add the original indentation to all lines
+ result.push(format!("{indent}{with_dim}"));
}
result
@@ -425,6 +446,24 @@ mod tests {
assert_eq!(result, vec![" "]);
}
+ #[test]
+ fn test_wrap_styled_text_preserves_indent_on_wrap() {
+ // Force wrapping by using a narrow width - text should wrap and preserve indent
+ let result = wrap_styled_text(
+ " This is a longer text that should wrap across multiple lines",
+ 40,
+ );
+ assert!(result.len() > 1, "Should have wrapped");
+ // All lines should have the 10-space indent
+ for line in &result {
+ assert!(
+ line.starts_with(" "),
+ "Line should start with 10 spaces: {:?}",
+ line
+ );
+ }
+ }
+
#[test]
fn test_format_with_gutter_basic() {
let result = format_with_gutter("hello", Some(80));
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
index ac8631caf..f57acb25f 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
@@ -146,7 +146,7 @@ When project hooks run for the first time, Worktrunk prompts for approval. Appro
[projects."my-project"]
approved-commands = ["npm ci", "npm test"]
-Manage approvals with wt hook approvals add to review and pre-approve commands, and wt hook approvals clear to reset (add --global to clear all
+Manage approvals with wt hook approvals add to review and pre-approve commands, and wt hook approvals clear to reset (add --global to clear all
projects).
User hooks
@@ -185,7 +185,7 @@ The [list] section adds a URL column to wt list:
[list]
url = "http://localhost:{{ branch | hash_port }}"
-URLs are dimmed when the port isn't listening. The template supports {{ branch }} with filters hash_port (port 10000-19999) and sanitize
+URLs are dimmed when the port isn't listening. The template supports {{ branch }} with filters hash_port (port 10000-19999) and sanitize
(filesystem-safe).
Shell integration
@@ -213,8 +213,7 @@ All user config options can be overridden with environment variables using the 
Naming convention
-Config keys use kebab-case (worktree-path), while env vars use SCREAMING_SNAKE_CASE (WORKTRUNK_WORKTREE_PATH). The conversion happens
-automatically.
+Config keys use kebab-case (worktree-path), while env vars use SCREAMING_SNAKE_CASE (WORKTRUNK_WORKTREE_PATH). The conversion happens automatically.
For nested config sections, use double underscores to separate levels:
diff --git a/tests/snapshots/integration__integration_tests__help__help_list_long.snap b/tests/snapshots/integration__integration_tests__help__help_list_long.snap
index 3bba67680..9e4de8d05 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list_long.snap
@@ -11,6 +11,7 @@ info:
GIT_EDITOR: ""
RUST_LOG: warn
SOURCE_DATE_EPOCH: "1735776000"
+ TERM: alacritty
WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
---
@@ -62,9 +63,8 @@ Usage: wt list [OPTIONS]
Show all worktrees with their status. The table includes uncommitted changes, divergence from the default branch and remote, and optional CI status.
-The table renders progressively: branch names, paths, and commit hashes appear immediately, then status, divergence, and other columns fill in as
-background git operations complete. With --full, CI status fetches from the network — the table displays instantly and CI fills in as results
-arrive.
+The table renders progressively: branch names, paths, and commit hashes appear immediately, then status, divergence, and other columns fill in as
+background git operations complete. With --full, CI status fetches from the network — the table displays instantly and CI fills in as results arrive.
Examples
@@ -117,8 +117,8 @@ The CI column shows GitHub/GitLab pipeline status:
⚠ yellow Fetch error (rate limit, network)
(blank) No upstream or no PR/MR
-CI indicators are clickable links to the PR or pipeline page. Any CI dot appears dimmed when there are unpushed local changes (stale status). PRs/MRs
-are checked first, then branch workflows/pipelines for branches with an upstream. Local-only branches show blank. Results are cached for 30-60
+CI indicators are clickable links to the PR or pipeline page. Any CI dot appears dimmed when there are unpushed local changes (stale status). PRs/MRs
+are checked first, then branch workflows/pipelines for branches with an upstream. Local-only branches show blank. Results are cached for 30-60
seconds; use wt config state to view or clear.
Status symbols
diff --git a/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap b/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap
index 7b7090b9b..e9d558772 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap
@@ -11,6 +11,7 @@ info:
GIT_EDITOR: ""
RUST_LOG: warn
SOURCE_DATE_EPOCH: "1735776000"
+ TERM: alacritty
WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
---
@@ -46,7 +47,7 @@ Usage: wt list [OPTIONS]
Show fast info immediately, update with slow info
Displays local data (branches, paths, status) first, then updates with
- remote data (CI, upstream) as it arrives. Auto-enabled for TTY.
+ remote data (CI, upstream) as it arrives. Auto-enabled for TTY.
-h, --help
Print help (see a summary with '-h')
@@ -61,12 +62,12 @@ Usage: wt list [OPTIONS]
-v, --verbose
Show commands and debug info
-Show all worktrees with their status. The table includes uncommitted changes,
+Show all worktrees with their status. The table includes uncommitted changes,
divergence from the default branch and remote, and optional CI status.
-The table renders progressively: branch names, paths, and commit hashes appear
-immediately, then status, divergence, and other columns fill in as background
-git operations complete. With --full, CI status fetches from the network — the
+The table renders progressively: branch names, paths, and commit hashes appear
+immediately, then status, divergence, and other columns fill in as background
+git operations complete. With --full, CI status fetches from the network — the
table displays instantly and CI fills in as results arrive.
Examples
@@ -104,8 +105,8 @@ Output as JSON for scripting:
Age Time since last commit
Message Last commit message (truncated)
-Note: main↕ and main…± refer to the default branch (header label stays
-main for compactness). main…± uses a merge-base (three-dot) diff.
+Note: main↕ and main…± refer to the default branch (header label stays main for
+compactness). main…± uses a merge-base (three-dot) diff.
CI status
@@ -122,14 +123,14 @@ The CI column shows GitHub/GitLab pipeline status:
(blank) No upstream or no PR/MR
CI indicators are clickable links to the PR or pipeline page. Any CI dot appears
-dimmed when there are unpushed local changes (stale status). PRs/MRs are checked
-first, then branch workflows/pipelines for branches with an upstream. Local-only
-branches show blank. Results are cached for 30-60 seconds; use wt config state
-to view or clear.
+ dimmed when there are unpushed local changes (stale status). PRs/MRs are
+checked first, then branch workflows/pipelines for branches with an upstream.
+Local-only branches show blank. Results are cached for 30-60 seconds; use wt
+config state to view or clear.
Status symbols
-The Status column has multiple subcolumns. Within each, only the first matching
+The Status column has multiple subcolumns. Within each, only the first matching
symbol is shown (listed in priority order):
Subcolumn Symbol Meaning
@@ -146,22 +147,22 @@ symbol is shown (listed in priority order):
⊟ Prunable (directory missing)
⊞ Locked worktree
Default branch ^ Is the default branch
-| | ✗ | Would conflict if merged to the default branch (with --full,
-includes uncommitted changes) |
- _ Same commit as the default branch, clean
- – Same commit as the default branch, uncommitted changes
-| | ⊂ | Content integrated into the default
-branch or target |
- ↕ Diverged from the default branch
- ↑ Ahead of the default branch
- ↓ Behind the default branch
- Remote | In sync with remote
- ⇅ Diverged from remote
- ⇡ Ahead of remote
- ⇣ Behind remote
-
-Rows are dimmed when safe to delete (_ same
-commit with clean working tree or ⊂ content integrated).
+ ✗ Would conflict if merged to the default branch (with
+ --full, includes uncommitted changes)
+ _ Same commit as the default branch, clean
+ – Same commit as the default branch, uncommitted
+ changes
+ ⊂ Content integrated into the default branch or target
+ ↕ Diverged from the default branch
+ ↑ Ahead of the default branch
+ ↓ Behind the default branch
+ Remote | In sync with remote
+ ⇅ Diverged from remote
+ ⇡ Ahead of remote
+ ⇣ Behind remote
+
+Rows are dimmed when safe to delete (_ same commit with clean working tree or ⊂
+content integrated).
JSON output
@@ -180,8 +181,7 @@ Query structured data with --format=json:
wt list --format=json | jq '.[] | select(.main.ahead > 0)'

# Integrated branches (ready to clean up)
- wt list --format=json | jq '.[] | select(.main_state == "integrated" or
- .main_state == "empty")'
+ wt list --format=json | jq '.[] | select(.main_state == "integrated" or .main_state == "empty")'
Fields:
@@ -195,23 +195,24 @@ Query structured data with --format=json:
working_tree object Working tree state (see below)
main_state string Relation to the default branch (see below)
integration_reason string Why branch is integrated (see below)
-| operation_state | string | "conflicts", "rebase", or "merge" (absent
-when clean) |
-| main | object | Relationship to the default branch (see below, absent when
-is_main) |
-| remote | object | Tracking branch info (see below, absent when no tracking)
- ─────────── ─────── ────────────────────────────────────────
- worktree object Worktree metadata (see below)
- is_main boolean Is the main worktree
- is_current boolean Is the current worktree
- is_previous boolean Previous worktree from wt switch
- ci object CI status (see below, absent when no CI)
-| url | string | Dev server URL from project config (absent when not
-configured) |
-| url_active | boolean | Whether the URL's port is listening (absent when not
-configured) |
- statusline string Pre-formatted status with ANSI colors
- symbols string Raw status symbols without colors (e.g., "!?↓")
+ operation_state string "conflicts", "rebase", or "merge" (absent
+ when clean)
+ main object Relationship to the default branch (see
+ below, absent when is_main)
+ remote object Tracking branch info (see below, absent when
+ no tracking)
+ worktree object Worktree metadata (see below)
+ is_main boolean Is the main worktree
+ is_current boolean Is the current worktree
+ is_previous boolean Previous worktree from wt switch
+ ci object CI status (see below, absent when no CI)
+ url string Dev server URL from project config (absent
+ when not configured)
+ url_active boolean Whether the URL's port is listening (absent
+ when not configured)
+ statusline string Pre-formatted status with ANSI colors
+ symbols string Raw status symbols without colors (e.g.,
+ "!?↓")
commit object
@@ -224,16 +225,15 @@ configured) |
working_tree object
- Field Type Description
- ───────── ─────── ───────────────────────────────────────
- staged boolean Has staged files
- modified boolean Has modified files (unstaged)
- untracked boolean Has untracked files
- renamed boolean Has renamed files
- deleted boolean Has deleted files
- diff object Lines changed vs HEAD: {added, deleted}
-| diff_vs_main | object | Lines changed vs the default branch: {added,
-deleted} |
+ Field Type Description
+ ──────────── ─────── ─────────────────────────────────────────────────────
+ staged boolean Has staged files
+ modified boolean Has modified files (unstaged)
+ untracked boolean Has untracked files
+ renamed boolean Has renamed files
+ deleted boolean Has deleted files
+ diff object Lines changed vs HEAD: {added, deleted}
+ diff_vs_main object Lines changed vs the default branch: {added, deleted}
main object
@@ -254,12 +254,12 @@ deleted} |
worktree object
- Field Type Description
- ───── ──── ───────────
-| state | string | "branch_worktree_mismatch", "prunable", "locked"
-(absent when normal) |
- reason string Reason for locked/prunable state
- detached boolean HEAD is detached
+ Field Type Description
+ ──────── ─────── ───────────────────────────────────────────────────────────
+ state string "branch_worktree_mismatch", "prunable", "locked" (absent
+ when normal)
+ reason string Reason for locked/prunable state
+ detached boolean HEAD is detached
ci object
@@ -274,19 +274,19 @@ deleted} |
These values describe relation to the default branch.
-"is_main" "would_conflict" "empty" "same_commit" "integrated"
-"diverged" "ahead" "behind"
+"is_main" "would_conflict" "empty" "same_commit" "integrated" "diverged" "ahead"
+ "behind"
integration_reason values
-When main_state == "integrated": "ancestor" "trees_match"
-"no_added_changes" "merge_adds_nothing"
+When main_state == "integrated": "ancestor" "trees_match" "no_added_changes"
+"merge_adds_nothing"
ci.status values
"passed" "running" "failed" "conflicts" "no-ci" "error"
-Missing a field that would be generally useful? Open an issue at
+Missing a field that would be generally useful? Open an issue at
https://github.com/max-sixty/worktrunk.
See also
diff --git a/tests/snapshots/integration__integration_tests__help__help_md_merge.snap b/tests/snapshots/integration__integration_tests__help__help_md_merge.snap
index f87f6a40e..56901e0cf 100644
--- a/tests/snapshots/integration__integration_tests__help__help_md_merge.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_md_merge.snap
@@ -109,30 +109,23 @@ wt merge --no-commit
`wt merge` runs these steps:
-1. **Squash** — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use `--stage` to
-control what gets staged: `all` (default), `tracked`, or `none`. A backup ref is saved to `refs/wt-backup/<branch>`. With `--no-squash`, uncommitted
-changes become a separate commit and individual commits are preserved.
+1. **Squash** — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use `--stage` to control what gets staged: `all` (default), `tracked`, or `none`. A backup ref is saved to `refs/wt-backup/<branch>`. With `--no-squash`, uncommitted changes become a separate commit and individual commits are preserved.
2. **Rebase** — Rebases onto target if behind. Skipped if already up-to-date. Conflicts abort immediately.
3. **Pre-merge hooks** — Hooks run after rebase, before merge. Failures abort. See [wt hook](@/hook.md).
4. **Merge** — Fast-forward merge to the target branch. Non-fast-forward merges are rejected.
5. **Pre-remove hooks** — Hooks run before removing worktree. Failures abort.
-6. **Cleanup** — Removes the worktree and branch. Use `--no-remove` to keep the worktree. When already on the target branch or in the main worktree,
-the worktree is preserved.
+6. **Cleanup** — Removes the worktree and branch. Use `--no-remove` to keep the worktree. When already on the target branch or in the main worktree, the worktree is preserved.
7. **Post-merge hooks** — Hooks run after cleanup. Failures are logged but don't abort.
-Use `--no-commit` to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless `--no-rebase` is
-passed. Useful after preparing commits manually with `wt step`. Requires a clean working tree.
+Use `--no-commit` to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless `--no-rebase` is passed. Useful after preparing commits manually with `wt step`. Requires a clean working tree.
## Local CI
-For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changes
-instead of fewer large ones.
+For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changes instead of fewer large ones.
-Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: it
-guaranteed validation happened. `wt merge` brings that guarantee local.
+Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: it guaranteed validation happened. `wt merge` brings that guarantee local.
-The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run `wt merge`, move on. Pre-merge
-hooks validate before merging — if they pass, the branch goes to the default branch and the worktree cleans up.
+The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run `wt merge`, move on. Pre-merge hooks validate before merging — if they pass, the branch goes to the default branch and the worktree cleans up.
```toml
[pre-merge]
diff --git a/tests/snapshots/integration__integration_tests__help__help_merge_long.snap b/tests/snapshots/integration__integration_tests__help__help_merge_long.snap
index 69e9cb5eb..85d7037cf 100644
--- a/tests/snapshots/integration__integration_tests__help__help_merge_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_merge_long.snap
@@ -100,29 +100,29 @@ Skip committing/squashing (rebase still runs unless --no-rebase):
wt merge runs these steps:
-1. Squash — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use --stage to
-control what gets staged: all (default), tracked, or none. A backup ref is saved to refs/wt-backup/<branch>. With --no-squash, uncommitted
-changes become a separate commit and individual commits are preserved.
+1. Squash — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use --stage to control
+what gets staged: all (default), tracked, or none. A backup ref is saved to refs/wt-backup/<branch>. With --no-squash, uncommitted changes become a
+separate commit and individual commits are preserved.
2. Rebase — Rebases onto target if behind. Skipped if already up-to-date. Conflicts abort immediately.
3. Pre-merge hooks — Hooks run after rebase, before merge. Failures abort. See wt hook.
4. Merge — Fast-forward merge to the target branch. Non-fast-forward merges are rejected.
5. Pre-remove hooks — Hooks run before removing worktree. Failures abort.
-6. Cleanup — Removes the worktree and branch. Use --no-remove to keep the worktree. When already on the target branch or in the main worktree,
-the worktree is preserved.
+6. Cleanup — Removes the worktree and branch. Use --no-remove to keep the worktree. When already on the target branch or in the main worktree, the
+worktree is preserved.
7. Post-merge hooks — Hooks run after cleanup. Failures are logged but don't abort.
-Use --no-commit to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless --no-rebase is
+Use --no-commit to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless --no-rebase is
passed. Useful after preparing commits manually with wt step. Requires a clean working tree.
Local CI
-For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changes
+For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changes
instead of fewer large ones.
-Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: it
+Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: it
guaranteed validation happened. wt merge brings that guarantee local.
-The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run wt merge, move on. Pre-merge
+The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run wt merge, move on. Pre-merge
hooks validate before merging — if they pass, the branch goes to the default branch and the worktree cleans up.
[pre-merge]
diff --git a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
index f811bf010..478847051 100644
--- a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
@@ -85,7 +85,7 @@ Force-delete an unmerged branch:
Branch cleanup
-By default, branches are deleted when merging them would add nothing. This works with squash-merge and rebase workflows where commit history differs
+By default, branches are deleted when merging them would add nothing. This works with squash-merge and rebase workflows where commit history differs
but file changes match.
Worktrunk checks five conditions (in order of cost):
@@ -96,8 +96,8 @@ Worktrunk checks five conditions (in order of cost):
4. Trees match — Branch tree SHA equals target tree SHA. Shows ⊂.
5. Merge adds nothing — Simulated merge produces the same tree as target. Handles squash-merged branches where target has advanced. Shows ⊂.
-The "same commit" check uses the local default branch; for other checks, target means the default branch, or its upstream (e.g., origin/main)
-when strictly ahead.
+The "same commit" check uses the local default branch; for other checks, target means the default branch, or its upstream (e.g., origin/main) when
+strictly ahead.
Branches showing _ or ⊂ are dimmed as safe to delete.
@@ -105,8 +105,8 @@ Use -D to force-delete branches with unmerged changes. Use --no-dele
Background removal
-Removal runs in the background by default (returns immediately). Logs are written to .git/wt-logs/{branch}-remove.log. Use --no-background to run
-in the foreground.
+Removal runs in the background by default (returns immediately). Logs are written to .git/wt-logs/{branch}-remove.log. Use --no-background to run in
+the foreground.
Shortcuts
diff --git a/tests/snapshots/integration__integration_tests__help__help_switch_long.snap b/tests/snapshots/integration__integration_tests__help__help_switch_long.snap
index cddaee85f..327fdd1c6 100644
--- a/tests/snapshots/integration__integration_tests__help__help_switch_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_switch_long.snap
@@ -11,6 +11,7 @@ info:
GIT_EDITOR: ""
RUST_LOG: warn
SOURCE_DATE_EPOCH: "1735776000"
+ TERM: alacritty
WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
---
@@ -47,15 +48,15 @@ Usage: wt switch [OPTIONS] <BRANCH> [--
Command to run after switch
Replaces the wt process with the command after switching, giving it full terminal control. Useful for launching editors, AI agents, or other
- interactive tools.
+ interactive tools.
Especially useful with shell aliases:
alias wsc='wt switch --create -x claude'
wsc feature-branch -- 'Fix GH #322'
- 
- Then wsc feature-branch creates the worktree and launches Claude Code. Arguments after -- are passed to the command, so wsc feature -- 'Fix
- GH #322' runs claude 'Fix GH #322', starting Claude with a prompt.
+
+ Then wsc feature-branch creates the worktree and launches Claude Code. Arguments after -- are passed to the command, so wsc feature -- 'Fix
+ GH #322' runs claude 'Fix GH #322', starting Claude with a prompt.
-y, --yes
Skip approval prompts
@@ -81,7 +82,7 @@ Usage: wt switch [OPTIONS] <BRANCH> [--
Change directory to a worktree, creating one if needed.
-Worktrees are addressed by branch name; paths are computed from a template. Unlike git switch, this navigates between worktrees rather than changing
+Worktrees are addressed by branch name; paths are computed from a template. Unlike git switch, this navigates between worktrees rather than changing
branches in place.
Examples