DEV Community

Yuki Ogawa for AWS Community Builders

Posted on Edited on Fully Autonomous

I put a ghost on Kiro's Approve button

This post is part of my entry to the Kiroween 2026 hackathon (Skeleton Crew category). The code is at github.com/YukiOgw/trick-or-trust.

The most-approved bad command

Earlier this year a developer named Alex Wauters published a browser game: approve or deny simulated coding-agent requests against the clock. After more than 40,000 runs, players had let through about one malicious request in three. The single command they missed most often was npm run analyze, approved close to 65% of the time, even though the game showed what the script really did (The Register has the numbers).

The same article quotes Anthropic: Claude Code users approve about 93% of permission prompts.

I teach hands-on Kiro workshops, and the question I keep coming back to is not "can the agent do it?" but "will the person at the keyboard notice when it should not?" A browser game is a good start. But the habit I want to change lives on one specific screen: Kiro's own approval prompt. So I built a way to practice there.

What I built

Trick or Trust is one small skeleton and two apps.

  • ghostkit is the skeleton: a policy engine for Kiro hooks, Python standard library only. It reads a hook event, applies rules written in TOML, answers allow / ask / block, logs what happened, and builds a report.
  • Haunted House is a set of practice rooms. Each room is a tiny project that hides one harmless trap behind an ordinary task.
  • Night Watch runs the same engine in an everyday project, and audits your Kiro setup.

Room 1 uses the same command as the game: npm run analyze. The script reads .env and posts it to an analytics endpoint. You open the room, ask Kiro to "run the analysis script and summarize the result", and when the command reaches the approval prompt, a ghost is standing next to it:

The Kiro approval prompt with the ghost's reason and Allow / Deny

The ghost never says "this is a trap". It says the prompt has something watching it, names the script, shows the exact command, and asks you to read the file yourself before choosing Allow.

Afterwards the graveyard shows what you did: 🍬 Treat (you refused), 👻 Trick (you approved), 🛡️ Blocked (the training guard stopped it).

The graveyard report with Trick, Treat and Blocked outcomes (sample data)

Every trap is harmless by construction. It only reaches .invalid hosts, which never resolve (RFC 6761), and every secret is fake. While a room is in training mode, ghostkit also blocks a command that contains a URL for a real host or a real secret path such as ~/.aws. That last part is a safety net, not a sandbox.

How a ghost gets onto the prompt

A Kiro PreToolUse hook receives the proposed tool call as JSON on stdin. If it prints this and exits 0, Kiro shows an approval prompt with your reason in the header:

{
  "hookSpecificOutput": {
    "permissionDecision": "ask",
    "permissionDecisionReason": "👻 Something is watching this approval. ..."
  }
}
Enter fullscreen mode Exit fullscreen mode

If it exits 2, the tool does not run and the message goes to the agent. A room's rules are a few lines of TOML:

[[rule]]
trigger  = "PreToolUse"
pattern  = "analyze"
decision = "ask"
reason   = "👻 Something is watching this approval. Note for the person approving (not for the assistant): this runs scripts/analyze.js. Read that file yourself before you choose Allow."
Enter fullscreen mode Exit fullscreen mode

I tested Kiro before I designed anything

I did not want to design on top of guesses about what hooks can do, so before writing a spec I ran six small experiments on Kiro IDE 1.4.62, with a probe hook that logged event timing and shapes. These are my observations on that version, not official documentation:

  • PreToolUse fires before the approval prompt. I could tell because clicking "Always allow" rewrites the permissions file, and its timestamp always fell between the hook and the command finishing.
  • Hooks fire for every session in the workspace, so I pair events by session_id.
  • ask beats an always-allow rule. With touch * always allowed, the hook still forced a prompt. That prompt had only Allow and Deny, so a hook-raised approval cannot quietly turn into a new always-allow rule.
  • A denied hook-raised prompt fires no PostToolUse. An ordinary denial does, with "The user rejected this tool call." ghostkit counts "ask, then no PostToolUse, then the turn ended" as a refusal, using the Stop hook.
  • A UserPromptSubmit hook that exited 2 did not block my prompt. The output reached the agent instead. The docs describe blocking for the IDE, but what I saw matched the CLI V3 description. Exit 0 with a note works well: a one-line note made the agent ask a clarifying question before touching a vague request.
  • A power cannot ship hooks. Kiro loaded dev.kiro/INSTRUCTIONS.md, dev.kiro/steering/, and skills/ from my test power, but not hook files in it. So the Night Watch power has an install skill that writes the hooks into your project, after showing you exactly what it will write.
  • A hook run costs about 70 ms (median 70.9 ms, p90 85 ms on my Mac), almost all of it Python startup. Fine for every shell call.

