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
pre-agent
Runs before Agent begins a session. Use to set up state, validate preconditions, or stash uncommitted changes.
post-agent
Runs after Agent finishes and changes are accepted. Use to run tests, format code, or trigger deployments.
on-checkpoint
Runs every time Agent creates a checkpoint. Use to save state to an external system.
on-pr-create
Runs when Agent opens a pull request. Use to add reviewers, labels, or trigger CI checks.
Creating hooks
Define hooks in your .vyre/hooks.json file:
{
"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
{
"event": "post-agent",
"name": "Test suite",
"command": "npm test -- --passWithNoTests",
"when": "on-success"
}Notify Slack when a large task completes
{
"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
{
"event": "post-agent",
"name": "Format & lint",
"command": "npx prettier --write . && npx eslint --fix .",
"when": "always"
}