Compose HotSwan Blog
From a Generation Loop to a Decision Loop: The Compose HotSwan CLI
December 6, 2026 · 8 min read

Hot reload matters even more now that AI agents write so much of our code. Getting new code has never been cheaper, but the build that shows it to you costs exactly what it did before.
Compose HotSwan 2.4.0 added a command line, hotswan, built for that gap, and 2.4.1 taught it to set HotSwan up in your project. It runs the whole hot reload loop from a terminal, for you or for a coding agent, and after every save it tells you whether the change actually reached the screen. When HotSwan became free, I wrote that a CLI was next. This is it.
In this article, you'll look at the build tax and two ways an agent loop can run, see why the loop needed a command line, and walk through what hotswan does: a verdict for every save, the screen as text, and the pieces that plug it into your agent.
The build tax
Say you are working on a detail screen, seven screens deep, and you change one font size from 16 to 18. That is one number. To see it, you build, install, launch, and tap seven times to get back. By then, your scroll position and the data you loaded are gone, and you do it all again for the next small change.
Some simple math, as an example rather than a benchmark: twenty small changes a day at two minutes a round trip is forty minutes, every day. For me, losing the context is worse than losing the time. By the time the screen is back, you are comparing it with your memory of the previous version.
New code on top of old state
Hot reload is the way out, and its definition is short: new code on top of old state. You edit the code in your IDE, or from the command line. When you save, or a terminal triggers a reload, the change goes into the app that is already running. No rebuild, no reinstall, and you stay on the same screen.
The state is the point. Without it, hot reload is just a faster rebuild, because you still have to find your way back to the screen and the data you were looking at. HotSwan keeps it through structural changes too: a new composable, a new branch, or a whole screen rewritten with new functions and classes. The 2.0 post explains how.
From a generation loop to a decision loop
Today, many of us don't hand-tweak code anymore, and sometimes we don't open an IDE at all. An agent writes and rewrites a whole screen, with new functions, new classes and new parameters at once. Without hot reload, that becomes a generation loop: the agent writes the code, you rebuild, reinstall, tap back to the screen and read the diff, and every round, the app starts over.

