Module 5 of 9 · Spec-Driven Development with Kiro · Intermediate

Hooks: Automating Your Workflow

Duration: 5 min

Kiro hooks are event-driven automations that trigger Kiro actions when something happens in your project — a file is saved, a spec is updated, or a task is completed. They let you encode your team's workflow into the project itself.

Hook configuration

Hooks are defined in .kiro/hooks/ as YAML files. Each hook specifies a trigger (file glob, event type) and an action (a prompt Kiro runs automatically).

name: Generate tests on implementation
trigger:
  type: file_change
  glob: "src/**/*.ts"
  exclude: "**/*.test.ts"
action:
  prompt: |
    A source file was just modified: {{changed_file}
    If there is no corresponding test file, create one.
    If a test file exists, update it to cover the new changes.
    Follow the existing test patterns in the project.

Try it in Google Colab: Open in Colab

💡 Tip: Start with one or two hooks. Over-automating early creates noise. Add hooks when you notice yourself doing the same manual step repeatedly.

Common hook patterns

name: Sync API docs on route change
trigger:
  type: file_change
  glob: "src/routes/**/*.ts"
action:
  prompt: |
    The file {{changed_file} was modified.
    Update docs/api.md to reflect any new or changed
    endpoints, request shapes, or response formats.

❓ What is a Kiro hook?

← Previous Continue interactively → Next →

Related Courses