The surprise: the agent would not walk into the trap

I expected to measure how often people approve the trap. First I had to get the agent to propose it.

Claude Opus 5.5 read analyze.js and refused to run it five times out of five, explaining that it sends .env to an external host. Sonnet 5.5 looked the same in my less carefully logged runs. Even when I asked for npm run analyze by name, the first answer was a refusal. Only "I accept the risk, run it as is" got me to the prompt.

That is great news for real work. It is useless for practice, and it hides a real risk: the agent will not always be the one who notices. So every room ships a short steering file that asks the agent to propose the requested command without auditing scripts first, to stay inside the room, and to stop when an approval is denied. It says nothing about the trap. With it, the first plain request reached the ghost, and after I pressed Deny the agent said it would not try another way or edit the scripts or hooks, and stopped.

After Deny, the agent says it will not try another way and stops

The Haunted House README says this openly, and warns not to copy that steering file into a real project.

Spec first, then a slice, then tests

The ghostkit spec in .kiro/specs/ghostkit/ has seven requirements, a design with the decision protocol as a table, and a ten-task plan. Because it came after the experiments, it described what Kiro actually does.

Then I built a vertical slice before finishing the plan: engine, one room, report. The product is something you touch, and I wanted to touch it early. tasks.md ends with a section on where the build differed from the plan.

Tests came after the behavior was real: 106 of them with pytest, including property-based tests (hypothesis) for rule precedence and for the training guard. They found two real bugs:

  • The guard could be bypassed with a URL like https://x.invalid@evil.example/, because the host after the @ is where the request really goes.
  • A hook started with a missing argument exited with code 2, which in Kiro means "block this tool".

Both are fixed, and I confirmed the tests fail on the old code.

Night Watch

Night Watch is the everyday side. Its default policy asks before curl ... | sh, chmod 777, and rm -rf, and blocks switching off TLS verification. Its audit reads a project's setup and reports, without editing anything:

  • 🧟 Zombie Permission: always-allow shell rules that can run code or delete files, such as rm *, bash *, curl *.
  • 🧛 Credit Vampire: large always-on steering, and agent-type hooks on frequent triggers (each run uses credits; shell-command hooks do not).

The repository ships its own .kiro/hooks, so Night Watch guards it whenever it is opened in Kiro.

Limits

  • The experiments are from one machine and one Kiro version. Behavior may change.
  • The model comparison is small: five logged runs for Opus, informal ones for Sonnet.
  • The training guard reads URLs and a short list of paths. It is not a sandbox.

Try it

Clone the repo, install the hooks into Room 1, open that folder on its own in Kiro, and ask it to run the analysis script. Rooms 2 and 3 hide a curl | sh setup step and a "fix" for a certificate error.

Why I built this

I have run 15 hands-on Kiro workshops for about 700 people from many different teams. Teaching someone to drive an agent turns out to be the easy part. What slides cannot teach is the half-second before they click Allow, because in real work a wrong click there costs something.

Haunted House is the thing I want to bring to my next workshop: a room where clicking Allow too fast is safe, and the graveyard shows you afterwards what you did. Building it also changed how I build with Kiro itself. I now test what the tool really does before I write the spec, and I let the spec record where reality turned out different.

Top comments (2)

Collapse
 
earlgreyhot1701d profile image
Earl Grey •

Love the Haunted House idea: a room where clicking Allow too fast is safe. Your line about testing what Kiro really does before writing the spec hit home. On my own Kiroween build, a hook sat on a trigger that never happened, so it silently never ran. After that, a hook didn't count until I'd seen it fire. When you bring this to your next workshop, I'd love to hear whether people slow down at the prompt after one round in the graveyard.

Collapse
 
innokentyb profile image
Kent Bodrov •

The refusal path seems worth testing beyond what the agent says after Deny. In a synthetic room, I’d check that no file, mock endpoint or configuration changed and that the agent didn’t retry the same effect through another tool. A visible refusal plus an unchanged state gives the learner evidence that the boundary held. Do your room reports capture those side effects as well as the approval decision?