Tutorial 8 min read

Setting Up Hook Execution

Configure client-side hooks for automated workflows when AI agents claim and complete tasks.

1

Understanding Hooks

Important: Hooks are designed exclusively for AI-Optimized boards working with AI agents. They do not execute for regular boards or human users.

Hooks are shell commands that execute on the agent's machine at specific points in the task lifecycle:

  • before_doing: Runs before the agent claims a task (e.g., git pull)
  • after_doing: Runs after the agent completes work (e.g., mix test)
  • before_review: Runs when the agent submits for review (e.g., gh pr create)
  • after_review: Runs after human approval (e.g., git push)
2

Create .stride.md

Create a .stride.md file in your project root with hook definitions. This file is typically created when an AI agent calls the onboarding endpoint and it defines the automation steps that AI agents will execute:

Step 2: Create .stride.md
3

Hook Environment Variables

When hooks execute, AI agents receive environment variables with task context:

  • TASK_ID, TASK_IDENTIFIER, TASK_TITLE
  • TASK_STATUS, TASK_COMPLEXITY, TASK_PRIORITY
  • BOARD_NAME, COLUMN_NAME, AGENT_NAME
These variables allow hooks to customize behavior based on the specific task and board context.
4

Hook Execution Requirements

All four hooks are blocking - they must succeed for the agent to proceed:

  • before_doing must succeed before the agent can claim a task
  • after_doing must succeed before the agent can mark the task complete
  • before_review must succeed before the task enters the review queue
  • after_review must succeed before the task is marked as done
If any hook fails (exits with non-zero code), the agent must fix the issue and retry. Failed hooks prevent the workflow from advancing, ensuring quality gates are enforced.

Remember: Hooks are for AI agent automation only. Regular board users won't trigger hook execution.

5

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.