Kiro CLI Hooks
Akto Guardrails for Kiro CLI brings real-time security validation to AI interactions by hooking into Kiro CLI's native lifecycle hooks — validating prompts and tool calls before they execute, and reporting every event to your Akto dashboard.
Key Features
✅ Zero Installation - No standalone apps to install
✅ Transparent Integration - Uses Kiro CLI's native hook mechanism
✅ Real-time Protection - Validates every prompt and tool call
✅ Centralized Monitoring - All events reported to Akto dashboard
✅ Flexible Deployment - Supports Argus and Atlas modes
✅ Configurable Behavior - Blocking or observation modes
How It Works
Kiro CLI's hook system executes custom scripts at three points:
3 Hook Points:
userPromptSubmit- Ingests prompts before they're sent to the model. Cannot block — a non-zero exit only shows the user a warning, the prompt still proceeds.preToolUse- Validates tool requests before execution. The only event that can block: exit code2rejects the tool call.postToolUse- Ingests tool input/output after execution (observational only).
File Structure
Key Files:
Wrapper scripts (
.sh): Set environment variables, invokeakto-hooks.py⚠️ Contains
AKTO_DATA_INGESTION_URLplaceholder - Must be replaced with your Akto instance URL
akto-hooks.py: Single dispatch script — routespreToolUseto a blocking runner,userPromptSubmitto a warn-only runner, and everything else to an observability-only runnerakto_ingestion_utility.py: Core validation/ingestion logic and Akto API communicationakto_machine_id.py: Generates unique device identifiers for Atlas modeAgent config (
hooksblock): Links hooks to wrapper scripts
Setup Guide
Prerequisites
Kiro CLI installed (Installation Guide)
Akto instance URL
Python 3.7+
macOS, Linux, or Windows with bash/zsh
Installation Steps
Create Directories
Download Hook Scripts
Configure Akto Ingestion URL, API Token and Device ID ⚠️ CRITICAL STEP
All wrapper scripts contain the placeholders {{AKTO_DATA_INGESTION_URL}}, {{AKTO_API_TOKEN}} and {{DEVICE_ID}} that must be replaced — the URL with your actual Akto instance URL, and the token with your Akto API token (obtain it from Akto Atlas → Connectors → Setup Guardrail card). If your deployment does not require auth, set the token to an empty string so the placeholder is removed (an unsubstituted {{AKTO_API_TOKEN}} would be sent as an invalid Authorization header).
DEVICE_ID becomes the first label of the reported hostname (<DEVICE_ID>.ai-agent.kirocli), and the dashboard displays that label verbatim as the device name. An unsubstituted {{DEVICE_ID}} is not treated as empty — leave it in and every machine in your org reports the literal string {{DEVICE_ID}}, collapsing them all into a single device.
Automated replacement:
Manual replacement (alternative):
Edit each wrapper script and replace:
With:
Files to update:
akto-validate-prompt-wrapper.shakto-validate-pre-tool-wrapper.shakto-validate-post-tool-wrapper.sh
Configure Hooks
Merge the hooks block below into your kiro-cli agent config (~/.kiro/agents/<agent-name>.json, or edit via kiro-cli agent edit):
Configure Hook Behavior (Optional)
Edit wrapper scripts to customize:
Mode Options:
Argus: Standard validation and reporting
Atlas: Includes device-specific metadata
Sync Mode:
true: Blocks threats on
preToolUse(exit code2)false: Reports but allows execution
Install Python Dependencies
Verify Installation
Check logs to confirm hooks are working:
Test by running a Kiro command:
You should see log entries indicating validation occurred.
Configuration Reference
Wrapper Script Variables
How DEVICE_ID is reported: the hooks send <DEVICE_ID>.ai-agent.kirocli as the request host, and the dashboard uses the first label of that host as the device name. If DEVICE_ID is empty the hooks fall back to the lowercased computer name (or, where that cannot be resolved, the raw machine UUID — which is why a device sometimes shows up as a bare hex string).
Environment Variables (Optional)
Override defaults via environment variables or config file:
Option 1: Environment variables
Option 2: Config file
Troubleshooting
Hooks Not Executing
Ingestion URL Not Configured
Check Logs for Errors
Events Not in Dashboard
Python Dependencies Missing
Uninstallation
To completely remove Akto hooks from Kiro CLI:
Complete Removal
Selective Removal (Keep Logs)
If you want to preserve logs for audit purposes:
Backup Before Removal
Verify Removal
Restore Kiro CLI to Default
After uninstallation, Kiro CLI will operate without Akto security monitoring. No additional configuration is needed beyond removing the files and the hooks block. Test with:
Enterprise Deployment
Automated Deployment Script
Deploy to developers:
Quick Setup Summary
Resources
Support: support@akto.io
Community: https://www.akto.io/community
Last updated