Lifecycle hooks
Reference for workspace lifecycle hooks such as dependency installation and pre-verification setup.
Last updated
{
"hooks": {
"beforeRun": "bun install --frozen-lockfile",
"beforeVerify": "bun install --frozen-lockfile",
"timeoutMs": 600000
}
}#Hooks
afterCreate: runs after a new workspace is cloned and checked out.beforeRun: runs before agent workflow execution.beforeVerify: runs immediately before verification.afterRun: runs after workflow completion; failures warn instead of stopping the run.beforeRemove: runs before workspace removal; failures warn instead of stopping removal.
For dependency installation, prefer beforeRun and beforeVerify. A fresh workspace runs beforeRun immediately after creation, so configuring the same install command in both afterCreate and beforeRun only repeats setup. Reserve afterCreate for setup that must run exactly once when the workspace is first created.
review-pr uses the same configured lifecycle hooks and verification setup as revise-pr. Hooks and verification run against the pinned PR checkout.
#Timeout
timeoutMs controls hook timeout. The default is 600000 milliseconds.
#Good uses
- Install dependencies.
- Generate local build artifacts required by verification.
- Run lightweight setup checks.
#Avoid
- Writing secrets into Git-tracked files.
- Long-running daemons.
- Interactive prompts.
- Commands that mutate unrelated host state.
For ignored local file copying, prefer workspace.copyToWorktree. See Managed workspaces.
#Next steps
- Use Configuration for the hook reference table.
- Use Verification for pre-verification setup.
- Use Security and secrets before adding hooks on shared hosts.