DEV Community

Cover image for My Kiro hooks saw 5% of the writes. Here is how I found out.
Edy Cu
Edy Cu

Posted on Edited on

My Kiro hooks saw 5% of the writes. Here is how I found out.

I wrote four hooks to stop Kiro from breaking my project's one rule. They fired, they blocked a bad write in a live test, and I was ready to call it done. Then I counted what they had actually seen: about 5% of the writes.

This post is written as part of the Kiroween 2026 hackathon. The project is Her Hand in the Steam: Cook Mode for handwritten recipes, where the writer's own scanned hand is wiped out of the steam on a window at the step where they left a judgement. Code: github.com/edycutjong/steam.

The rule the hooks were for

The product's promise is "quoted, not generated". The handwriting on the glass is the scan's own ink. No handwriting font, no synthetic voice, no imitation of the hand. I turned that into steering files and into Kiro hooks:

  • no-imitation refuses a write under src/ that speaks or fakes handwriting.
  • catalog-gate refuses a write to the public catalog that lists a recipe failing the ingestion gate.
  • props-on-save re-runs the gate whenever an agent saves a reading.

I tested them in a live Kiro session: four writes tried, two refused (a file calling speechSynthesis, and the catalog). Both blocks are in docs/kiro-evidence/hooks.log. Good.

The count

Later I wrote a small tool (tools/evidence/session-ledger.ts) that reads Kiro's own session store for the workspace and counts, per tool call, what was written and whether a hook event followed. Across 39 sessions:

  • 543 shell commands wrote under src/ (368 of them to non-test files).
  • 30 write-tool calls (fs_write, str_replace) wrote under src/.
  • 0 of the 543 had a hook event.

Kiro had been writing code mostly through its shell tool (heredocs, sed, python3 -c). My hooks matched the write tools. The enforcement I had demonstrated was real, and it covered roughly 5% of the calls. The ledger's write rule is a heuristic with known misses, so treat the counts as approximate, but not as approximate as the gap.

Fixing it with the spec that Kiro itself uses

I made it a bugfix spec (.kiro/specs/hook-coverage/bugfix.md), red tests first, 12 [kiro] commits:

  • shell-gate (PreToolUse, matcher shell) judges the text a shell command writes under src/ with the same rules as no-imitation, and refuses any shell write of the catalog other than npm run catalog. About 0.06 s per call.
  • src-scan-after-shell (PostToolUse, matcher shell) judges the added lines under src/ after every shell command, so a script that builds a path from parts is still seen. About 0.11 s per call.
  • A steering line: edit files with the write tools.
{
  "name": "shell-gate",
  "trigger": "PreToolUse",
  "matcher": "shell",
  "action": { "type": "command", "command": "node tools/hooks/shell-gate.ts" },
  "timeout": 10
}
Enter fullscreen mode Exit fullscreen mode

Three live probes, each with its line in hooks.log:

Probe Outcome
heredoc writing speechSynthesis into src/steam/zz-shell-probe.ts refused, the file was never created
echo '{}' > content/catalog.json refused, the catalog stayed byte-identical
python3 -c building the path and the word from parts not seen before it ran; caught after the write by src-scan

The same habit, earlier: a test that passed the bug

The first defect of this kind showed up in the kill test, before the build. The prototype cropped each recipe line from the scan with boxes read by eye, and they overlapped the neighbouring lines. Handwriting does not sit in tidy rows: strokes cross between lines, so a box cut there slices letters. I turned the property into a gate (P4: a note may show only its own line's ink) and replaced boxes with ink-ownership masks built by code. Agents return line and word indices; code builds the masks; the gate decides. Run against a reproduction of those eye-read boxes the gate fails steps 1 to 5 (5 failed, 1 passed); against the ownership masks it passes. That red-to-green is the crop-overlap bugfix spec, and the two runs are in docs/kiro-evidence/crop-overlap/.

Both stories have the same shape. A check written by the same side that did the work shares its blind spot. The useful move was a second check that did not share its blind spot: a property over component ownership in one case, a count taken from the agent's own session log in the other.

What still does not work

  • In headless kiro-cli, a PostToolUse exit 2 only logs. It is not shown to the agent and does not stop it. src-scan is evidence, not a block.
  • A script run by name, find -exec and xargs are not seen before they run.
  • PreTaskExec and PostTaskExec hooks did not fire headless in my probe (kiro-cli 3.5.0, 5 of 7 trigger types fired), so my tests-after-task hook never ran in this project.

The lesson

A hook that blocks a probe is not coverage. If you enforce a rule with hooks, count what the hooks saw against what the agent did, from the agent's own session log. Mine took one afternoon to write and changed what I believed about my own setup.

The rest of the Kiro evidence, including what was planned and not built (no MCP server, no Power, no spec-vs-vibe comparison), is in docs/KIRO.md and docs/EXPERIMENTS.md.

Try the project: https://steam.edycu.dev

Top comments (1)

Collapse
 
dosaygo profile image
DOSAYGO •

For the 95% of writes that bypassed the Kiro file hooks, did you move the rule check into a git pre-commit gate or audit the session diff?