Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Kiro Hooks Reference

Disclaimer: This document reflects our current understanding of Kiro’s hook system. It is a working reference for symposium development, not a substitute for the official docs. Details may be outdated or incomplete — always consult the primary sources.

Primary sources: CLI hooks · Agent configuration reference · IDE hooks

Kiro is Amazon’s AI coding agent available as an IDE (VS Code fork) and CLI. Both have hook systems but they differ in configuration format, trigger types, and capabilities.

Kiro CLI Agent Definition

Each .kiro/agents/*.json file defines a complete agent. All fields are optional; omitting a field has specific defaults.

FileScope
.kiro/agents/*.jsonProject
~/.kiro/agents/*.jsonGlobal

Agent Definition Fields

FieldTypeDefault if omitted
namestringDerived from filename
descriptionstring(none)
promptstring or file:// URINo custom system context
toolsarray of stringsNo tools available
allowedToolsarray of strings/globsAll tools require confirmation
toolAliasesobject(none)
resourcesarray of URIs/objects(none)
hooksobject(none)
mcpServersobject(none)
toolsSettingsobject(none)
includeMcpJsonboolean(none)
modelstringSystem default
keyboardShortcutstring(none)
welcomeMessagestring(none)

Critical: Omitting tools means the agent has zero tools. Use "tools": ["*"] for all tools, "@builtin" for built-ins only, or list specific tools.

Tools Field Values

  • "*" — all available tools
  • "@builtin" — all built-in tools
  • "read", "write", "shell" — specific built-in tools
  • "@server_name" — all tools from an MCP server
  • "@server_name/tool_name" — specific MCP tool

AllowedTools Field

Specifies tools that execute without user confirmation. Supports exact matches and glob patterns ("@server/read_*", "@git-*/status"). Does not support "*" wildcard for all tools.

Resources Field

  • "file://README.md" — load file into context at startup
  • "skill://.kiro/skills/**/SKILL.md" — skill metadata loaded at startup, full content on-demand

Custom agents do not auto-discover skills. They require explicit skill:// URIs in resources.

Kiro CLI Hooks

Configured inside agent configuration JSON files. Shell commands receive JSON on stdin and use exit codes for control flow.

Events

EventTriggerMatcher?Can block?
agentSpawnSession startsNoNo
userPromptSubmitUser submits promptNoNo
preToolUseBefore tool executionYesYes (exit 2)
postToolUseAfter tool executionYesNo
stopAgent finishesNoNo

Input Schema (stdin)

All events include hook_event_name and cwd.

userPromptSubmit adds:

  • prompt: string

preToolUse adds:

  • tool_name: string
  • tool_input: object (full tool arguments)

postToolUse adds:

  • tool_name: string
  • tool_input: object
  • tool_response: string

MCP tools use @server/tool naming (e.g., @postgres/query).

Exit Codes

CodeMeaning
0Success; stdout captured as context
2Block (preToolUse only); stderr sent to LLM as reason
OtherWarning; stderr shown but execution continues

Matcher Patterns

  • Tool name strings: execute_bash, fs_write, read
  • Aliases: shell, write
  • MCP server globs: @git, @git/status
  • Wildcards: *
  • Built-in group: @builtin
  • No matcher = applies to all tools

Execution Behavior

  • Hooks execute in array order within each trigger type.
  • Default timeout: 30 seconds (30,000ms), configurable via timeout_ms.
  • cache_ttl_seconds: default 0 (no caching). agentSpawn hooks are never cached.

Configuration Example

{
  "hooks": {
    "preToolUse": [
      {
        "matcher": "execute_bash",
        "command": "./scripts/validate.sh"
      }
    ],
    "postToolUse": [
      {
        "matcher": "fs_write",
        "command": "cargo fmt --all"
      }
    ],
    "agentSpawn": [
      {
        "command": "git status"
      }
    ]
  }
}

Each entry is a flat object with command (required) and optional matcher. There is no nested hooks array or type field.

Kiro IDE Hooks

Stored as individual .kiro.hook files in .kiro/hooks/. Created via the Kiro panel UI or command palette.

Hook File Format

name: Format on save
description: Run formatter after file saves
when:
  type: fileEdit
  patterns: **/*.ts
then:
  type: shellCommand
  command: npx prettier --write {file}

Trigger Types (10)

TypeTrigger
promptSubmitUser submits a prompt
agentStopAgent finishes responding
preToolUseBefore tool execution
postToolUseAfter tool execution
fileCreateFile created
fileEditFile saved
fileDeleteFile deleted
preTaskExecutionBefore spec task runs
postTaskExecutionAfter spec task runs
userTriggeredManual invocation

The IDE adds file-event and spec-task triggers not available in the CLI.

Action Types (2)

TypeDescription
askAgentSends a natural language prompt to the agent (consumes credits)
shellCommandRuns locally; exit 0 = stdout added to context, non-zero = blocks on preToolUse/promptSubmit

IDE Tool Matching Categories

read, write, shell, web, spec, *, @mcp, @powers, @builtin, plus regex patterns with @ prefix.

IDE Execution Behavior

  • Default timeout: 60 seconds.
  • USER_PROMPT env var is available for promptSubmit shell commands.

Environment Variables

No dedicated environment variables are documented for CLI hook execution. Context is passed via stdin JSON. The IDE provides USER_PROMPT for promptSubmit shell command hooks.

Custom Instructions (Steering)

Kiro uses “steering files” instead of a single instructions file:

ScopePath
Workspace.kiro/steering/*.md
Global~/.kiro/steering/*.md
StandardAGENTS.md at workspace root (always included)

Steering files support YAML frontmatter with four inclusion modes: Always, FileMatch (glob pattern), Manual (referenced via #name in chat), and Auto (description-based matching). Kiro also auto-generates product.md, tech.md, and structure.md.

Skills

ScopePath
Workspace.kiro/skills/<name>/SKILL.md
Global~/.kiro/skills/<name>/SKILL.md

Workspace skills take precedence over global skills with the same name. The default agent auto-discovers skills from both locations. Custom agents require explicit skill:// URIs in their resources field. Skills use SKILL.md with YAML frontmatter (name, description).

MCP Server Configuration

ScopePath
Workspace.kiro/settings/mcp.json
Global~/.kiro/settings/mcp.json
Agent-levelmcpServers field in .kiro/agents/*.json

Priority: Agent config > Workspace > Global. Format is JSON with mcpServers key, supporting command/args/env for stdio and url/headers for remote servers.

MCP Server Registration

In addition to hooks, symposium registers itself as an MCP server in the agent’s MCP config file. This provides an alternative integration path alongside the hook-based approach.

Configuration structure

The MCP server entry is added under mcpServers:

{
  "mcpServers": {
    "symposium": {
      "command": "/path/to/cargo-agents",
      "args": ["mcp"]
    }
  }
}
  • Project-level: .kiro/settings/mcp.json
  • User-level: ~/.kiro/settings/mcp.json

Registration is idempotent — if the entry already exists with the correct values, no changes are made. If the entry exists but has stale values (e.g. the binary moved), it is updated in place.