roark

Search documentation

Search across all Roark documentation pages.

Type to search across the docs.

docs/lifecycle-hooks.md

Lifecycle hooks

Run setup commands at specific points in a Roark workflow.

Last updated

View Markdown
json
{
  "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.

Put dependency installation in beforeRun and beforeVerify. A new workspace runs beforeRun immediately after creation; adding the same command to afterCreate runs it twice. Reserve afterCreate for one-time setup.

review-pr and revise-pr use the same hooks and verification setup. Both run them against the PR checkout.

#Timeout

timeoutMs controls hook timeout. The default is 600000 milliseconds.

#Use hooks for

  • Install dependencies.
  • Generate local build artifacts required by verification.
  • Run lightweight setup checks.

#Do not use hooks for

  • 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.