I Put 166,700 Fly Neurons in a Browser. Kiro Helped Me Keep the Science Honest.
What happens when you connect a fruit fly's brain to a video game? Does the fly actually control anything? Or is the surrounding code doing all the work while the brain gets the credit? That question became Frankenfly,
What happens when you connect a fruit fly's brain to a video game?
Does the fly actually control anything? Or is the surrounding code doing all the work while the brain gets the credit?
That question became Frankenfly, my project for the Kiroween 2026 hackathon, entered under the Frankenstein category.
Frankenfly combines a real fruit fly's neural wiring map, a spiking-neuron simulation, a six-legged physics body, and a 3D platformer. You can watch recorded experiments, disconnect the code controlling parts of the fly, and inspect what its simulated neurons actually did.
There's also a live operating table where the entire brain network runs in your browser, and you can manipulate its connections while it fires.
But building something like this creates an interesting problem: how do you stop a fascinating scientific demo from making claims that its own results don't support?
That's where Kiro's approach to specs, steering, and verification became particularly useful.
This article was written as part of the Kiroween 2026 hackathon.
Meet Frankenfly
Frankenfly stitches together four technologies:
- Brain: MaleCNS v1.0, an electron-microscopy wiring map containing 166,700 neurons and 25,582,837 connections.
- Neural activity: A spiking-neuron model based on Shiu et al. (2024).
- Body: NeuroMechFly v2, a six-legged simulated fly.
- World: A 3D platformer with coins, enemies, and a finish line.
The brain is simulated using a wiring map derived from a real fruit fly. No living fly is involved.
The application has two main parts.
1. The Lab
Here, you replay recorded experiments and disconnect the programs surrounding the brain.
You can cut the WALK connection, removing our code's decision about when the fly walks. You can also cut SENSES, removing shortcuts our code uses to identify coins and enemies.
You can swap the original neural wiring for a scrambled version and compare the results.
A 3D visualization shows neural spikes alongside the recording, while a timeline reveals when those spikes happened relative to game events.
The results were revealing.
With the walking program disconnected, the fly's simulated walking neurons initiated movement in 16 out of 16 flies. They also stopped movement at 48 out of 48 coins.
But when we removed our sensory shortcuts, its escape neuron warned it in time for 0 out of 48 enemies.
In other words, the neural wiring was contributing to walking and stopping, but our code had been doing the work of recognizing danger.
Without that distinction, the demo could have told a very different story.
2. The Operating Table
The second half goes further.
Instead of replaying recordings, the Operating Table runs all 166,700 neurons and approximately 25.6 million connections live through WebGPU.
The network downloads in roughly 40 MB and runs on the visitor's graphics card.
Visitors can:
- Stimulate sensory neurons with virtual electrodes.
- Scramble the neural connections.
- Cut specific connections between neural populations.
- Disconnect entire cell types.
- Watch live neural firing rates.
- Listen to neural spikes as audio clicks.
There's even a circuit-screening tool.
Pick a neuron, and Frankenfly systematically silences its strongest input cell types, reruns the experiment, and measures what changes.
In one experiment, cutting 311 direct danger-to-escape connections revealed that the network still had an indirect route. Silencing a four-cell population called PVLP151 reduced the right escape neuron's firing rate from 44 Hz to 20 Hz.
On our test laptop, the circuit screens completed in roughly 12–20 seconds using integrated Intel Iris Xe graphics.
That's a scientific experiment someone can run directly in a web page.
Where Kiro came in
Frankenfly wasn't just a graphics project. It needed a development process that could keep the simulation, interface, experimental claims, and tests consistent.
We organized development around Kiro's approach to steering, specifications, implementation tasks, and correctness properties.
The repository contains the project specifications in its .kiro directory, making the intended behavior and verification rules visible alongside the code.
Steering: rules the project couldn't casually ignore
The first important piece was steering.
We created four documents under .kiro/steering/:
product.mdtech.mdstructure.mdscience-honesty.md
The most interesting is science-honesty.md.
It establishes rules about what the application is allowed to claim.
For example, we shouldn't say the simulated fly thinks, sees, or tastes. A spike in a simulated sugar-sensing neuron is not proof of subjective taste.
We also needed to distinguish what came from the neural model and what came from our own programs.
Every experimental result is attributed to the fly's simulated neurons, our code, both, or luck.
And rather than showing percentages that hide small sample sizes, the project displays counts like 16/16 or 0/48.
It's a surprisingly important distinction.
Imagine saying your AI-powered robot independently avoided 48 obstacles. Sounds impressive.
Now imagine discovering that your own obstacle-detection program identified every obstacle and told the robot when to react.
The robot might still be interesting, but you've suddenly got a very different scientific claim.
The steering rules helped us keep that difference visible.
Specs: turning a strange idea into testable requirements
Next came Kiro-style specs.
Under .kiro/specs/frankenfly-lab/, we organized the application into three documents:
requirements.md defines nine major requirements, R1 through R9, using EARS-style acceptance criteria.
For instance, when someone switches between real and scrambled wiring, the application must select the corresponding recorded experiment. It must never invent a recording for a configuration that wasn't simulated.
design.md describes the architecture, data flows, live GPU engine, and correctness properties.
tasks.md contains 68 implementation tasks, checked off as development progressed. Later review rounds became additional tasks with their own checks.
This made a complicated system easier to reason about.
The Lab's replay, brain visualization, neural timeline, and experimental scoreboard all need to agree about what happened and when.
Without explicit requirements, it's easy to build a beautiful interface that quietly displays the wrong experiment or attributes an action to the wrong source.
The spec made those behaviors things we could actually verify.
Property-based testing: test the rules, not just the examples
We also turned the design into eleven correctness properties, P1 through P11.
The repository contains 16 tests, including 14 fast-check property-based tests.
Instead of checking only a handful of manually chosen examples, property-based testing generates many inputs and verifies that important rules continue to hold.
Some examples:
P1: Timeline consistency
If we convert a simulated timestamp into a position on the timeline, then convert it back, we should recover the original time.
P5: Scrambled wiring
When we scramble the brain network, each neuron's number of incoming and outgoing connections must remain unchanged.
Otherwise, we aren't just rearranging the wiring; we're changing the structure of the experiment in another way.
P7: Connection encoding
The browser simulation uses a compact format for millions of neural connections. Encoding and decoding those connections must preserve their targets and signed connection counts.
P9: Neural surgery
When a visitor cuts connections between two populations, only those intended connections should change.
P11: Honest experimental conclusions
An experiment's result card must report numbers belonging to the selected brain and setup, rather than accidentally quoting results from a different experiment.
That last one is particularly relevant. A visually convincing result card is useless if its numbers describe the wrong brain.
Hooks and quality checks
We also defined four hook configurations under .kiro/hooks/.
They describe checks for:
- Scientific honesty whenever relevant user-facing files change.
- Data validation when experimental exports or results change.
- Syntax checking and property tests after an agent turn.
- On-demand Playwright screenshots at three viewport sizes.
The underlying commands include:
node tools/honesty_lint.mjs
node tools/validate_data.mjs
npm run syntax
npm test
npm run qa
The honesty checker flags language that overstates the experiment. The data validator independently recomputes scoreboard results from the recorded data.
We also run the checks through GitHub Actions before deployment.
One important clarification about our tooling: we had no Kiro credits during development, so Kiro's agent did not write the code or execute these hooks. Implementation was done with Claude Code following our Kiro-format specifications. The verification commands ran as local scripts and through CI, rather than as hooks executed inside Kiro.
The value of Kiro's approach for this project was the structured specification and verification workflow: requirements, architecture, scientific constraints, tasks, and properties that implementation could be checked against.
The hardest technical challenge
One of the biggest engineering problems was getting the complete neural network to run live in a browser.
We're talking about 166,700 neurons, 25.6 million connections, and neural simulation steps of 0.1 milliseconds.
That's 10,000 simulation steps per second.
The key optimization came from the model's fixed 1.8-millisecond synaptic delay.
Because a neural spike cannot influence another neuron until that delay has passed, the GPU engine can process 18 simulation steps before delivering the resulting spikes.
We implemented the live engine using WebGPU compute shaders, with integer atomic operations for spike delivery.
But making something fast isn't enough if the result is wrong.
We gave the WebGPU implementation and the original PyTorch simulator identical random input and compared their neural spike counts.
On our test hardware, they matched neuron by neuron for the checked intervals.
For example, the danger-cell experiment produced 3,057 spikes in both implementations over 504 milliseconds.
The live simulation also kept up with real time on our Intel Iris Xe graphics during testing, even at around 480,000 spikes per second.
The comparison does have hardware-dependent limitations: GPU rounding differences can eventually cause individual spikes to diverge. We document those limitations rather than promising identical results everywhere.
What Frankenfly taught us
The most surprising result wasn't simply that a fly's wiring could contribute to movement in a simulation.
It was how much the surrounding software mattered.
With our danger-detection shortcut connected, the escape neuron responded in time for 48 of 48 enemies.
Without it, the escape neuron responded in time for none of 48.
The scrambled network also became nearly silent, which limits what that control experiment can establish.
And strong bitter stimulation caused runaway simulated activity, exposing a limitation of the simple neural model.
Those are important outcomes, even when they make the demo seem less impressive.
This is where the Kiro-style workflow earned its place.
Our requirements and correctness properties weren't just about getting the application running. They helped define what the application needed to demonstrate, what its tests should establish, and what its conclusions could reasonably say.
Try Frankenfly yourself
Frankenfly is open source, and the application includes a guided five-minute tour through both halves.
You can cut the walking connection, watch its simulated neurons respond, compare against scrambled wiring, and run your own experiments on the live brain.
Links:
Frankenfly was built for the Kiroween 2026 hackathon, Frankenstein category.
We wanted to combine technologies that don't normally belong together. We ended up with something that makes it possible to examine the difference between a neural network's behavior and the software surrounding it.
And perhaps that's the most useful lesson from the project:
A good experiment shouldn't just make something impressive happen. It should make it possible to discover who, or what, actually made it happen.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.
