Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 5 min read

Building phone controllers for the web in 19 days with Kiro

This post is being written as part of the Kiroween 2026 hackathon. Phones are full of sensors, but using one as a game controller in a web page is awkward. You usually need an app. On iPhone, Safari wants HTTPS and a ta

Building phone controllers for the web in 19 days with Kiro

This post is being written as part of the Kiroween 2026 hackathon.

Phones are full of sensors, but using one as a game controller in a web page is awkward. You usually need an app. On iPhone, Safari wants HTTPS and a tap for every permission, and it pauses your page when the screen locks.

I wanted to solve that once, as a kit, and prove it with two very different apps. So I built Haunt Kit: scan a QR code, tap once, and your phone's tilt, shakes, microphone loudness and taps reach the web app. Nothing to install.

  • SΓ©ance Party is a Halloween party game for up to 8 players on a big screen. Everyone's tilt is averaged to steer one Ouija planchette. You dance while a ghost looks away and freeze when it turns. The loudest scream wins.
  • Steady is a home physical-therapy rep counter. It counts reps out loud, says "too fast" or "not full range", and makes a report you can print for your therapist. Its data never leaves the phone.

Live demo: https://haunt-kit-seance.pages.dev Β· Code: https://github.com/Kiroween2026/Haunt_Kit

Here is what I learned using Kiro to build it.

The spec found a hole before any code existed

I wrote a spec for the message protocol first: requirements, design, tasks. Writing the design, I saw that my message list had no way for a game screen to create a room, or to get the room back if its connection dropped. I had three message types to add. That was a five-minute edit in a spec, and it would have been a day of rewrites once the relay and the phone page depended on the old list.

Property tests found bugs that example tests missed

I used fast-check, which generates hundreds of random inputs, and Kiro wrote most of the tests. They found four real problems:

  • A batch that could not be sent. I allowed 64 sensor samples per message. The test passed, because fast-check makes short arrays by default. A worst-case check showed 64 long numbers come to about 21 KB, over my 16 KB limit. A message could pass validation and still fail to send. I lowered the limit to 32 and added a test for the worst case.
  • A key that changed a message. A test failed in CI on a new random seed: a gesture with the data key __proto__ arrived as {}, because the validation library silently drops that key. The game would have received a different message than the phone sent.
  • Bots that could never spell BOO. In the Ouija game a letter can't be picked twice in a row. A perfectly aimed bot never moved off the letter, so it could never spell BOO or SPOOK. Only the clumsy bots succeeded, by accident.
  • Wrong gravity. My simulator's gravity formula had two signs wrong. Every test passed, because I had written the tests with the same wrong formula. A teammate's recordings of a real phone showed an error of 8 to 19 m/sΒ². Now a test checks the simulator against the real recordings.

The lesson I keep coming back to: plant a bug on purpose to check that a test can fail. I did this with several tests. One of them, "a player who left the game never wins", passed even with the bug in, because a leaver rarely leads a random game. Only a more direct test caught it.

Hooks, agents and steering

  • Steering files told every Kiro session the same rules: audio never leaves the phone, the iPhone limits, who owns which folder, and what the message protocol guarantees.
  • A hook turns a .gesture.md spec into a detector. When Kiro saves a spec, a small script checks that all seven sections are filled in and prints a work order: write the detector, add a property test for every "must not fire when" line, register it, run the tests. For a "double shake" gesture it produced a detector and 11 tests. Kiro's hooks fire when Kiro itself saves a file, and a command hook receives the event as JSON on STDIN. A small tested script was simpler and more reliable than a long prompt.
  • Two custom agents: one that fixes a misfiring detector using real sensor data and must show before and after numbers on every recording, and one that reviews UI against our design rules and can't edit files.
  • A SΓ©ance MCP server I wrote, so Kiro can look at a live phone before it changes a threshold. It lists phones, reads sensor statistics, records motions and replays them as fake players. It only works against the local dev relay, behind a token.

The things that went wrong

My first deploy looked green, but three of the pages had silently failed ("wrangler not found"), because my shell script never stopped on errors. A later version stopped on errors and curled every page to check it. Cloudflare also taught me two error codes: 7003 (my account ID and token were pasted into each other's secret) and 9109 (the token only worked from my own IP address).

Our team only had iPhones, so I built a desktop simulator and "ghost players" that replay recorded sensor data, and ran the browser tests on Safari's engine. I'm still missing real Android testing.

A few lines to use it

const room = await createRoom({ relayUrl, controllerUrl });
document.body.insertAdjacentHTML("beforeend", room.qrSvg); // QR code for phones
room.on("player_joined", (p) => room.setUi(p.playerId, { view: "tilt", title: "Steer!" }));
room.on("frames", ({ playerId, samples }) => { /* tilt, shake, loudness */ });

No relay? createMockRoom({ ghosts: [{ name: "Casper" }] }) gives you fake players.

What I'd tell someone starting with Kiro

  1. Write the spec first, even a short one. It was the cheapest place to find mistakes.
  2. Let Kiro write tests, but make it show that they can fail.
  3. Use real data as early as you can. Simulated data told me everything was fine when it wasn't.
  4. Give each tool one job and a limit. My agents that can only run test commands and only edit one folder were the ones I trusted.

The whole project, including the specs, hooks, agents and the MCP server, is open source: https://github.com/Kiroween2026/Haunt_Kit

Thumbnail

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.