Answer: Use a bash case statement on the exit code ($?) to take appropriate action: 0 means success, 3 means MCP servers failed to start, and 4 means the requested agent or mode is not available. In a CI/CD pipeline, run the Kiro task with continue-on-error set to false. Status: Confirmed Entry: tool/kiro/commands-and-shortcuts/scripting-with-exit-codes Revision: 3 Digest: sha256:738a53f3ff22c2b8 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:44:32Z Last changed: 2026-11-20T13:31:58Z (CI/CD continue-on-error setting: — → false) Last verified: 2026-11-20T13:31:58Z Next check: 2026-11-21T13:31:58Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Success exit code | 0 | [1] | 2026-11-20 MCP startup failure exit code | 3 | [1] | 2026-11-20 Agent/mode unavailable exit code | 4 | [1] | 2026-11-20 CI/CD continue-on-error setting | false | [1] | 2026-11-20 Sources: [1] Amazon Web Services. "Exit codes - Commands and Reference - Docs - Kiro". https://kiro.dev/docs/reference/exit-codes/ Role: primary. Accessed: 2026-11-20T13:31:58Z Quote: "0 ) echo "Success"" (Supports: Success exit code) Quote: "3 ) echo "MCP servers failed to start"" (Supports: MCP startup failure exit code) Quote: "4 ) echo "Requested agent or mode not available"" (Supports: Agent/mode unavailable exit code) Quote: "continue-on-error : false" (Supports: CI/CD continue-on-error setting) Published: 2026-11-20T07:39:25Z Snapshot SHA-256: 6137bfd1d3bfef7777ad565e0657ccc240509e6976f98c2d05903ea49ab694ce (captured 2026-11-20T13:31:57Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T13:31:58Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:31:58Z Last attempt: 2026-11-20T13:31:58Z Notes and limitations: Extracted automatically from a single official source (section "Scripting examples"). Related: https://latestn.com/tool/kiro/commands-and-shortcuts/scroll-conversation-fullscreen How do I scroll through the conversation in Kiro CLI fullscreen mode? https://latestn.com/tool/kiro/commands-and-shortcuts/slack-slash-commands What slash commands are available in the Kiro Crew Slack interface? https://latestn.com/tool/kiro/commands-and-shortcuts/slash-command-best-practices What best practices should I follow when designing and using slash commands in Kiro? https://latestn.com/tool/kiro/commands-and-shortcuts/resume-last-session How do I resume a previous chat session in Kiro CLI? https://latestn.com/tool/kiro/commands-and-shortcuts/run-shell-command-composer How do I run a shell command from the Kiro Crew chat composer? https://latestn.com/tool/kiro/commands-and-shortcuts/save-load-session How do I save and load a chat session in Kiro? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T13:31:58Z | changed | CI/CD continue-on-error setting: — → false | [1] 2026-11-20T13:31:58Z | changed | Agent/mode unavailable exit code: — → 4 | [1] 2026-11-20T13:31:58Z | changed | MCP startup failure exit code: — → 3 | [1] 2026-11-20T13:31:58Z | changed | Success exit code: — → 0 | [1] 2026-11-20T13:31:58Z | changed | CI/CD setting: continue-on-error : false → — | [1] 2026-11-20T13:31:58Z | changed | agent/mode unavailable code: 4 → — | [1] 2026-11-20T13:31:58Z | changed | MCP startup failure code: 3 → — | [1] 2026-11-20T13:31:58Z | changed | success code: 0 → — | [1] 2026-11-20T13:31:58Z | changed | exit code capture: exit_code = $? → — | [1] 2026-11-19T13:23:02Z | changed | agent/mode unavailable code: — → 4 | [1] 2026-11-19T13:23:02Z | changed | MCP startup failure code: — → 3 | [1] 2026-11-19T13:23:02Z | changed | success code: — → 0 | [1] 2026-11-19T13:23:02Z | changed | exit code capture: — → exit_code = $? | [1] 2026-11-19T13:23:02Z | changed | Agent not found exit code: 4 → — | [1] 2026-11-19T13:23:02Z | changed | MCP startup failure exit code: 3 → — | [1] 2026-11-19T13:23:02Z | changed | Success exit code: 0 → — | [1] 2026-11-13T03:44:32Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/kiro/commands-and-shortcuts/scripting-with-exit-codes/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/kiro/commands-and-shortcuts/scripting-with-exit-codes POST: https://latestn.com/dispute/tool/kiro/commands-and-shortcuts/scripting-with-exit-codes with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/kiro/commands-and-shortcuts/scripting-with-exit-codes?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I handle Kiro CLI exit codes in a bash script or CI/CD pipeline? Revision 3, last verified 2026-11-20T13:31:58Z. https://latestn.com/tool/kiro/commands-and-shortcuts/scripting-with-exit-codes (accessed 2026-11-21T10:03:44Z). @misc{LatestN_tool_kiro_commands_and_shortcuts_scripting_with_exit_codes_r3, title = {How do I handle Kiro CLI exit codes in a bash script or CI/CD pipeline?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/kiro/commands-and-shortcuts/scripting-with-exit-codes}}, note = {Revision 3; digest sha256:738a53f3ff22c2b8; last verified 2026-11-20T13:31:58Z; accessed 2026-11-21T10:03:44Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/kiro/commands-and-shortcuts/scripting-with-exit-codes