Skip to content

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

Show resolved template variables under `-v` for hooks (#2316)

Maximilian Rooseec3b24883d1
diff --git a/docs/content/config.md b/docs/content/config.md
index 7463d4887..599723ef1 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -494,8 +494,9 @@ Usage: <b><span class=c>wt config</span></b> <span class=c>[OPTIONS]</span> <spa
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -555,8 +556,9 @@ Usage: <b><span class=c>wt config show</span></b> <span class=c>[OPTIONS]</span>
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -606,8 +608,9 @@ Usage: <b><span class=c>wt config approvals</span></b> <span class=c>[OPTIONS]</
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -650,8 +653,9 @@ Usage: <b><span class=c>wt config alias</span></b> <span class=c>[OPTIONS]</span
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -725,8 +729,9 @@ Usage: <b><span class=c>wt config state</span></b> <span class=c>[OPTIONS]</span
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -783,8 +788,9 @@ Usage: <b><span class=c>wt config state default-branch</span></b> <span class=c>
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -888,8 +894,9 @@ Usage: <b><span class=c>wt config state logs</span></b> <span class=c>[OPTIONS]<
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -949,8 +956,9 @@ Usage: <b><span class=c>wt config state ci-status</span></b> <span class=c>[OPTI
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -1022,8 +1030,9 @@ Usage: <b><span class=c>wt config state marker</span></b> <span class=c>[OPTIONS
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -1097,8 +1106,9 @@ Usage: <b><span class=c>wt config state vars</span></b> <span class=c>[OPTIONS]<
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
diff --git a/docs/content/hook.md b/docs/content/hook.md
index fbadca69f..9de39f220 100644
--- a/docs/content/hook.md
+++ b/docs/content/hook.md
@@ -160,6 +160,8 @@ Some variables are conditional: `upstream` requires remote tracking; `base` only
sync = "{% if upstream %}git fetch && git rebase {{ upstream }}{% endif %}"
```
+Run any hook-firing command with `-v` to see the resolved variables for the actual invocation — each hook prints a `template variables:` block showing every in-scope variable and its value (`(unset)` for conditional vars that didn't populate, like `target_worktree_path` during `wt switch -`).
+
Variables use dot access and the `default` filter for missing keys. JSON object/array values are parsed automatically, so `{{ vars.config.port }}` works when the value is `{"port": 3000}`:
```toml
@@ -507,8 +509,9 @@ Usage: <b><span class=c>wt hook</span></b> <span class=c>[OPTIONS]</span> <span
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
diff --git a/docs/content/list.md b/docs/content/list.md
index f27542688..01bac4c68 100644
--- a/docs/content/list.md
+++ b/docs/content/list.md
@@ -281,8 +281,9 @@ Usage: <b><span class=c>wt list</span></b> <span class=c>[OPTIONS]</span>
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
diff --git a/docs/content/merge.md b/docs/content/merge.md
index bc4c39d74..61dad023c 100644
--- a/docs/content/merge.md
+++ b/docs/content/merge.md
@@ -146,8 +146,9 @@ Usage: <b><span class=c>wt merge</span></b> <span class=c>[OPTIONS]</span> <span
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
diff --git a/docs/content/remove.md b/docs/content/remove.md
index 1dedf9812..4125df228 100644
--- a/docs/content/remove.md
+++ b/docs/content/remove.md
@@ -133,8 +133,9 @@ Usage: <b><span class=c>wt remove</span></b> <span class=c>[OPTIONS]</span> <spa
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
diff --git a/docs/content/step.md b/docs/content/step.md
index 5c27a72ad..0880824c6 100644
--- a/docs/content/step.md
+++ b/docs/content/step.md
@@ -76,8 +76,9 @@ Usage: <b><span class=c>wt step</span></b> <span class=c>[OPTIONS]</span> <span
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -156,8 +157,9 @@ Usage: <b><span class=c>wt step commit</span></b> <span class=c>[OPTIONS]</span>
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -239,8 +241,9 @@ Usage: <b><span class=c>wt step squash</span></b> <span class=c>[OPTIONS]</span>
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -300,8 +303,9 @@ Usage: <b><span class=c>wt step diff</span></b> <span class=c>[OPTIONS]</span> <
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -435,8 +439,9 @@ Usage: <b><span class=c>wt step copy-ignored</span></b> <span class=c>[OPTIONS]<
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -513,8 +518,9 @@ Usage: <b><span class=c>wt step eval</span></b> <span class=c>[OPTIONS]</span> <
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -586,8 +592,9 @@ Usage: <b><span class=c>wt step for-each</span></b> <span class=c>[OPTIONS]</spa
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -663,8 +670,9 @@ Usage: <b><span class=c>wt step promote</span></b> <span class=c>[OPTIONS]</span
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -737,8 +745,9 @@ Usage: <b><span class=c>wt step prune</span></b> <span class=c>[OPTIONS]</span>
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
@@ -830,8 +839,9 @@ Usage: <b><span class=c>wt step relocate</span></b> <span class=c>[OPTIONS]</spa
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
diff --git a/docs/content/switch.md b/docs/content/switch.md
index f3b4f88c9..bf499b358 100644
--- a/docs/content/switch.md
+++ b/docs/content/switch.md
@@ -217,8 +217,9 @@ Usage: <b><span class=c>wt switch</span></b> <span class=c>[OPTIONS]</span> <spa
User config file path
<b><span class=c>-v</span></b>, <b><span class=c>--verbose</span></b><span class=c>...</span>
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
<b><span class=c>-y</span></b>, <b><span class=c>--yes</span></b>
Skip approval prompts
diff --git a/skills/worktrunk/reference/config.md b/skills/worktrunk/reference/config.md
index 3db3508d6..ad782cfcd 100644
--- a/skills/worktrunk/reference/config.md
+++ b/skills/worktrunk/reference/config.md
@@ -497,8 +497,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -560,8 +561,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -617,8 +619,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -666,8 +669,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -755,8 +759,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -815,8 +820,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -930,8 +936,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -991,8 +998,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -1063,8 +1071,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -1149,8 +1158,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/skills/worktrunk/reference/hook.md b/skills/worktrunk/reference/hook.md
index fbeafffa0..48fd2c950 100644
--- a/skills/worktrunk/reference/hook.md
+++ b/skills/worktrunk/reference/hook.md
@@ -151,6 +151,8 @@ Some variables are conditional: `upstream` requires remote tracking; `base` only
sync = "{% if upstream %}git fetch && git rebase {{ upstream }}{% endif %}"
```
+Run any hook-firing command with `-v` to see the resolved variables for the actual invocation — each hook prints a `template variables:` block showing every in-scope variable and its value (`(unset)` for conditional vars that didn't populate, like `target_worktree_path` during `wt switch -`).
+
Variables use dot access and the `default` filter for missing keys. JSON object/array values are parsed automatically, so `{{ vars.config.port }}` works when the value is `{"port": 3000}`:
```toml
@@ -501,8 +503,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/skills/worktrunk/reference/list.md b/skills/worktrunk/reference/list.md
index fda349c21..7f4641732 100644
--- a/skills/worktrunk/reference/list.md
+++ b/skills/worktrunk/reference/list.md
@@ -311,8 +311,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/skills/worktrunk/reference/merge.md b/skills/worktrunk/reference/merge.md
index a2b4f6d7a..2c14fe602 100644
--- a/skills/worktrunk/reference/merge.md
+++ b/skills/worktrunk/reference/merge.md
@@ -136,8 +136,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/skills/worktrunk/reference/remove.md b/skills/worktrunk/reference/remove.md
index 4e8723994..59ccda072 100644
--- a/skills/worktrunk/reference/remove.md
+++ b/skills/worktrunk/reference/remove.md
@@ -132,8 +132,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/skills/worktrunk/reference/step.md b/skills/worktrunk/reference/step.md
index db4c3fabd..45364eedf 100644
--- a/skills/worktrunk/reference/step.md
+++ b/skills/worktrunk/reference/step.md
@@ -68,8 +68,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -156,8 +157,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -243,8 +245,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -314,8 +317,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -449,8 +453,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -533,8 +538,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -614,8 +620,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -694,8 +701,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -775,8 +783,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
@@ -876,8 +885,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/skills/worktrunk/reference/switch.md b/skills/worktrunk/reference/switch.md
index 59d395496..e4f6f0104 100644
--- a/skills/worktrunk/reference/switch.md
+++ b/skills/worktrunk/reference/switch.md
@@ -209,8 +209,9 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report
- + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for
+ each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under
+ .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 17ed3b324..3e68417fb 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -241,7 +241,7 @@ pub(crate) struct Cli {
)]
pub config: Option<std::path::PathBuf>,
- /// Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ /// Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
#[arg(
long,
short = 'v',
@@ -1292,6 +1292,8 @@ Some variables are conditional: `upstream` requires remote tracking; `base` only
sync = "{% if upstream %}git fetch && git rebase {{ upstream }}{% endif %}"
```
+Run any hook-firing command with `-v` to see the resolved variables for the actual invocation — each hook prints a `template variables:` block showing every in-scope variable and its value (`(unset)` for conditional vars that didn't populate, like `target_worktree_path` during `wt switch -`).
+
Variables use dot access and the `default` filter for missing keys. JSON object/array values are parsed automatically, so `{{ vars.config.port }}` works when the value is `{"port": 3000}`:
```toml
diff --git a/src/commands/command_executor.rs b/src/commands/command_executor.rs
index beda7a883..e7f6cbe99 100644
--- a/src/commands/command_executor.rs
+++ b/src/commands/command_executor.rs
@@ -5,12 +5,15 @@ use anyhow::{Context, Result, bail};
use color_print::cformat;
use worktrunk::HookType;
use worktrunk::config::{
- Command, CommandConfig, HookStep, UserConfig, expand_template, template_references_var,
- validate_template_syntax,
+ Command, CommandConfig, HookStep, UserConfig, expand_template, format_hook_variables,
+ template_references_var, validate_template_syntax,
};
use worktrunk::git::{Repository, WorktrunkError, interrupt_exit_code};
use worktrunk::path::{format_path_for_display, to_posix_path};
-use worktrunk::styling::{eprintln, error_message, format_bash_with_gutter, progress_message};
+use worktrunk::styling::{
+ eprintln, error_message, format_bash_with_gutter, format_with_gutter, info_message,
+ progress_message, verbosity,
+};
use super::format_command_label;
use super::hook_filter::HookSource;
@@ -482,6 +485,13 @@ fn announce_command(cmd: &PreparedCommand, origin: &CommandOrigin) {
}
None => full_label,
};
+ if verbosity() >= 1 {
+ let ctx: HashMap<String, String> = serde_json::from_str(&cmd.context_json)
+ .expect("context_json is always serialized from a HashMap<String, String>");
+ let vars = format_hook_variables(*hook_type, &ctx);
+ eprintln!("{}", info_message("template variables:"));
+ eprintln!("{}", format_with_gutter(&vars, None));
+ }
eprintln!("{}", progress_message(message));
eprintln!("{}", format_bash_with_gutter(&cmd.expanded));
}
diff --git a/src/commands/hooks.rs b/src/commands/hooks.rs
index 788ec9e28..0aae01dda 100644
--- a/src/commands/hooks.rs
+++ b/src/commands/hooks.rs
@@ -1,11 +1,14 @@
+use std::collections::HashMap;
use std::path::{Path, PathBuf};
use anyhow::Context;
use color_print::cformat;
use worktrunk::HookType;
-use worktrunk::config::CommandConfig;
+use worktrunk::config::{CommandConfig, format_hook_variables};
use worktrunk::path::format_path_for_display;
-use worktrunk::styling::{eprintln, progress_message, warning_message};
+use worktrunk::styling::{
+ eprintln, format_with_gutter, info_message, progress_message, verbosity, warning_message,
+};
use super::command_executor::{
CommandContext, CommandOrigin, FailureStrategy, ForegroundStep, PreparedCommand, PreparedStep,
@@ -333,6 +336,9 @@ pub fn announce_and_spawn_background_hooks(
}
None => format!("Running {combined}"),
};
+ if verbosity() >= 1 {
+ print_background_variable_tables(&non_empty);
+ }
eprintln!("{}", progress_message(message));
for (ctx, group) in non_empty {
@@ -342,6 +348,36 @@ pub fn announce_and_spawn_background_hooks(
Ok(())
}
+/// Emit a `template variables:` block per distinct hook type in `pipelines`.
+///
+/// Background hooks don't flow through `announce_command` (which prints the
+/// table in the foreground path), so this is the symmetric entry point: once
+/// per hook type, using the first command's context. `hook_name` within a
+/// table reflects that first command — the combined announce line above
+/// already enumerates the rest.
+fn print_background_variable_tables(pipelines: &[(CommandContext<'_>, Vec<SourcedStep>)]) {
+ let mut seen: Vec<HookType> = Vec::new();
+ for (_, group) in pipelines {
+ for sourced in group {
+ if seen.contains(&sourced.hook_type) {
+ continue;
+ }
+ let cmd = match &sourced.step {
+ PreparedStep::Single(cmd) => cmd,
+ PreparedStep::Concurrent(cmds) => &cmds[0],
+ };
+ let ctx: HashMap<String, String> = serde_json::from_str(&cmd.context_json)
+ .expect("context_json is always serialized from a HashMap<String, String>");
+ eprintln!("{}", info_message("template variables:"));
+ eprintln!(
+ "{}",
+ format_with_gutter(&format_hook_variables(sourced.hook_type, &ctx), None)
+ );
+ seen.push(sourced.hook_type);
+ }
+ }
+}
+
/// Prepare and spawn all source-group pipelines for a single hook type.
///
/// Wraps `prepare_background_hooks` + `announce_and_spawn_background_hooks` so
diff --git a/src/config/expansion.rs b/src/config/expansion.rs
index ef8ed81a6..6ad05dd77 100644
--- a/src/config/expansion.rs
+++ b/src/config/expansion.rs
@@ -9,7 +9,9 @@
//! See `wt hook --help` for available filters and functions.
use std::borrow::Cow;
+use std::collections::{BTreeSet, HashMap};
use std::fmt::{self, Write};
+use std::hash::{Hash, Hasher};
use std::sync::Arc;
use anyhow::Context;
@@ -26,27 +28,22 @@ use crate::styling::{
info_message, verbosity,
};
-/// Template variables available in every context.
+/// Active-context vars: point at the branch the operation acts on.
///
-/// Populated by `build_hook_context()` in `command_executor.rs`. `upstream`
-/// is conditional on branch tracking configuration but is included here so
-/// templates may reference it in any context (guarded by `{% if upstream %}`).
-///
-/// Ordered to match the user-facing help table in `src/cli/mod.rs`
-/// (`## Template variables`): active-context vars first, then repo/remote
-/// metadata, then the always-available portion of execution context (`cwd`).
-/// Operation-context vars (`base`, `target`, `pr_*`) and infrastructure
-/// vars (`hook_type`, `hook_name`) are not in `BASE_VARS` — they're added
-/// per-scope by `hook_extras` and `HOOK_INFRASTRUCTURE_VARS`.
-pub const BASE_VARS: &[&str] = &[
- // Active context
+/// `upstream` is conditional on branch tracking configuration but is listed
+/// here so templates may reference it in any context (guarded by
+/// `{% if upstream %}`).
+pub const ACTIVE_VARS: &[&str] = &[
"branch",
"worktree_path",
"worktree_name",
"commit",
"short_commit",
"upstream",
- // Repo / remote metadata
+];
+
+/// Repo/remote-metadata vars: describe the repository hosting the operation.
+pub const REPO_VARS: &[&str] = &[
"repo",
"repo_path",
"owner",
@@ -54,10 +51,29 @@ pub const BASE_VARS: &[&str] = &[
"default_branch",
"remote",
"remote_url",
- // Execution context (always-available portion)
- "cwd",
];
+/// Exec-context vars always available outside hook infrastructure.
+///
+/// `cwd` is populated for every template expansion; `hook_type`/`hook_name`
+/// are added by the hook runner itself (`HOOK_INFRASTRUCTURE_VARS`).
+pub const EXEC_BASE_VARS: &[&str] = &["cwd"];
+
+/// Template variables available in every context: the concatenation of
+/// [`ACTIVE_VARS`], [`REPO_VARS`], and [`EXEC_BASE_VARS`].
+///
+/// Populated by `build_hook_context()` in `command_executor.rs`. Operation-
+/// context vars (`base`, `target`, `pr_*`) and infrastructure vars
+/// (`hook_type`, `hook_name`) are not in the base set — they're added per-
+/// scope by `hook_extras` and the hook runner itself.
+pub fn base_vars() -> Vec<&'static str> {
+ let mut v = Vec::with_capacity(ACTIVE_VARS.len() + REPO_VARS.len() + EXEC_BASE_VARS.len());
+ v.extend_from_slice(ACTIVE_VARS);
+ v.extend_from_slice(REPO_VARS);
+ v.extend_from_slice(EXEC_BASE_VARS);
+ v
+}
+
/// Reserved context key carrying a JSON-encoded `Vec<String>` of positional
/// CLI args forwarded to an alias. The key flows through
/// `HashMap<String, String>` — stable for stdin JSON — and
@@ -98,7 +114,7 @@ pub enum ValidationScope {
Alias,
}
-/// Hook-type-specific extras that sit on top of [`BASE_VARS`].
+/// Hook-type-specific extras that sit on top of [`base_vars`].
///
/// These are the vars injected by callers via `extra_vars` when running a
/// hook. Keeping the mapping in one place means "which vars work in a
@@ -151,11 +167,11 @@ const HOOK_INFRASTRUCTURE_VARS: &[&str] = &["hook_type", "hook_name"];
/// All template variables available in a given scope.
///
-/// The returned list is `BASE_VARS` + scope-specific extras + deprecated
+/// The returned list is [`base_vars`] + scope-specific extras + deprecated
/// aliases. Used by [`validate_template`] to build the placeholder context
/// and by error messages to list what the user could have typed.
pub fn vars_available_in(scope: ValidationScope) -> Vec<&'static str> {
- let mut vars: Vec<&'static str> = BASE_VARS.to_vec();
+ let mut vars: Vec<&'static str> = base_vars();
match scope {
ValidationScope::Hook(hook_type) => {
vars.extend(HOOK_INFRASTRUCTURE_VARS);
@@ -173,8 +189,46 @@ pub fn vars_available_in(scope: ValidationScope) -> Vec<&'static str> {
vars
}
-use std::collections::{BTreeSet, HashMap};
-use std::hash::{Hash, Hasher};
+/// Format the resolved template variables for a hook invocation as an
+/// aligned `name = value` block — no heading, no indent, caller wraps.
+///
+/// Ordered per the `## Template variables` help table in `src/cli/mod.rs`:
+/// active, operation, repo, exec. A variable appears if it's in scope for
+/// `hook_type` per [`vars_available_in`]. Values come from `ctx`; vars that
+/// are in-scope but absent from `ctx` render as `(unset)` — this surfaces
+/// operation-specific gaps (e.g., `target_worktree_path` during
+/// `wt switch -`, `upstream` when the branch doesn't track a remote).
+///
+/// `(unset)` relies on an invariant in `build_hook_context`: optional vars
+/// are omitted from the map rather than inserted as empty strings. If a
+/// future caller starts inserting `""`, revisit the empty-vs-absent
+/// distinction here.
+///
+/// Deprecated aliases and `vars.*` (user state) are intentionally omitted.
+pub fn format_hook_variables(hook_type: HookType, ctx: &HashMap<String, String>) -> String {
+ // Flat list in the canonical docs order: active, operation, repo, exec.
+ let vars: Vec<&'static str> = ACTIVE_VARS
+ .iter()
+ .chain(hook_extras(hook_type))
+ .chain(REPO_VARS)
+ .chain(EXEC_BASE_VARS)
+ .chain(HOOK_INFRASTRUCTURE_VARS)
+ .copied()
+ .collect();
+
+ let max_name = vars.iter().map(|v| v.len()).max().unwrap_or(0);
+
+ vars.iter()
+ .map(|var| {
+ let value = match ctx.get(*var) {
+ Some(v) => v.as_str(),
+ None => "(unset)",
+ };
+ format!("{var:<max_name$} = {value}")
+ })
+ .collect::<Vec<_>>()
+ .join("\n")
+}
/// Positional CLI args forwarded from `wt <alias> a b c` into the alias's
/// template context. Bare `{{ args }}` renders as a space-joined,
@@ -1832,4 +1886,63 @@ mod tests {
assert!(!err.available_vars.is_empty(), "should list available vars");
assert!(err.available_vars.contains(&"branch".to_string()));
}
+
+ #[test]
+ fn test_format_hook_variables_groups_and_unset() {
+ let mut ctx: HashMap<String, String> = HashMap::new();
+ ctx.insert("branch".into(), "feature".into());
+ ctx.insert("worktree_path".into(), "/tmp/feature".into());
+ ctx.insert("worktree_name".into(), "feature".into());
+ ctx.insert("base".into(), "main".into());
+ ctx.insert("base_worktree_path".into(), "/tmp/main".into());
+ ctx.insert("target".into(), "-".into());
+ // target_worktree_path deliberately absent — mimics `wt switch -`
+ ctx.insert("repo".into(), "demo".into());
+ ctx.insert("repo_path".into(), "/tmp/demo".into());
+ ctx.insert("cwd".into(), "/tmp/feature".into());
+ ctx.insert("hook_type".into(), "pre-switch".into());
+ ctx.insert("hook_name".into(), "show-variables".into());
+
+ assert_snapshot!(format_hook_variables(HookType::PreSwitch, &ctx), @r"
+ branch = feature
+ worktree_path = /tmp/feature
+ worktree_name = feature
+ commit = (unset)
+ short_commit = (unset)
+ upstream = (unset)
+ base = main
+ base_worktree_path = /tmp/main
+ target = -
+ target_worktree_path = (unset)
+ pr_number = (unset)
+ pr_url = (unset)
+ repo = demo
+ repo_path = /tmp/demo
+ owner = (unset)
+ primary_worktree_path = (unset)
+ default_branch = (unset)
+ remote = (unset)
+ remote_url = (unset)
+ cwd = /tmp/feature
+ hook_type = pre-switch
+ hook_name = show-variables
+ ");
+ }
+
+ #[test]
+ fn test_format_hook_variables_scope_filters_operation() {
+ // pre-commit only has `target` in operation scope — no base*, pr_*, etc.
+ let mut ctx: HashMap<String, String> = HashMap::new();
+ ctx.insert("target".into(), "main".into());
+ let out = format_hook_variables(HookType::PreCommit, &ctx);
+ assert!(out.contains("target = main"), "got: {out}");
+ assert!(
+ !out.contains("base "),
+ "pre-commit has no `base`; got: {out}"
+ );
+ assert!(
+ !out.contains("pr_number"),
+ "pre-commit has no `pr_number`; got: {out}"
+ );
+ }
}
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 827cdffa6..9c36010a3 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -121,10 +121,10 @@ pub use deprecation::{
key_belongs_in, warn_unknown_fields,
};
pub use expansion::{
- ALIAS_ARGS_KEY, BASE_VARS, DEPRECATED_TEMPLATE_VARS, TemplateExpandError, ValidationScope,
- expand_template, redact_credentials, referenced_vars_for_config, sanitize_branch_name,
- sanitize_db, short_hash, template_references_var, validate_template, validate_template_syntax,
- vars_available_in,
+ ACTIVE_VARS, ALIAS_ARGS_KEY, DEPRECATED_TEMPLATE_VARS, EXEC_BASE_VARS, REPO_VARS,
+ TemplateExpandError, ValidationScope, base_vars, expand_template, format_hook_variables,
+ redact_credentials, referenced_vars_for_config, sanitize_branch_name, sanitize_db, short_hash,
+ template_references_var, validate_template, validate_template_syntax, vars_available_in,
};
pub use hooks::HooksConfig;
pub use project::{ProjectCiConfig, ProjectConfig, ProjectListConfig, valid_project_config_keys};
diff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rs
index 39283bac0..5e35aba46 100644
--- a/tests/integration_tests/user_hooks.rs
+++ b/tests/integration_tests/user_hooks.rs
@@ -7,8 +7,8 @@
//! - Skipped together with project hooks via --no-hooks
use crate::common::{
- TestRepo, make_snapshot_cmd, repo, resolve_git_common_dir, setup_snapshot_settings,
- wait_for_file, wait_for_file_content, wait_for_file_count,
+ TestRepo, make_snapshot_cmd, make_snapshot_cmd_with_global_flags, repo, resolve_git_common_dir,
+ setup_snapshot_settings, wait_for_file, wait_for_file_content, wait_for_file_count,
};
use insta_cmd::assert_cmd_snapshot;
use rstest::rstest;
@@ -3421,3 +3421,51 @@ test = "echo TEST"
"single [[pre-merge]] block should run concurrently: {stderr}",
);
}
+
+/// Under `-v`, hooks print a grouped table of resolved template variables —
+/// see issue #2309 for why this helps users understand scope-dependent gaps.
+#[rstest]
+fn test_hook_verbose_prints_variable_table(mut repo: TestRepo) {
+ repo.add_worktree("feature");
+ repo.write_test_config(
+ r#"[pre-switch]
+noop = "true"
+"#,
+ );
+
+ let settings = setup_snapshot_settings(&repo);
+ settings.bind(|| {
+ let mut cmd =
+ make_snapshot_cmd_with_global_flags(&repo, "switch", &["feature"], None, &["-v"]);
+ assert_cmd_snapshot!("hook_verbose_variable_table", cmd);
+ });
+}
+
+/// Background-path variable dump dedups per hook type when both user and
+/// project configs contribute to the same hook — the table prints once, not
+/// once per source. Also exercises the `PreparedStep::Single` arm of
+/// `print_background_variable_tables`, which the all-named-commands case in
+/// `test_post_start_verbose_shows_per_hook_output` doesn't hit.
+#[rstest]
+fn test_hook_verbose_background_dedups_across_sources(repo: TestRepo) {
+ repo.write_test_config(r#"post-start = "echo user-hook""#);
+ repo.write_project_config(r#"post-start = "echo project-hook""#);
+ repo.commit("add post-start");
+ repo.write_test_approvals(
+ r#"[projects."../origin"]
+approved-commands = ["echo project-hook"]
+"#,
+ );
+
+ let settings = setup_snapshot_settings(&repo);
+ settings.bind(|| {
+ let mut cmd = make_snapshot_cmd_with_global_flags(
+ &repo,
+ "switch",
+ &["--create", "feature"],
+ None,
+ &["-v"],
+ );
+ assert_cmd_snapshot!("hook_verbose_background_dedup", cmd);
+ });
+}
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap b/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap
index 79ae57076..286527dea 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_approvals.snap
@@ -51,7 +51,7 @@ Usage: wt config approvals [OPTIONS] <COMMAND>
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap b/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap
index 2206e38ac..1d559ebfd 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_approvals_add.snap
@@ -51,7 +51,7 @@ Usage: wt config approvals add [OPTIONS]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_approvals_clear.snap b/tests/snapshots/integration__integration_tests__help__help_config_approvals_clear.snap
index dd97db76f..4d4c4c358 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_approvals_clear.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_approvals_clear.snap
@@ -51,7 +51,7 @@ Usage: wt config approvals clear [OPTIONS]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_create.snap b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
index c524420b3..c236d5347 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_create.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
@@ -50,7 +50,7 @@ Usage: wt config create [OPTIONS]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
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 507657fe3..c184661db 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
@@ -58,7 +58,7 @@ Usage: wt config [OPTIONS] <COMMAND>
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_shell.snap b/tests/snapshots/integration__integration_tests__help__help_config_shell.snap
index fafe00785..bb5666f27 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_shell.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_shell.snap
@@ -47,7 +47,7 @@ Usage: wt config shell [OPTIONS] <COMMAND>
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_short.snap b/tests/snapshots/integration__integration_tests__help__help_config_short.snap
index c6c0bc75d..18ffad25b 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_short.snap
@@ -50,7 +50,7 @@ Usage: wt config [OPTIONS] <COMMAND>
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_show.snap b/tests/snapshots/integration__integration_tests__help__help_config_show.snap
index ba866c888..2de02a9fd 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_show.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_show.snap
@@ -60,7 +60,7 @@ Usage: wt config show [OPTIONS]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state.snap b/tests/snapshots/integration__integration_tests__help__help_config_state.snap
index 2fd1cadb9..3532cf6fc 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state.snap
@@ -58,7 +58,7 @@ Usage: wt config state [OPTIONS] <COMMAND>
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_ci_status.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_ci_status.snap
index 0724e2791..fa8ce7a14 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_ci_status.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_ci_status.snap
@@ -56,7 +56,7 @@ Usage: wt config state ci-status [OPTIONS] [COMMAND]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_clear.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_clear.snap
index 814525830..ab96b1f99 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_clear.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_clear.snap
@@ -48,7 +48,7 @@ Usage: wt config state clear [OPTIONS]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_default_branch.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_default_branch.snap
index 493e5ed33..d22660000 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_default_branch.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_default_branch.snap
@@ -53,7 +53,7 @@ Usage: wt config state default-branch [OPTIONS] [COMM
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_get.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_get.snap
index 50812dacc..b3e08606d 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_get.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_get.snap
@@ -53,7 +53,7 @@ Usage: wt config state get [OPTIONS]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
index 29a5fcb69..b04998bd9 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
@@ -56,7 +56,7 @@ Usage: wt config state logs [OPTIONS] [COMMAND]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_marker.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_marker.snap
index dcfdfd892..adfd2f9f4 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_marker.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_marker.snap
@@ -57,7 +57,7 @@ Usage: wt config state marker [OPTIONS] [COMMAND]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_previous_branch.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_previous_branch.snap
index ef20df7f7..45d80c345 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_previous_branch.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_previous_branch.snap
@@ -53,7 +53,7 @@ Usage: wt config state previous-branch [OPTIONS] [COM
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
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 7f266986f..bf1718308 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list_long.snap
@@ -69,7 +69,7 @@ Usage: wt list [OPTIONS]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
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 10c9c0ed9..48393a927 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
@@ -71,8 +71,9 @@ Usage: wt list [OPTIONS]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs
- + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved
+ template variables for each hook invocation; -vv: debug logs +
+ diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_list_short.snap b/tests/snapshots/integration__integration_tests__help__help_list_short.snap
index c930a7b4b..671263283 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list_short.snap
@@ -49,7 +49,7 @@ Usage: wt list [OPTIONS]
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
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 acddd5aab..65aac4f8e 100644
--- a/tests/snapshots/integration__integration_tests__help__help_md_merge.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_md_merge.snap
@@ -92,7 +92,7 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_md_root.snap b/tests/snapshots/integration__integration_tests__help__help_md_root.snap
index ee628b1aa..0ea90670f 100644
--- a/tests/snapshots/integration__integration_tests__help__help_md_root.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_md_root.snap
@@ -57,7 +57,7 @@ Global Options:
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
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 683cc6a4b..8b0d8b07a 100644
--- a/tests/snapshots/integration__integration_tests__help__help_merge_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_merge_long.snap
@@ -92,7 +92,7 @@ Usage: wt merge [OPTIONS] [TARGET]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_merge_short.snap b/tests/snapshots/integration__integration_tests__help__help_merge_short.snap
index 4768b83f9..943f46278 100644
--- a/tests/snapshots/integration__integration_tests__help__help_merge_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_merge_short.snap
@@ -53,7 +53,7 @@ Usage: wt merge [OPTIONS] [TARGET]
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__help__help_no_args.snap b/tests/snapshots/integration__integration_tests__help__help_no_args.snap
index 35d9a9bdb..20481408b 100644
--- a/tests/snapshots/integration__integration_tests__help__help_no_args.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_no_args.snap
@@ -48,7 +48,7 @@ Usage: wt [OPTIONS] [COMMAND]
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
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 006d79ab3..d65211d49 100644
--- a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
@@ -81,7 +81,7 @@ Usage: wt remove [OPTIONS] [BRANCHES]...
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_remove_short.snap b/tests/snapshots/integration__integration_tests__help__help_remove_short.snap
index 8115f4bd1..aaab5087c 100644
--- a/tests/snapshots/integration__integration_tests__help__help_remove_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_remove_short.snap
@@ -51,7 +51,7 @@ Usage: wt remove [OPTIONS] [BRANCHES]...
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__help__help_root_long.snap b/tests/snapshots/integration__integration_tests__help__help_root_long.snap
index c864a69c1..b565f9df6 100644
--- a/tests/snapshots/integration__integration_tests__help__help_root_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_root_long.snap
@@ -57,7 +57,7 @@ Usage: wt [OPTIONS] [COMMAND]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_root_short.snap b/tests/snapshots/integration__integration_tests__help__help_root_short.snap
index bbfff4af4..25b9a3020 100644
--- a/tests/snapshots/integration__integration_tests__help__help_root_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_root_short.snap
@@ -49,7 +49,7 @@ Usage: wt [OPTIONS] [COMMAND]
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
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 dc58a7db9..5b413daf8 100644
--- a/tests/snapshots/integration__integration_tests__help__help_step_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_step_long.snap
@@ -61,7 +61,7 @@ Usage: wt step [OPTIONS] <COMMAND>
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_step_promote.snap b/tests/snapshots/integration__integration_tests__help__help_step_promote.snap
index 6ea1525af..a89eb12a9 100644
--- a/tests/snapshots/integration__integration_tests__help__help_step_promote.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_step_promote.snap
@@ -55,7 +55,7 @@ Usage: wt step promote [OPTIONS] [BRANCH]
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
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 40240ddc6..7ddf0e467 100644
--- a/tests/snapshots/integration__integration_tests__help__help_step_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_step_short.snap
@@ -53,7 +53,7 @@ Usage: wt step [OPTIONS] <COMMAND>
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
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 6e8c037e7..1f30731b3 100644
--- a/tests/snapshots/integration__integration_tests__help__help_switch_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_switch_long.snap
@@ -113,7 +113,7 @@ Usage: wt switch [OPTIONS] [BRANCH] [--
User config file path
-v, --verbose...
- Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts
diff --git a/tests/snapshots/integration__integration_tests__help__help_switch_short.snap b/tests/snapshots/integration__integration_tests__help__help_switch_short.snap
index 9df4d17ca..27ebeb04b 100644
--- a/tests/snapshots/integration__integration_tests__help__help_switch_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_switch_short.snap
@@ -57,7 +57,7 @@ Usage: wt switch [OPTIONS] [BRANCH] [--
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_verbose_template_expansion.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_verbose_template_expansion.snap
index 5f496d241..444ceae77 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_verbose_template_expansion.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_verbose_template_expansion.snap
@@ -56,6 +56,29 @@ exit_code: 0
  echo 'Setting up {{ branch | sanitize }} in {{ worktree_path }}'
  →
  echo 'Setting up verbose-hooks in _REPO_.verbose-hooks'
+○ template variables:
+  branch = verbose-hooks
+  worktree_path = _REPO_.verbose-hooks
+  worktree_name = repo.verbose-hooks
+  commit = 8b2a39bbbeb5897579b4db89e4785539fd72278d
+  short_commit = 8b2a39b
+  upstream = (unset)
+  base = main
+  base_worktree_path = _REPO_
+  target = verbose-hooks
+  target_worktree_path = _REPO_.verbose-hooks
+  pr_number = (unset)
+  pr_url = (unset)
+  repo = repo
+  repo_path = _REPO_
+  owner = (unset)
+  primary_worktree_path = _REPO_
+  default_branch = main
+  remote = origin
+  remote_url = ../origin.git
+  cwd = _REPO_.verbose-hooks
+  hook_type = pre-start
+  hook_name = setup
◎ Running pre-start project:setup @ _REPO_.verbose-hooks
  echo 'Setting up verbose-hooks in _REPO_.verbose-hooks'
Setting up verbose-hooks in _REPO_.verbose-hooks
diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap
index 1b85130ae..e59f543c8 100644
--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap
+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_verbose_output.snap
@@ -58,4 +58,27 @@ exit_code: 0
  echo 'verbose test' > verbose.txt
  →
  echo 'verbose test' > verbose.txt
+○ template variables:
+  branch = feature
+  worktree_path = _REPO_.feature
+  worktree_name = repo.feature
+  commit = d545a78b148af245c616612b474fd2049705c00c
+  short_commit = d545a78
+  upstream = (unset)
+  base = main
+  base_worktree_path = _REPO_
+  target = feature
+  target_worktree_path = _REPO_.feature
+  pr_number = (unset)
+  pr_url = (unset)
+  repo = repo
+  repo_path = _REPO_
+  owner = (unset)
+  primary_worktree_path = _REPO_
+  default_branch = main
+  remote = origin
+  remote_url = ../origin.git
+  cwd = _REPO_.feature
+  hook_type = post-start
+  hook_name = setup
◎ Running post-start: project:setup @ _REPO_.feature
diff --git a/tests/snapshots/integration__integration_tests__step_alias__step_help_includes_aliases.snap b/tests/snapshots/integration__integration_tests__step_alias__step_help_includes_aliases.snap
index 07d00f2a1..3397fae6e 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__step_help_includes_aliases.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__step_help_includes_aliases.snap
@@ -68,7 +68,7 @@ Usage: wt step [OPTIONS] <COMMAND>
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_alias__step_list_no_aliases.snap b/tests/snapshots/integration__integration_tests__step_alias__step_list_no_aliases.snap
index 827a33dc3..7c7250372 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__step_list_no_aliases.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__step_list_no_aliases.snap
@@ -64,7 +64,7 @@ Usage: wt step [OPTIONS] <COMMAND>
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__step_alias__step_list_with_aliases.snap b/tests/snapshots/integration__integration_tests__step_alias__step_list_with_aliases.snap
index 2e5c9c407..ce2409bed 100644
--- a/tests/snapshots/integration__integration_tests__step_alias__step_list_with_aliases.snap
+++ b/tests/snapshots/integration__integration_tests__step_alias__step_list_with_aliases.snap
@@ -69,7 +69,7 @@ Usage: wt step [OPTIONS] <COMMAND>
Global Options:
-C <path> Working directory for this command
--config <path> User config file path
- -v, --verbose... Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
+ -v, --verbose... Verbose output (-v: info logs + hook/template output + resolved template variables for each hook invocation; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes Skip approval prompts
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_background_dedup.snap b/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_background_dedup.snap
new file mode 100644
index 000000000..b5c6815b6
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_background_dedup.snap
@@ -0,0 +1,88 @@
+---
+source: tests/integration_tests/user_hooks.rs
+info:
+ program: wt
+ args:
+ - "-v"
+ - switch
+ - "--create"
+ - feature
+ 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]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "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 -----
+○ Expanding worktree-path
+  {{ repo_path }}/../{{ repo }}.{{ branch | sanitize }}
+  →
+  _REPO_/../repo.feature
+✓ Created branch feature from main and worktree @ _REPO_.feature
+↳ To customize worktree locations, run wt config create
+▲ Cannot change directory — shell integration not installed
+↳ To enable automatic cd, run wt config shell install
+○ Expanding user post-start hook
+  echo user-hook
+  →
+  echo user-hook
+○ Expanding project post-start hook
+  echo project-hook
+  →
+  echo project-hook
+○ template variables:
+  branch = feature
+  worktree_path = _REPO_.feature
+  worktree_name = repo.feature
+  commit = 26c70caa73d841981f190bafd2a2a6e1d4eed34e
+  short_commit = 26c70ca
+  upstream = (unset)
+  base = main
+  base_worktree_path = _REPO_
+  target = feature
+  target_worktree_path = _REPO_.feature
+  pr_number = (unset)
+  pr_url = (unset)
+  repo = repo
+  repo_path = _REPO_
+  owner = (unset)
+  primary_worktree_path = _REPO_
+  default_branch = main
+  remote = origin
+  remote_url = ../origin.git
+  cwd = _REPO_.feature
+  hook_type = post-start
+  hook_name = (unset)
+◎ Running post-start: user, project @ _REPO_.feature
diff --git a/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_variable_table.snap b/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_variable_table.snap
new file mode 100644
index 000000000..60de3faf7
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__user_hooks__hook_verbose_variable_table.snap
@@ -0,0 +1,82 @@
+---
+source: tests/integration_tests/user_hooks.rs
+info:
+ program: wt
+ args:
+ - "-v"
+ - switch
+ - feature
+ 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]"
+ NO_COLOR: ""
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "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 -----
+○ Expanding user:noop
+  true
+  →
+  true
+○ template variables:
+  branch = feature
+  worktree_path = _REPO_.feature
+  worktree_name = repo.feature
+  commit = 05a4a45d0b981dad5c27db59dca482836d59f89e
+  short_commit = 05a4a45
+  upstream = (unset)
+  base = main
+  base_worktree_path = _REPO_
+  target = feature
+  target_worktree_path = _REPO_.feature
+  pr_number = (unset)
+  pr_url = (unset)
+  repo = repo
+  repo_path = _REPO_
+  owner = (unset)
+  primary_worktree_path = _REPO_
+  default_branch = main
+  remote = origin
+  remote_url = ../origin.git
+  cwd = _REPO_
+  hook_type = pre-switch
+  hook_name = noop
+◎ Running pre-switch user:noop
+  true
+○ Expanding worktree-path
+  {{ repo_path }}/../{{ repo }}.{{ branch | sanitize }}
+  →
+  _REPO_/../repo.feature
+▲ Worktree for feature @ _REPO_.feature, but cannot change directory — shell integration not installed
+↳ To enable automatic cd, run wt config shell install