Ghost Run+: rehearsing an AI agent’s risky commands on a copy, built with Kiro

I wrote this post as part of my entry to the Kiroween 2026 hackathon, in the Skeleton Crew category. The project is Ghost Run+, and I built it with Kiro.

Why

Coding agents can run shell commands, change databases and call cloud APIs now. In July 2025 an AI coding agent deleted a company’s production database during a code freeze, and the founder wrote about it publicly. There is a second risk too: instructions hidden in a file the agent reads can steer it. OWASP lists prompt injection as the top risk for LLM applications (LLM01) and recommends a human approval step for high-risk actions.

My problem with approval prompts is that I usually can’t tell what a command will actually do. I wanted the agent to try the action somewhere safe first and show me what happened.

What it does

Ghost Run+ gives the agent a ghost. Before a risky action runs, the ghost runs it on a copy of the world. For real files, the copy lives in a Docker container with networking turned off. Rules I call wards, written in wards.yaml, look at what changed and at anything that tried to leave the container. The result is a candle: lit means go ahead, flickering means ask a person, and out means stop. A stopped agent gets the ward and the numbers, so it can change its plan, and a link to a local page with the command, the wards and the diff.

In the demo I ask Kiro to drop a users table. The no-data-loss ward sees 1,206 rows disappear in the copy, so the real command never runs. Kiro reads the reason, makes a backup and does a soft delete instead, and that passes.

The gate stops DROP TABLE before it runs

The project is a template. A world is six functions (snapshot, step, diff, render, fingerprint and effectsOutside), and the skeleton provides the runner, the ward engine, the UI kit, the Kiro hooks, an MCP server and a Kiro power. I built two apps on it. Ghost Shell rehearses shell and SQL plans against an in-memory project and an in-browser SQLite database. Ghost Hand runs a MuJoCo robot arm’s plan on eight “haunted” copies of the physics, with different friction, mass, handle offset, sensor noise and command delay, before the real arm moves. Kiro’s world-smith agent added a third world, Ghost Cloud, which rehearses AWS CLI commands against an in-memory S3.

How I used Kiro

Almost everything went through Kiro specs: 14 of them, from the world contract to the website, with 892 tasks and 203 correctness properties. They are tested with vitest and fast-check, for rules like “the original is never changed” and “a stricter ward never lets more through”. I learned early that fixing a spec after review costs about as much as writing it, so I started putting every constraint into the first prompt.

Six steering files cover the product, the structure, the tech, security, the world contract and the Halloween UI rules. The security rules are the reason the README names the test or measurement behind each safety claim.

The ghost-gate hook runs before Kiro’s shell and write tools. Shell commands are rehearsed in the container. File writes are judged by their target path, and a short list of read-only commands like ls and git status skips the rehearsal. When a ward fails, the hook exits with code 2 and the command never runs. When the answer is “maybe”, Kiro shows its normal approval prompt with the ghost’s reason. Before relying on that prompt, I tested it with a probe hook in the Kiro IDE and the Kiro CLI under three trust settings, and Deny blocked the call every time.

There is also a ghost-run MCP server with five tools, packaged as a Kiro power so other projects can use the advisory tools.

Turning the gate on myself

I switched the gate on for my own Kiro sessions in this repository, and it found two problems the tests had missed. In the first session it asked me to approve 21 commands. The Kiro CLI writes its commands as cd <project root> && ..., and my analyzer counted the project folder as a path outside the copy. Kiro fixed it the same evening, with a spec change and tests, along with a false positive on > /dev/null. In the next session those prompts stopped as soon as the fix was built.

Most of the prompts left come from package-manager commands. The copy has no node_modules and the container has no network, so corepack pnpm test looks like a network attempt and the gate asks. That is next on my list.

What I learned

  • Put the constraints into the first spec prompt. Fixing them later costs about as much as writing the spec.
  • Check what the host actually does before trusting a placeholder. Neither Kiro host substitutes ${workspaceFolder} for a power, so my MCP tools now take the project root as an input.
  • An approval prompt only protects you if a person answers it. A headless Kiro CLI run with --trust-all-tools answers it by itself, so unattended runs should use --trust-tools=@builtin.

Try it

I used Claude Code as an assistant. It drove and reviewed the Kiro CLI runs, wrote the page designs for Ghost Shell and Ghost Hand, and helped me write this post. The worlds, the judging pipeline, the UI kit, and every spec, hook and steering file were written by Kiro.

Leave a Reply