Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
docs(hook): improve JSON context section (#1360)
Maximilian Roos1389a0b783ac
diff --git a/docs/content/hook.md b/docs/content/hook.mdindex 725ade53d..57e43dcbb 100644--- a/docs/content/hook.md+++ b/docs/content/hook.md@@ -272,18 +272,20 @@ setup = "cp {{ worktree_path_of_branch('main') }}/config.local {{ worktree_path## JSON context-Hooks receive context as JSON on stdin, enabling complex logic that templates can't express:+Hooks receive all template variables as JSON on stdin, enabling complex logic that templates can't express:++```toml+[post-create]+setup = "python3 scripts/post-create-setup.py"+``````pythonimport json, sys, subprocessctx = json.load(sys.stdin)-# Run extra setup for feature branches on backend reposif ctx['branch'].startswith('feature/') and 'backend' in ctx['repo']:subprocess.run(['make', 'seed-db'])```-The JSON includes all template variables.-# Running Hooks Manually`wt hook <type>` runs hooks on demand — useful for testing during development, running in CI pipelines, or re-running after a failure.diff --git a/skills/worktrunk/reference/hook.md b/skills/worktrunk/reference/hook.mdindex 70915e6d0..fffa8f2bb 100644--- a/skills/worktrunk/reference/hook.md+++ b/skills/worktrunk/reference/hook.md@@ -263,18 +263,20 @@ setup = "cp {{ worktree_path_of_branch('main') }}/config.local {{ worktree_path## JSON context-Hooks receive context as JSON on stdin, enabling complex logic that templates can't express:+Hooks receive all template variables as JSON on stdin, enabling complex logic that templates can't express:++```toml+[post-create]+setup = "python3 scripts/post-create-setup.py"+``````pythonimport json, sys, subprocessctx = json.load(sys.stdin)-# Run extra setup for feature branches on backend reposif ctx['branch'].startswith('feature/') and 'backend' in ctx['repo']:subprocess.run(['make', 'seed-db'])```-The JSON includes all template variables.-# Running Hooks Manually`wt hook <type>` runs hooks on demand — useful for testing during development, running in CI pipelines, or re-running after a failure.diff --git a/src/cli/mod.rs b/src/cli/mod.rsindex 774269ff5..8a8041bf8 100644--- a/src/cli/mod.rs+++ b/src/cli/mod.rs@@ -1337,18 +1337,20 @@ setup = "cp {{ worktree_path_of_branch('main') }}/config.local {{ worktree_path## JSON context-Hooks receive context as JSON on stdin, enabling complex logic that templates can't express:+Hooks receive all template variables as JSON on stdin, enabling complex logic that templates can't express:++```toml+[post-create]+setup = "python3 scripts/post-create-setup.py"+``````pythonimport json, sys, subprocessctx = json.load(sys.stdin)-# Run extra setup for feature branches on backend reposif ctx['branch'].startswith('feature/') and 'backend' in ctx['repo']:subprocess.run(['make', 'seed-db'])```-The JSON includes all template variables.-# Running Hooks Manually`wt hook <type>` runs hooks on demand — useful for testing during development, running in CI pipelines, or re-running after a failure.