Skip to content

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

feat: add `wt step diff` command (#1074)

Maximilian Roos87ae623c7838
diff --git a/Cargo.toml b/Cargo.toml
index 070825da0..bef23ea04 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -122,6 +122,7 @@ fs2 = "0.4.3"
sanitize-filename = "0.6.0"
schemars = { version = "1.2.1", features = ["derive"] }
+tempfile = "3.25"
wait-timeout = "0.2"
[target.'cfg(unix)'.dependencies]
diff --git a/docs/content/step.md b/docs/content/step.md
index 5f1ed28eb..ddf45b372 100644
--- a/docs/content/step.md
+++ b/docs/content/step.md
@@ -33,6 +33,7 @@ wt step push
- `squash` — Squash all branch commits into one with [LLM-generated message](@/llm-commits.md)
- `rebase` — Rebase onto target branch
- `push` — Fast-forward target to current branch
+- `diff` — Show all changes since branching (committed, staged, unstaged, untracked)
- `copy-ignored` — Copy gitignored files between worktrees
- `for-each` — [experimental] Run a command in every worktree
@@ -56,6 +57,7 @@ Usage: <b><span class=c>wt step</span></b> <span class=c>[OPTIONS]</span> <span
<b><span class=c>squash</span></b> Squash commits since branching
<b><span class=c>push</span></b> Fast-forward target to current branch
<b><span class=c>rebase</span></b> Rebase onto target
+ <b><span class=c>diff</span></b> Show all changes since branching
<b><span class=c>copy-ignored</span></b> Copy gitignored files to another worktree
<b><span class=c>for-each</span></b> [experimental] Run command in each worktree
<b><span class=c>relocate</span></b> [experimental] Move worktrees to expected paths
diff --git a/skills/worktrunk/reference/step.md b/skills/worktrunk/reference/step.md
index 24bec709a..c25e6fa6d 100644
--- a/skills/worktrunk/reference/step.md
+++ b/skills/worktrunk/reference/step.md
@@ -25,6 +25,7 @@ wt step push
- `squash` — Squash all branch commits into one with [LLM-generated message](https://worktrunk.dev/llm-commits/)
- `rebase` — Rebase onto target branch
- `push` — Fast-forward target to current branch
+- `diff` — Show all changes since branching (committed, staged, unstaged, untracked)
- `copy-ignored` — Copy gitignored files between worktrees
- `for-each` — [experimental] Run a command in every worktree
@@ -42,6 +43,7 @@ Usage: <b><span class=c>wt step</span></b> <span class=c>[OPTIONS]</span> <span
<b><span class=c>squash</span></b> Squash commits since branching
<b><span class=c>push</span></b> Fast-forward target to current branch
<b><span class=c>rebase</span></b> Rebase onto target
+ <b><span class=c>diff</span></b> Show all changes since branching
<b><span class=c>copy-ignored</span></b> Copy gitignored files to another worktree
<b><span class=c>for-each</span></b> [experimental] Run command in each worktree
<b><span class=c>relocate</span></b> [experimental] Move worktrees to expected paths
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index ea416d7be..7a0bc59ea 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -1016,6 +1016,7 @@ wt step push
- `squash` — Squash all branch commits into one with [LLM-generated message](@/llm-commits.md)
- `rebase` — Rebase onto target branch
- `push` — Fast-forward target to current branch
+- `diff` — Show all changes since branching (committed, staged, unstaged, untracked)
- `copy-ignored` — Copy gitignored files between worktrees
- `for-each` — [experimental] Run a command in every worktree
diff --git a/src/cli/step.rs b/src/cli/step.rs
index bbf9f7e17..82f6d0f84 100644
--- a/src/cli/step.rs
+++ b/src/cli/step.rs
@@ -169,6 +169,53 @@ wt step rebase develop # Rebase onto develop
target: Option<String>,
},
+ /// Show all changes since branching
+ ///
+ /// Includes committed, staged, unstaged, and untracked files.
+ #[command(
+ after_long_help = r#"Shows all changes that `wt merge` would include: committed, staged, unstaged, and untracked files — in a single diff against the merge base.
+
+## Extra git diff arguments
+
+Arguments after `--` are forwarded to `git diff`:
+
+```console
+wt step diff -- --stat
+wt step diff -- --name-only
+wt step diff -- -- '*.rs'
+```
+
+The diff is pipeable to tools like `delta`:
+
+```console
+wt step diff | delta
+```
+
+## How it works
+
+Equivalent to:
+
+```console
+GIT_INDEX_FILE=/tmp/idx git read-tree --empty
+GIT_INDEX_FILE=/tmp/idx git add --intent-to-add .
+GIT_INDEX_FILE=/tmp/idx git diff $(git merge-base HEAD $(wt config state default-branch))
+```
+
+`git diff` ignores untracked files. `git add --intent-to-add .` registers them in the index without staging their content, making them visible to `git diff`. This runs against a temporary empty index so the real one is never modified.
+"#
+ )]
+ Diff {
+ /// Target branch
+ ///
+ /// Defaults to default branch.
+ #[arg(add = crate::completion::branch_value_completer())]
+ target: Option<String>,
+
+ /// Extra arguments forwarded to `git diff`
+ #[arg(last = true)]
+ extra_args: Vec<String>,
+ },
+
/// Copy gitignored files to another worktree
///
/// Eliminates cold starts by copying build caches and dependencies.
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index acb39b228..a80ec81c7 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -41,7 +41,7 @@ pub(crate) use merge::{MergeOptions, handle_merge};
pub(crate) use select::handle_select;
pub(crate) use step_commands::{
RebaseResult, SquashResult, handle_rebase, handle_squash, step_commit, step_copy_ignored,
- step_relocate, step_show_squash_prompt,
+ step_diff, step_relocate, step_show_squash_prompt,
};
pub(crate) use worktree::{
OperationMode, handle_remove, handle_remove_current, is_worktree_at_expected_path,
diff --git a/src/commands/step_commands.rs b/src/commands/step_commands.rs
index c88b5c252..2bb2c11c9 100644
--- a/src/commands/step_commands.rs
+++ b/src/commands/step_commands.rs
@@ -5,6 +5,7 @@
//! - `handle_squash` - Squash commits into one
//! - `step_show_squash_prompt` - Show squash prompt without executing
//! - `handle_rebase` - Rebase onto target branch
+//! - `step_diff` - Show all changes since branching
//! - `step_copy_ignored` - Copy gitignored files matching .worktreeinclude
use std::fs;
@@ -470,6 +471,70 @@ pub fn handle_rebase(target: Option<&str>) -> anyhow::Result<RebaseResult> {
Ok(RebaseResult::Rebased)
}
+/// Handle `wt step diff` command
+///
+/// Shows all changes since branching from the target: committed, staged, unstaged,
+/// and untracked files in a single diff. Uses a temporary index to include untracked
+/// files without modifying the real git index.
+///
+/// TODO: consider adding `--stage` flag (all/tracked/none) like `step commit` to
+/// control which change types are included. `tracked` would skip the temp index,
+/// `none` would diff only committed changes.
+pub fn step_diff(target: Option<&str>, extra_args: &[String]) -> anyhow::Result<()> {
+ let repo = Repository::current()?;
+ let wt = repo.current_worktree();
+
+ // Get and validate target ref
+ let integration_target = repo.require_target_ref(target)?;
+
+ // Get merge base
+ let merge_base = repo
+ .merge_base("HEAD", &integration_target)?
+ .context("No common ancestor with target branch")?;
+
+ let current_branch = wt.branch()?.unwrap_or_else(|| "HEAD".to_string());
+
+ // Create an empty temporary index and register all working tree files with
+ // `git add -N .` so untracked files become visible to `git diff`.
+ let worktree_root = wt.root()?;
+
+ let temp_index = tempfile::NamedTempFile::new().context("Failed to create temporary index")?;
+ let temp_index_path = temp_index
+ .path()
+ .to_str()
+ .context("Temporary index path is not valid UTF-8")?;
+
+ // Initialize a valid empty index
+ Cmd::new("git")
+ .args(["read-tree", "--empty"])
+ .current_dir(&worktree_root)
+ .context(&current_branch)
+ .env("GIT_INDEX_FILE", temp_index_path)
+ .run()
+ .context("Failed to initialize temporary index")?;
+
+ // Register all working tree files as intent-to-add
+ Cmd::new("git")
+ .args(["add", "--intent-to-add", "."])
+ .current_dir(&worktree_root)
+ .context(&current_branch)
+ .env("GIT_INDEX_FILE", temp_index_path)
+ .run()
+ .context("Failed to register untracked files")?;
+
+ // Stream diff to stdout — git handles pager and coloring
+ let mut diff_args = vec!["diff".to_string(), merge_base];
+ diff_args.extend_from_slice(extra_args);
+ Cmd::new("git")
+ .args(&diff_args)
+ .current_dir(&worktree_root)
+ .context(&current_branch)
+ .env("GIT_INDEX_FILE", temp_index_path)
+ .stream()?;
+
+ Ok(())
+}
+
/// Handle `wt step copy-ignored` command
///
/// Copies gitignored files from a source worktree to a destination worktree.
diff --git a/src/main.rs b/src/main.rs
index ed3549b3e..567112bc3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -52,7 +52,7 @@ use commands::{
handle_remove, handle_remove_current, handle_show_theme, handle_squash, handle_state_clear,
handle_state_clear_all, handle_state_get, handle_state_set, handle_state_show, handle_switch,
handle_unconfigure_shell, resolve_worktree_arg, run_hook, step_commit, step_copy_ignored,
- step_for_each, step_relocate,
+ step_diff, step_for_each, step_relocate,
};
use output::handle_remove_output;
@@ -535,6 +535,7 @@ fn main() {
}
})
}
+ StepCommand::Diff { target, extra_args } => step_diff(target.as_deref(), &extra_args),
StepCommand::CopyIgnored {
from,
to,
diff --git a/tests/integration_tests/completion.rs b/tests/integration_tests/completion.rs
index b1d0d75f4..5132c1818 100644
--- a/tests/integration_tests/completion.rs
+++ b/tests/integration_tests/completion.rs
@@ -591,12 +591,13 @@ fn test_complete_step_subcommands(repo: TestRepo) {
subcommands.contains(&"copy-ignored"),
"Missing copy-ignored"
);
+ assert!(subcommands.contains(&"diff"), "Missing diff");
assert!(subcommands.contains(&"for-each"), "Missing for-each");
assert!(subcommands.contains(&"relocate"), "Missing relocate");
assert_eq!(
subcommands.len(),
- 7,
- "Should have exactly 7 step subcommands"
+ 8,
+ "Should have exactly 8 step subcommands"
);
}
diff --git a/tests/integration_tests/mod.rs b/tests/integration_tests/mod.rs
index e4612db29..277867d4d 100644
--- a/tests/integration_tests/mod.rs
+++ b/tests/integration_tests/mod.rs
@@ -55,6 +55,7 @@ pub mod snapshot_formatting_guard;
pub mod spacing_edge_cases;
pub mod statusline;
pub mod step_copy_ignored;
+pub mod step_diff;
pub mod step_relocate;
pub mod switch;
pub mod switch_picker;
diff --git a/tests/integration_tests/step_diff.rs b/tests/integration_tests/step_diff.rs
new file mode 100644
index 000000000..4eecdd4dd
--- /dev/null
+++ b/tests/integration_tests/step_diff.rs
@@ -0,0 +1,153 @@
+//! Integration tests for `wt step diff`
+
+use crate::common::{TestRepo, make_snapshot_cmd, repo, setup_snapshot_settings};
+use insta_cmd::assert_cmd_snapshot;
+use rstest::rstest;
+use std::fs;
+use std::path::Path;
+
+/// Helper: create a feature worktree with a commit ahead of main
+fn setup_feature_with_commit(repo: &mut TestRepo) -> std::path::PathBuf {
+ let feature_path = repo.add_worktree("feature");
+ fs::write(feature_path.join("feature.txt"), "feature content").unwrap();
+ repo.run_git_in(&feature_path, &["add", "feature.txt"]);
+ repo.run_git_in(&feature_path, &["commit", "-m", "Add feature file"]);
+ feature_path
+}
+
+/// No changes: worktree identical to merge base
+#[rstest]
+fn test_step_diff_no_changes(mut repo: TestRepo) {
+ let feature_path = repo.add_worktree("feature");
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "step",
+ &["diff"],
+ Some(&feature_path),
+ ));
+}
+
+/// Committed changes show full diff by default
+#[rstest]
+fn test_step_diff_committed_changes(mut repo: TestRepo) {
+ let feature_path = setup_feature_with_commit(&mut repo);
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "step",
+ &["diff"],
+ Some(&feature_path),
+ ));
+}
+
+/// Untracked files appear in diff
+#[rstest]
+fn test_step_diff_untracked_files(mut repo: TestRepo) {
+ let feature_path = repo.add_worktree("feature");
+ fs::write(feature_path.join("untracked.txt"), "untracked content").unwrap();
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "step",
+ &["diff"],
+ Some(&feature_path),
+ ));
+}
+
+/// All change types: committed + staged + unstaged + untracked
+#[rstest]
+fn test_step_diff_all_change_types(mut repo: TestRepo) {
+ let feature_path = setup_feature_with_commit(&mut repo);
+
+ // Staged change
+ fs::write(feature_path.join("staged.txt"), "staged content").unwrap();
+ repo.run_git_in(&feature_path, &["add", "staged.txt"]);
+
+ // Unstaged change (modify a tracked file)
+ fs::write(feature_path.join("feature.txt"), "modified content").unwrap();
+
+ // Untracked file
+ fs::write(feature_path.join("new.txt"), "new content").unwrap();
+
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "step",
+ &["diff"],
+ Some(&feature_path),
+ ));
+}
+
+/// Extra args are forwarded to git diff
+#[rstest]
+fn test_step_diff_extra_args(mut repo: TestRepo) {
+ let feature_path = setup_feature_with_commit(&mut repo);
+ fs::write(feature_path.join("untracked.txt"), "untracked content").unwrap();
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "step",
+ &["diff", "--", "--stat"],
+ Some(&feature_path),
+ ));
+}
+
+/// Real index is unchanged after running diff
+#[rstest]
+fn test_step_diff_index_unchanged(mut repo: TestRepo) {
+ let feature_path = repo.add_worktree("feature");
+ fs::write(feature_path.join("untracked.txt"), "content").unwrap();
+
+ // Get index state before
+ let index_before = get_git_status(&repo, &feature_path);
+
+ // Run step diff
+ let mut cmd = repo.wt_command();
+ cmd.args(["step", "diff"]).current_dir(&feature_path);
+ let output = cmd.output().unwrap();
+ assert!(output.status.success(), "step diff failed");
+
+ // Get index state after
+ let index_after = get_git_status(&repo, &feature_path);
+
+ assert_eq!(
+ index_before, index_after,
+ "Real git index was modified by step diff"
+ );
+}
+
+/// Explicit target branch
+#[rstest]
+fn test_step_diff_explicit_target(mut repo: TestRepo) {
+ let feature_path = setup_feature_with_commit(&mut repo);
+ let settings = setup_snapshot_settings(&repo);
+ let _guard = settings.bind_to_scope();
+
+ assert_cmd_snapshot!(make_snapshot_cmd(
+ &repo,
+ "step",
+ &["diff", "main"],
+ Some(&feature_path),
+ ));
+}
+
+fn get_git_status(repo: &TestRepo, dir: &Path) -> String {
+ let output = repo
+ .git_command()
+ .args(["status", "--porcelain"])
+ .current_dir(dir)
+ .output()
+ .unwrap();
+ String::from_utf8_lossy(&output.stdout).to_string()
+}
diff --git a/tests/snapshots/integration__integration_tests__help__help_step_long.snap b/tests/snapshots/integration__integration_tests__help__help_step_long.snap
index 371dfba0a..1f30923a4 100644
--- a/tests/snapshots/integration__integration_tests__help__help_step_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_step_long.snap
@@ -15,10 +15,12 @@ info:
RUST_LOG: warn
SHELL: ""
TERM: alacritty
+ WORKTRUNK_APPROVALS_PATH: /nonexistent/test/approvals.toml
WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml
WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
---
@@ -38,6 +40,7 @@ Usage: wt step [OPTIONS] <COMMAND>
squash Squash commits since branching
push Fast-forward target to current branch
rebase Rebase onto target
+ diff Show all changes since branching
copy-ignored Copy gitignored files to another worktree
for-each [experimental] Run command in each worktree
relocate [experimental] Move worktrees to expected paths
@@ -75,6 +78,7 @@ Manual merge workflow with review between steps:
- squash — Squash all branch commits into one with LLM-generated message
- rebase — Rebase onto target branch
- push — Fast-forward target to current branch
+- diff — Show all changes since branching (committed, staged, unstaged, untracked)
- copy-ignored — Copy gitignored files between worktrees
- for-each — [experimental] Run a command in every worktree
diff --git a/tests/snapshots/integration__integration_tests__help__help_step_short.snap b/tests/snapshots/integration__integration_tests__help__help_step_short.snap
index eb2e7b175..c35dc6ddb 100644
--- a/tests/snapshots/integration__integration_tests__help__help_step_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_step_short.snap
@@ -15,10 +15,12 @@ info:
RUST_LOG: warn
SHELL: ""
TERM: alacritty
+ WORKTRUNK_APPROVALS_PATH: /nonexistent/test/approvals.toml
WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml
WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
---
@@ -36,6 +38,7 @@ Usage: wt step [OPTIONS] <COMMAND>
squash Squash commits since branching
push Fast-forward target to current branch
rebase Rebase onto target
+ diff Show all changes since branching
copy-ignored Copy gitignored files to another worktree
for-each [experimental] Run command in each worktree
relocate [experimental] Move worktrees to expected paths
diff --git a/tests/snapshots/integration__integration_tests__step_diff__step_diff_all_change_types.snap b/tests/snapshots/integration__integration_tests__step_diff__step_diff_all_change_types.snap
new file mode 100644
index 000000000..2373166ea
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_diff__step_diff_all_change_types.snap
@@ -0,0 +1,66 @@
+---
+source: tests/integration_tests/step_diff.rs
+info:
+ program: wt
+ args:
+ - step
+ - diff
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+diff --git a/feature.txt b/feature.txt
+new file mode 100644
+index 0000000..268af4e
+--- /dev/null
++++ b/feature.txt
+@@ -0,0 +1 @@
++modified content
+/ No newline at end of file
+diff --git a/new.txt b/new.txt
+new file mode 100644
+index 0000000..47d2739
+--- /dev/null
++++ b/new.txt
+@@ -0,0 +1 @@
++new content
+/ No newline at end of file
+diff --git a/staged.txt b/staged.txt
+new file mode 100644
+index 0000000..cadfe6b
+--- /dev/null
++++ b/staged.txt
+@@ -0,0 +1 @@
++staged content
+/ No newline at end of file
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_diff__step_diff_committed_changes.snap b/tests/snapshots/integration__integration_tests__step_diff__step_diff_committed_changes.snap
new file mode 100644
index 000000000..da51d433b
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_diff__step_diff_committed_changes.snap
@@ -0,0 +1,50 @@
+---
+source: tests/integration_tests/step_diff.rs
+info:
+ program: wt
+ args:
+ - step
+ - diff
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+diff --git a/feature.txt b/feature.txt
+new file mode 100644
+index 0000000..47a4d0c
+--- /dev/null
++++ b/feature.txt
+@@ -0,0 +1 @@
++feature content
+/ No newline at end of file
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_diff__step_diff_explicit_target.snap b/tests/snapshots/integration__integration_tests__step_diff__step_diff_explicit_target.snap
new file mode 100644
index 000000000..d5e3c1028
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_diff__step_diff_explicit_target.snap
@@ -0,0 +1,51 @@
+---
+source: tests/integration_tests/step_diff.rs
+info:
+ program: wt
+ args:
+ - step
+ - diff
+ - main
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+diff --git a/feature.txt b/feature.txt
+new file mode 100644
+index 0000000..47a4d0c
+--- /dev/null
++++ b/feature.txt
+@@ -0,0 +1 @@
++feature content
+/ No newline at end of file
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_diff__step_diff_extra_args.snap b/tests/snapshots/integration__integration_tests__step_diff__step_diff_extra_args.snap
new file mode 100644
index 000000000..d0ab7520b
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_diff__step_diff_extra_args.snap
@@ -0,0 +1,47 @@
+---
+source: tests/integration_tests/step_diff.rs
+info:
+ program: wt
+ args:
+ - step
+ - diff
+ - "--"
+ - "--stat"
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ feature.txt | 1 +
+ untracked.txt | 1 +
+ 2 files changed, 2 insertions(+)
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_diff__step_diff_no_changes.snap b/tests/snapshots/integration__integration_tests__step_diff__step_diff_no_changes.snap
new file mode 100644
index 000000000..1d4f3a479
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_diff__step_diff_no_changes.snap
@@ -0,0 +1,42 @@
+---
+source: tests/integration_tests/step_diff.rs
+info:
+ program: wt
+ args:
+ - step
+ - diff
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_diff__step_diff_untracked_files.snap b/tests/snapshots/integration__integration_tests__step_diff__step_diff_untracked_files.snap
new file mode 100644
index 000000000..39b11c292
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__step_diff__step_diff_untracked_files.snap
@@ -0,0 +1,50 @@
+---
+source: tests/integration_tests/step_diff.rs
+info:
+ program: wt
+ args:
+ - step
+ - diff
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+diff --git a/untracked.txt b/untracked.txt
+new file mode 100644
+index 0000000..0fea02a
+--- /dev/null
++++ b/untracked.txt
+@@ -0,0 +1 @@
++untracked content
+/ No newline at end of file
+
+----- stderr -----