Kiro Hooks Pack: 13 Ready Agent Hook Files (v1 JSON), Simulator, Linter and Migrator

Give Kiro guard rails and good habits in five minutes, with hooks that run in Kiro 1.0 and not just in old blog posts.

Kiro Hooks Pack: 13 Ready Agent Hook Files (v1 JSON), Simulator, Linter and Migrator product illustration

What it does

13 ready Kiro agent hook files (16 hooks) in the current v1 JSON format (.kiro/hooks/*.json, Kiro IDE 1.0+ and CLI V3), the Python scripts they run, a linter, an offline simulator, 38 policy tests and a migrator for old .kiro.hook / CLI 2.x hooks.

Python 3.9+, standard library only, no network, no API keys. The scripts need git for the git-aware hooks.

60-second demo

./tools/demo.sh

It installs the recommended hooks into a throwaway repo, then shows rm -rf /, a write to .env and a non-allowlisted MCP call being blocked, and npm test going through.

Install into your project

python3 tools/install.py /path/to/repo --set recommended --dry-run   # see what changes
python3 tools/install.py /path/to/repo --set recommended

Sets: safety, quality, context, opt-in-agent, recommended (safety + quality + context) and all. Or pick hooks: --hooks guard-shell,stop-run-tests. Windows: add --python python (or py) so the commands match your Python launcher.

The installer copies hooks/<name>.json to <repo>/.kiro/hooks/, the scripts to <repo>/.kiro/hook-scripts/, never overwrites your config files, keeps a .bak-<time> copy when you --force an update, adds .kiro/hook-scripts/.state/ to .gitignore, then lints the result. Kiro picks the hooks up when the next session starts.

The hooks

filetriggerwhat it does
guard-shell.jsonPreToolUse shellBlocks rm -rf on / ~ $HOME . .. *, force pushes to main/master/production/release, git reset --hard, git clean -fd, curl|sh, chmod 777, mkfs/dd, DROP DATABASE/TABLE from a CLI, terraform destroy, kubectl delete --all, sudo rm. Add your own regexes in config/shell-deny.txt.
protect-secrets.jsonPreToolUse write + shellBlocks agent writes to .env, keys, secrets/, .git/ and the hook folders themselves (so the agent can't switch its own guard rails off). Catches shell redirects, sed -i, cp/mv/rm too. .env.example stays editable.
mcp-allowlist.jsonPreToolUse @mcpOnly the MCP servers/tools in config/mcp-allow.txt run; !server/tool lines deny.
prompt-secret-guard.jsonUserPromptSubmitStops prompts containing OpenAI/Anthropic/AWS/GitHub/Slack/Stripe/Google keys, JWTs or private keys (blocks in the IDE; the CLI can't block prompts, so there it warns).
audit-tool-calls.jsonPostToolUseOne JSON line per tool call in .kiro/hook-scripts/.state/audit.jsonl, secrets redacted.
format-on-save.jsonPostFileSaveFormats and lints only the saved file with the repo's own prettier/eslint, ruff/black, gofmt or rustfmt; lint problems go back to the agent. Missing tools are skipped.
stop-run-tests.jsonStopRuns your tests when a turn changed code and sends the agent back to fix failures. Loop-safe: skips unchanged trees, max 2 retries per session, always exits 0 (see below).
spec-task-gate.jsonPreTaskExec + PostTaskExecRefuses to start a spec task with conflict markers or a merge/rebase in progress; runs the tests after each task.
session-context.jsonSessionStartBriefs the agent: branch, uncommitted files, last commits, test command, your config/session-notes.md.
compaction-memory.jsonPreCompact + PostCompactSaves a work-in-progress snapshot before compaction, tells the summarizer what to keep, and re-injects your rules + changed files afterwards.
new-file-tests-reminder.jsonPostFileCreate (agent, off)Opt-in: asks the agent to add a test for each new source file. Uses credits.
i18n-sync.jsonPostFileSave (agent, off)Opt-in: marks missing/changed keys in other locales when the English file changes. Uses credits.
changelog-on-stop.jsonStop + confirm (off)Opt-in: asks before appending this session's commits to a CHANGELOG draft. Shows the confirm block.

Settings live in .kiro/hook-scripts/config/ (plain text, one entry per line): protected-paths.txt, protected-branches.txt, shell-deny.txt, mcp-allow.txt, test-command.txt, stop-max-retries.txt, after-compact.md.

Why the Stop hook is written the way it is

On Stop, Kiro treats exit 1 as "start another agent turn". A hook that runs npm test directly will therefore keep the agent going every time a test fails, with no reason attached, and can loop. stop_checks.py instead prints {"decision": "block", "reason": "<failing output>"} and exits 0, caps retries per session and skips turns that changed nothing. The linter flags the risky pattern (K115).

Simulate before you trust it

python3 tools/simulate.py --trigger PreToolUse --tool execute_bash --input '{"command": "git push -f origin main"}'
python3 tools/simulate.py --trigger PreToolUse --mcp github/delete_repository --input '{}'
python3 tools/simulate.py --trigger PostFileSave --file src/app.ts
python3 tools/simulate.py --cases policy-tests/cases.json        # 38 allow/block cases, exit 1 on any mismatch

The simulator builds the event JSON Kiro sends on stdin, applies Kiro's matcher rules (tool tags like shell/write/@mcp, @server/tool, * wildcards, regexes, execute_bash = execute_pwsh), runs the matching command hooks in your project, and explains the result with Kiro's exit-code rules (0 allow + context, 2 block on PreToolUse/PreTaskExec/IDE prompts, Stop continue semantics). Agent actions are shown, never sent to a model. Run it from the project root, or pass --root.

Lint

python3 tools/kiro_hooks_lint.py --project .           # .kiro/hooks in this repo (add --global for ~/.kiro/hooks)
python3 tools/kiro_hooks_lint.py --project . --strict --json

Finds hooks that silently never run: old camelCase triggers (fileEdited, agentStop), file matchers written as globs (src//*.ts is a regex in v1, so it doesn't match), legacy .kiro.hook files and when/then keys, runCommand/askAgent action types, CLI 2.x tool names (fs_read, execute_cmd), bad regexes, missing commands/prompts, matchers on triggers that ignore them, agent actions on high-frequency triggers (credit burn), Stop loops, broken script paths, bad timeouts and confirm blocks. examples/broken/ shows every check.

Migrate old hooks

python3 tools/migrate_legacy.py .kiro/hooks --dry-run        # IDE 0.x *.kiro.hook -> v1 .json (globs become regexes)
python3 tools/migrate_legacy.py --agent .kiro/agents/dev.json  # CLI 2.x object-form hooks -> one standalone v1 file

Old files stay on disk. userTriggered hooks have no v1 trigger, so they become a manual steering file you run as /<name>. The migrator lints what it writes and tells you about loops and renamed tool groups.

Use it in CI

- run: python3 tools/kiro_hooks_lint.py --project . --strict
- run: python3 tools/simulate.py --cases policy-tests/cases.json

How it was tested

./run_tests.sh (23 tests) installs every set into temporary git repos, runs all 38 policy cases through the real scripts, checks the Stop loop guard and retry cap, the spec-task gate, compaction snapshot/restore, audit redaction, matcher semantics, the linter on the broken examples, both migrations and the installer (dry run, idempotence, config kept, backups). Run on Python 3.13 and 3.10.

Honest limits

  • Built from the Kiro hooks documentation as of November 2026 (IDE 1.x, CLI V3). Kiro changes fast: if a trigger or payload field changes, the linter and simulator follow the docs, not your build. Re-run the policy tests after upgrades.
  • The event payload field names for file paths aren't fully documented, so the scripts read several (file_path, path, tool_input.path ...) and {{filePath}}.
  • The simulator models Kiro's documented matcher and exit-code rules; it is not Kiro. The built-in tool list is the documented subset; ask Kiro for the ids in your version.
  • Shell rules match command text, so they are guard rails, not a sandbox. Combine them with Kiro's own permissions.
  • Not affiliated with Amazon Web Services or Kiro.

Format and license

Zip, 53 KB, v1.0, 56 files. You may use and modify this kit for your own work and for clients you serve, including paid client work. Not affiliated with Amazon Web Services or Kiro.

FAQ

Does it work with the Kiro CLI too?
Yes. v1 hook files in .kiro/hooks run in Kiro IDE 1.0+ and CLI V3. The README notes the few triggers that only run on one surface (SessionEnd is CLI only; compaction hooks need IDE 1.4.121+ / CLI 3.1.0+).
My old .kiro.hook files stopped working. Can it fix them?
Yes. tools/migrate_legacy.py converts IDE 0.x .kiro.hook files and CLI 2.x object-form hooks to v1 JSON, turns globs into regexes and lints the result. Your old files stay on disk.
Do the hooks use credits?
The command hooks don't: they run local Python scripts. The 3 agent (prompt) hooks start an agent turn and use credits, so they ship disabled.
How do I get the files?
Pay by card right here on youraitools.co: your download links appear on this page the moment the payment goes through (claim window: 72 hours, up to 5 downloads per 7 days). Need the files re-sent later? Email hello@youraitools.co.
Refunds?
Email hello@youraitools.co within 14 days if it doesn’t work and we can’t fix it.
Can I pay with crypto?
Yes. Pay the same price in USDC or USDT on Base, Ethereum, Arbitrum, Optimism, Polygon or Solana from the "Pay with crypto" button, with no account or KYC. We check the payment on-chain and show your download links as soon as it confirms.

Get Kiro Hooks Pack: 13 Ready Agent Hook Files (v1 JSON), Simulator, Linter and Migrator

13 tested Kiro agent hooks in the v1 JSON format: shell and secrets guards, MCP allowlist, loop-safe test-on-stop, format-on-save, compaction memory. $15.

Pairs well with

Related

1 email a week: new x402 + MCP tools and free kits.

Short weekly digest of new x402 + MCP tools and free kits, including the MCP OAuth Checker. No spam, unsubscribe any time.