Deno worktree hooks for
worktrunkautomating environment setup, warm-copy indexing, and path isolation.
When creating isolated git worktrees, new checkouts often start cold: index databases must be rebuilt from scratch, nested .git references break across directory boundaries, and development dependencies require manual setup. This repository provides executable TypeScript hooks that wire into worktrunk lifecycle events (pre-start, post-start, post-switch, pre-merge) to make every worktree immediately ready for development.
# .config/wt.toml
[hooks]
pre-start = "deno run --allow-read --allow-write --allow-run --allow-env ./scripts/pre-start.ts {{worktree_path}} {{primary_worktree_path}}"
post-start = "deno run --allow-read --allow-write --allow-run --allow-env ./scripts/copy-codegraph.ts {{worktree_path}} {{primary_worktree_path}}"
post-switch = "deno run --allow-run ./scripts/post-switch.ts {{worktree_path}}"
pre-merge = "deno run --allow-read --allow-write --allow-run ./scripts/pre-merge.ts {{worktree_path}}"Ensure Deno is installed on your workstation, then verify the codebase:
git clone https://github.com/systemfsoftware/worktrunk-scripts.git
cd worktrunk-scripts
deno task checkThe hooks execute directly with deno run using explicit permission flags declared in each script's shebang.
Scripts under scripts/ are standalone CLI entrypoints invoked by worktrunk lifecycle events. Shared helpers (git resolution, relative path mapping, filesystem utilities) live under scripts/lib/.
In your primary repository, configure worktrunk to call the desired hook scripts in .config/wt.toml. Every script accepts standard arguments supplied by the runner:
deno run --allow-read --allow-write --allow-run --allow-env ./scripts/<hook-name>.ts <worktree_path> [primary_path]If the secondary primary_path argument is omitted, the hook automatically resolves the primary repository root using the shared git common directory.
Code formatting and linting are enforced via dprint and deno lint:
deno task fmt # Format all files using dprint
deno task check # Run dprint verification and deno lintDevelopment setup, conventions, and workflow: CONTRIBUTING.md.
See LICENSE for terms.