Kiro CLI returns specific exit codes to indicate operation status. Use these in scripts and CI/CD pipelines to detect success, failures, and specific error conditions.
| Code | Name | Description |
|---|---|---|
| 0 | Success | Command completed successfully |
| 1 | Failure | General failure (auth error, invalid args, operation failed) |
| 3 | MCP Startup Failure | A server required by --require-mcp-startup did not start |
By default, MCP server failures are logged as warnings but don't affect the exit code. Use --require-mcp-startup to wait for configured MCP servers before a run begins:
kiro-cli chat --require-mcp-startup --no-interactive "Run task"
If a required server does not start, Kiro CLI exits with code 3. In a non-interactive V3 run, this includes a server failure, an undetermined startup state, or no reported status within 30 seconds.
Handle different exit codes to take appropriate action in your automation:
#!/bin/bash kiro-cli chat --require-mcp-startup --no-interactive --trust-all-tools "Run analysis" exit_code=$? case $exit_code in 0) echo "Success" ;; 3) echo "MCP servers failed to start"; exit 1 ;; *) echo "Failed with code $exit_code"; exit $exit_code ;; esac
- name: Run Kiro task run: | kiro-cli chat --require-mcp-startup --no-interactive --trust-all-tools "Analyze code" continue-on-error: false
Hooks use a separate set of exit codes to control tool execution:
| Code | Behavior |
|---|---|
| 0 | Hook succeeded |
| 2 | (PreToolUse only) Block tool execution; STDERR returned to LLM |
| Other | Hook failed; STDERR shown as warning |
--require-mcp-startup in CI/CD when your tasks depend on MCP tools-v or -vv) when debugging exit code issues
Exit codes