When hot reload survives structural changes and keeps the state, the loop changes shape. The agent edits the code, the device shows it within seconds, and you look and choose. That is a decision loop. In the KotlinConf app, a general edit reaches the screen in about 6.2 seconds at the median, about 60 percent of it in the Kotlin compiler, and a literal edit such as a number or a color takes 177 milliseconds on an emulator, on a fresh app.
The clip below, recorded with the IDE plugin, shows the shape of it. An agent applies a restyle of the For you screen of Now in Android that was prepared in four stages, writing each stage into the same file about five seconds apart, and the screen on the emulator updates after every write while the app keeps running.
New code is cheap now, so the expensive part is deciding. When every step shows up on the device, you see a wrong turn while the agent is still making it, move to a different direction right away, and spend fewer tokens on a path you would have thrown away. You don't have to wait for the agent to finish, look at the final result, and start the tweak loop over. Until you see a change running on the screen with your real state, it is hard to know whether it is right.
Why a command line
Until 2.4.0, the IDE sat at the center of that loop, and agents reached it through the MCP server bundled with the IDE plugin. But much of the work with agents now happens in the terminal, where they already run builds and tests, often with no IDE open at all.
An agent also needs something the IDE never had to give: a verdict. You glance at the device and know. An agent cannot see the screen, so it has to be told, in a form it can read, whether its edit was applied, whether it reached the screen, and if not, why. hotswan is the decision loop as a command, with that verdict at the end of every save. It uses the same Gradle plugin and runtime as the IDE plugin, so there is nothing new to add to your app.
Getting started
Install the CLI with one line. It needs Java 17 or newer and adb:
1curl -fsSL https://hotswan.dev/install.sh | sh -s -- --add-to-pathThen, in your project, three commands take an Android device or emulator from a project without HotSwan to a verified reload:
1hotswan setup --apply # applies the HotSwan Gradle plugin
2hotswan run # builds, installs and launches the app
3# edit a file, then:
4hotswan reload # pushes the edit and checks what reached the screenhotswan setup adds the plugin to your version catalog, registers it in the root build script and applies it in your app module. Without --apply it only prints the edits, and with it, it reads the Gradle build again and puts every file back if Gradle does not then apply the plugin. If you prefer to do it by hand, the install guide shows each step.
hotswan doctor checks everything a reload needs, from Java and adb to the device, the plugin and the running app, and prints the fix for anything missing. If you edit by hand in the editor you like, hotswan watch reloads on every save with the same verdict.
A verdict for every save
hotswan reload pushes your edits into the running app and then checks the screen from outside the app: a before and after screenshot diff that ignores the screen's own animation, the text that appeared or disappeared, and a crash check. Each run writes its evidence to .hotswan/runs/<id>/, including compare.png and zoom.png, so you and the agent look at the same pictures.
When something goes wrong, the CLI says what and where. A compile error comes back as file:line:column, ready for the agent to open. Any other failure writes an issue-ready report.md with the versions, the device, and the Gradle and device logs, with paths rewritten to <project> and ~, and hotswan report --open turns it into a prefilled GitHub issue.
Every command also speaks to scripts and agents: --json prints one JSON object, and the exit code says what happened.
- 0: the edit was applied.
- 1: it failed, for example on a compile error or a refused push.
- 3: the environment is not ready, such as no device or no running app.
- 4: the change cannot be applied live, so the app needs a relaunch.
- 5: the reload landed, but the app says the edit is not on screen.
- 6: a selector matched nothing, or a wait timed out.
Exit code 5 is the one I care about most. A wrong reload is worse than a slow one, because it sends you after a bug that is not in your real app. An agent that is told plainly that its edit did not reach the screen does not build its next step on top of a change you never saw.
The screen as text
To check its work, an agent first has to reach the screen it is working on. hotswan ui tree prints the screen as text, the way an agent reads it, and the other ui commands tap, type, scroll and wait through the app's own semantics:
1hotswan ui tree # the screen as text
2hotswan ui tap "Bulbasaur" # tap the node with this text
3hotswan ui scroll-to "Base Stats"
4hotswan journey save detail # keep the path to this screen
5hotswan reload --restart # relaunches, then walks backEvery successful ui action is recorded, so hotswan journey save keeps the path to the current screen, and journey run or hotswan run --journey walks it again after any restart. Some changes still need a fresh process, or touch resources or the manifest. hotswan reload --restart applies those by rebuilding and relaunching, walks the recorded path back to the same screen, and compares it with the one before the change. The seven taps of the build tax become the CLI's job.
Plugging in your agent
Any agent that can run a shell command can use hotswan, and a few pieces make the setup explicit:
hotswan agent initwrites two Claude Code skills into your project:hotswan-setupinstalls the CLI, applies the plugin, launches the app and verifies a first reload, andhotswanruns the edit, reload and verify loop. With--agents-md, the same guidance goes into a section ofAGENTS.mdfor other agents.hotswan mcpis an MCP server on stdio that needs no IDE. Its reload and screenshot answers include the images, so the agent sees the result directly.hotswan agent init --mcpregisters it in.mcp.json.- In Claude Code, the repository is also a plugin marketplace with the same skills:
/plugin marketplace add skydoves/compose-hotswan, then/plugin install hotswan@hotswan.
From there, the loop is the right half of the diagram above. The agent makes one change, reloads, reads the verdict and the screenshots, and decides its next step from what reached the screen, while you watch the device and step in when it heads the wrong way.
Try it
Install the CLI, run hotswan setup --apply in a project, and hand the loop to your agent, or ask the agent to do all of it with the hotswan-setup skill. The CLI guide lists every command and option, and the source is on GitHub.
In the AI era, writing the code is no longer the slow part. Seeing it, and deciding what to do next, is. I hope hotswan makes that part fast for you and for your agent. If a reload does not do what you expected, a small repro on the issue tracker is the fastest way to get it fixed.
As always, happy coding!
Jaewoong (skydoves)


