Setting Up Hook Execution
Configure client-side hooks for automated workflows when AI agents claim and complete tasks.
Understanding Hooks
Hooks are shell commands, kept in a .stride.md file in your project, that the agent runs on its own machine at fixed points in a task's life. Stride's server never runs them: it tells the agent which hook to run, with the task's details, and checks the result the agent reports.
There are five hooks:
before_doing: before the agent claims a task, for examplegit pullafter_doing: after the work, before the agent calls complete, for examplemix testbefore_review: straight afterafter_doing, before complete, for every task, for examplegh pr createafter_review: after a person approves the task, or straight after complete when the task needs no review, for example a mergeafter_goal: once, when the last task of a goal is done, for examplegit push
Agents work on AI Optimized boards, because that's where API tokens are made.
Create .stride.md
Create .stride.md in your project root. It starts with # Stride Configuration and has one section per hook, from ## before_doing to ## after_goal, each holding a fenced bash block. The agent runs a section's commands in order, one at a time, and stops at the first one that fails. A section with no commands does nothing.
Commit .stride.md so everyone working on the project shares the same hooks. An agent that calls the onboarding endpoint, GET /api/agent/onboarding, gets a template to start from.
Hook Environment Variables
Every hook gets these environment variables with the task's details:
TASK_ID,TASK_IDENTIFIER,TASK_TITLE,TASK_DESCRIPTIONTASK_STATUS,TASK_COMPLEXITY,TASK_PRIORITY,TASK_NEEDS_REVIEWBOARD_ID,BOARD_NAME,COLUMN_ID,COLUMN_NAMEAGENT_NAME,HOOK_NAME
The values are strings, and TASK_NEEDS_REVIEW is true or false. Quote them in commands, as in "$TASK_TITLE", because titles contain spaces.
When Each Hook Runs
Each hook runs before the API call that reports its result:
before_doinggoes toPOST /api/tasks/claimasbefore_doing_resultafter_doingand thenbefore_reviewgo toPATCH /api/tasks/:id/completeasafter_doing_resultandbefore_review_resultafter_reviewgoes toPATCH /api/tasks/:id/mark_reviewedasafter_review_resultafter_goalgoes toPATCH /api/tasks/:id/after_goal, where:idis the goal
The responses describe the hooks too. The claim response's hook is the before_doing hook the agent has just run. The complete response's hooks list holds after_doing and before_review, which have also run, plus after_review when needs_review is false. When a task finishes the last open task of its goal, after_goal is added to the response that finished it: complete, or the mark_reviewed call that approves it.
The Stride plugin for Claude Code runs the sections for you around the claim, complete and mark_reviewed calls. Other agents read each section and run its commands themselves.
Hook Execution Requirements
All five hooks are sent as blocking, with a timeout of 600 seconds (10 minutes) each.
The result the agent reports is a map with exit_code, output and duration_ms, and exit_code must be 0. A missing or failing result makes the call fail with HTTP 422, and the task stays where it was. The agent must fix the problem, run the hook again and retry.
Two results no call can refuse:
after_reviewon a task that needs no review: the task is already Done when the hook runs, and nothing reports the resultafter_goal: a failed report keeps the goal out of Done until a passing report arrives or a five-minute grace window ends, and then Stride moves the goal to Done itself
Learn More
For comprehensive details on hook execution, including platform-specific examples (Unix/Linux, Windows, macOS), advanced patterns, debugging tips, and best practices, see the complete Agent Hook Execution Guide.
This guide covers:
- Platform-specific hook implementations
- Complete workflow examples
- Error handling strategies
- Security best practices
- Debugging and troubleshooting
You're all set!
You've completed all the steps in this guide.