Hooks

Hooks are event listeners that trigger custom actions at specific points in the agent lifecycle. Run linters before agent starts, run tests after it finishes, or post a Slack message when a large task completes.

What are hooks?

Hooks are shell commands or scripts that Vyre executes automatically when specific agent events occur. They integrate your existing tooling — CI scripts, git hooks, deployment pipelines — directly into the agent workflow.

Hooks run in your local shell with full access to your environment. They can read and write files, call APIs, run build tools, or anything else a shell script can do.

Hook types

Creating hooks

Define hooks in your .vyre/hooks.json file:

json
{
  "hooks": [
    {
      "event": "post-agent",
      "name": "Run tests",
      "command": "npm test",
      "when": "always"
    },
    {
      "event": "post-agent",
      "name": "Format code",
      "command": "npx prettier --write .",
      "when": "on-success"
    },
    {
      "event": "pre-agent",
      "name": "Stash changes",
      "command": "git stash",
      "when": "if-dirty"
    }
  ]
}

Condition values

  • always — Run regardless of agent outcome.
  • on-success — Run only if agent completed without errors.
  • on-failure — Run only if agent encountered an error.
  • if-dirty — Run only if there are uncommitted changes.

Examples

Run tests after every agent session
json
{
  "event": "post-agent",
  "name": "Test suite",
  "command": "npm test -- --passWithNoTests",
  "when": "on-success"
}
Notify Slack when a large task completes
json
{
  "event": "post-agent",
  "name": "Slack notification",
  "command": "node scripts/notify-slack.js 'Agent finished: $VYRE_TASK_SUMMARY'",
  "when": "on-success"
}

Available environment variables:

  • $VYRE_TASK_SUMMARY — one-line summary of the task
  • $VYRE_FILES_CHANGED — comma-separated list of changed files
  • $VYRE_DURATION_SECONDS — how long the session took
Auto-format after editing
json
{
  "event": "post-agent",
  "name": "Format & lint",
  "command": "npx prettier --write . && npx eslint --fix .",
  "when": "always"
}