Skip to content

Hooks

Hooks let you automate tasks when Workset creates a new worktree. Common use cases include installing dependencies, running code generation, or setting up local configuration.

Create a .workset/hooks.yaml file in any repo:

hooks:
- id: bootstrap
on: [worktree.created]
run: ["npm", "ci"]
cwd: "{repo.path}"
on_error: fail
  • worktree.created — Fires when a new worktree is created for the repo
FieldDescription
idUnique identifier for the hook
onList of events that trigger the hook
runCommand and arguments to execute
cwdWorking directory (supports {repo.path} template)
on_errorError handling: fail or warn

Hooks run automatically when the triggering event occurs. You can also run them manually:

Terminal window
workset hooks run -t <thread> <repo> --event worktree.created

By default, Workset prompts before running hooks from repos you haven’t explicitly trusted. Add repos to the trusted list in your global config:

hooks:
repo_hooks:
trusted_repos: [platform, api]

Or disable hooks entirely:

hooks:
enabled: false

The on_error field controls what happens when a hook fails:

  • fail — Stop execution and report the error (default)
  • warn — Log the warning and continue

You can set a default at the global level:

hooks:
on_error: fail

Hook configuration supports template variables:

  • {repo.path} — Absolute path to the repo worktree