Documentation
Command Line (CLI)
The hotswan command line sets HotSwan up and drives it from a terminal, for you or for a coding agent. It uses the same Gradle plugin and runtime as the IDE plugin, so you can hot reload a Compose app without opening Android Studio or IntelliJ IDEA.
hotswan setup needs the 2.4.1 CLI or newer; with the 2.4.0 CLI, apply the plugin by hand as shown in Set Up a Project.Overview
Every command answers one question and says what to do next:
- A verdict for every save.
hotswan reloadpushes your edits into the running app, then compares the screen before and after. It tells you whether the edit was applied and whether it reached the screen, and writes before, after and diff images. - Failures you can act on. A compile error is printed as
file:line:column. Any other failure writes an issue-readyreport.mdwith versions, device, Gradle and device logs. - The screen as text.
hotswan uireads the screen through the app's semantics and taps, types and scrolls, so you or an agent can reach the screen you are working on and get back to it after a restart. - Built for scripts and agents.
--jsonprints exactly one JSON object per command, and the exit code says what happened.
Install
The CLI needs Java 17 or newer (Android Studio's bundled JDK is found automatically) and adb from the Android SDK platform-tools. It runs on macOS and Linux.
curl -fsSL https://hotswan.dev/install.sh | sh -s -- --add-to-pathThe installer downloads the CLI from Maven Central, checks its checksum and writes the launcher to ~/.hotswan/bin/hotswan. --add-to-path adds that directory to your shell profile; --version 2.4.1 installs a specific version. Run hotswan --version to check it.
Set Up a Project
Inside your project, hotswan doctor checks everything a reload needs and names the fix for anything missing. The first command in a project reads the Gradle build once, which can take a minute on a large project; later commands reuse it until a build file changes, and --refresh reads it again after you change build logic.
hotswan setup applies the HotSwan Gradle plugin for you. On its own it only prints the edits it would make; --apply makes them.
cd your-project
hotswan setup # prints the edits; changes nothing
hotswan setup --apply # makes them, then checks that Gradle applies the pluginIt makes the same edits you would make by hand:
- adds the plugin to
gradle/libs.versions.toml(or uses the plugin id and version when the project has no catalog), - registers it in the root build script with
apply false, - applies it in the Android application module,
- adds
mavenCentral()to the repositories ofpluginManagementanddependencyResolutionManagementwhen it is missing, and - adds the HotSwan settings plugin when Gradle isolated projects is on, in the project's or your own
gradle.properties. - applies it to the Compose modules HotSwan cannot reach on its own because Gradle configures them first, such as a Kotlin Multiplatform UI module next to a thin Android app.
hotswan doctorwarns about such modules too.
After --apply it reads the Gradle build again. If Gradle fails or does not then apply the plugin, it puts every file back and prints why, so a failed setup never leaves a half-edited build. It does not change a HotSwan version a project already has: a project on a version older than 2.3.0 is told to update it. It refuses, with the manual step, a Kotlin version below 2.3.20, a module without the Compose compiler plugin, and a build with several app modules until you pick one with --module :app. For the iOS simulator or Compose Desktop, also apply it to that module with --module.
By hand, or with the 2.4.0 CLI, add the plugin to the version catalog and apply it in the module that owns your app:
# gradle/libs.versions.toml
[versions]
hotswan = "2.4.1"
[plugins]
hotswan-compiler = { id = "com.github.skydoves.compose.hotswan.compiler", version.ref = "hotswan" }// build.gradle.kts (root)
plugins {
alias(libs.plugins.hotswan.compiler) apply false
}
// app/build.gradle.kts
plugins {
alias(libs.plugins.hotswan.compiler)
}- Keep
mavenCentral()in the repositories ofpluginManagementinsettings.gradle.kts: the plugin is published to Maven Central. - With Gradle isolated projects on, also add
id("com.github.skydoves.compose.hotswan.settings") version "2.4.1"to thepluginsblock ofsettings.gradle.kts(Gradle 8.8 or newer).
See Gradle Configuration and Kotlin Multiplatform for every option and for iOS and Desktop modules.
Edit, Reload, Verify
hotswan run # builds, installs and launches the app, waits until it can reload
# edit a file, then:
hotswan reload # pushes the change and checks the screenhotswan reload reloads every file changed since the last reload (or the files you name), then compares the screen before and after: it prints the text that appeared or disappeared and writes compare.png (before, after, diff) and zoom.png (the changed area) under .hotswan/runs/. The screen check ignores the screen's own animation and counts only frames taken before the push as “before”.
Some edits cannot be applied to a running app, such as resource values or the manifest. hotswan reload --restart rebuilds and relaunches the app, walks back to the same screen with the ui actions it recorded, and compares it with the screen before. hotswan watch reloads on every save until you stop it.
Read and Drive the Screen
hotswan ui tree # the screen as an indented outline
hotswan ui tap "Settings" # by visible text; also tag=…, desc=…, #id, @x,y
hotswan ui type "Search" "coffee" # type into a field
hotswan ui scroll-to "Privacy policy"
hotswan ui wait "Loaded" --timeout 10s
hotswan ui backA plain selector matches visible text, then the content description, then the test tag. Add --shot to an action to save a screenshot once the screen settles.
Every successful ui action is recorded. hotswan journey save detail keeps the path to the current screen, hotswan journey run detail walks it again, and hotswan run --journey detail launches straight onto it.
JSON and Exit Codes
Add --json to any command for exactly one compact JSON object on stdout (watch prints one per reload). Every document has ok and exitCode; a failure adds message and remedy. A reload adds outcome, screen (changed, textAdded, textRemoved, images), errors and warnings.
| Outcome | What to do |
|---|---|
| APPLIED | The edit is live. With screen.changed: true it reached the screen; look at screen.images.compare. |
| NO_CHANGES | No file changed since the last reload. Name the file: hotswan reload path/to/File.kt. |
| NO_CODE_CHANGE | The compiled code is the same, such as a comment edit. If the screen looks old, run hotswan run. |
| COMPILE_ERROR | Fix errors[] (file, line, column, message) and reload again. |
| RESTART_REQUIRED | The edit cannot be applied live. hotswan reload --restart rebuilds and walks back to the screen. |
| APP_CRASHED | The app crashed after the push. hotswan logs --crash shows why; --restart recovers. |
| NOT_RENDERED / NOTHING_APPLIED | The push did not reach the screen (exit 5). Read message. |
| RESTARTED | Result of --restart. Trust its screen result only when restart.returned is true. |
| PARTIAL | Some targets took the edit and others did not; message names them. |
| NOT_RELOADABLE | The edit cannot be reloaded, for example because its module does not apply HotSwan; remedy says what to run. |
| anything else | Read message and remedy; report points to an issue-ready report.md. |
| Exit code | Meaning |
|---|---|
| 0 | Reloaded, or nothing to reload. |
| 1 | Failed: a compile error, a refused push or a crash. |
| 2 | Usage error: an unknown command or option. |
| 3 | Not ready: no device, no running app, or no HotSwan plugin. |
| 4 | Restart required: the edit cannot be applied to the running app. |
| 5 | Reloaded, but the edit did not reach the screen. |
| 6 | Not found: a ui selector, a journey step, a scroll that moved nothing, or a wait that timed out. |
Diagnose and Report
hotswan doctorchecks Java, adb, the device and its screen, the plugin, the running app and that the app and the plugin are on the same version.hotswan logsshows the app's HotSwan lines and warnings;--crashshows its last crash.hotswan reportprints the last failure as Markdown, with paths rewritten to<project>and~;--openopens a prefilled GitHub issue.
Coding Agents
hotswan agent init writes two Claude Code skills into the project:
hotswan-setupinstalls the CLI, applies the plugin, launches the app and verifies a first reload, so you can ask an agent to “set up HotSwan” in a project that does not use it yet.hotswanruns the loop: edit,hotswan reload --json, read the verdict, look at the screen, and drive the app to the screen that uses the edited code.
--agents-md also writes both into AGENTS.md for other agents, and --mcp registers hotswan mcp, an MCP server that needs no IDE, in .mcp.json. In Claude Code, you can instead install the skills once for every project (use one or the other, not both):
/plugin marketplace add skydoves/compose-hotswan
/plugin install hotswan@hotswanThe hotswan-setup skill needs the 2.4.1 CLI or newer; the 2.4.0 CLI's agent init writes only the loop skill. See Agent Skill for the skill that drives the IDE plugin's MCP server instead.
Targets and Limits
- Android devices and emulators are fully supported. Pick one with
--device <serial>when several are connected. --target desktopreloads a running Compose Desktop app, and--target ios --udid <UDID>an app on the iOS simulator. The screen check,ui,journeyandstatusare Android only;screenshotalso works on a simulator.- Resource value and manifest edits are not reloaded live: use
hotswan reload --restartorhotswan run. - The app must be a debug build with the plugin applied. Run
hotswan help <command>for every option.
Command Reference
| Command | What it does |
|---|---|
| hotswan setup [--apply] | Apply the HotSwan Gradle plugin to the project (2.4.1 or newer). Without --apply it prints the edits. |
| hotswan doctor | Check Java, the project, adb, the device and its screen, the plugin, the running app and versions. |
| hotswan run | Build, install and launch the debug app, and wait until it can reload. --journey <name> lands on a saved screen. |
| hotswan reload [files…] | Push your edits and verify the screen. --no-verify skips screenshots; --restart recovers from a restart-only edit. |
| hotswan watch | Reload on every save, with one verdict line per save (one JSON document per reload with --json). |
| hotswan screenshot | Save the screen as a PNG and print its path. |
| hotswan ui tree | The screen as an outline of text, buttons and lists (--json for bounds and actions). |
| hotswan ui tap <selector> | Tap by visible text, tag=…, desc=…, #id or @x,y; also long-tap. |
| hotswan ui type [<field>] <text> | Type into a text field. |
| hotswan ui scroll / scroll-to | Scroll the main list, or until something is on screen. |
| hotswan ui wait <selector> | Wait until something appears (--gone: disappears). |
| hotswan ui back / press <key> | Press back, home, enter or any key code. |
| hotswan journey save|run <name> | Save the path to the current screen, and walk it again later. |
| hotswan logs [--crash] | The app's HotSwan lines and warnings, or its crash. |
| hotswan status | The device, the running app and the last reload. |
| hotswan devices | Android devices, booted iOS simulators and a running desktop app. |
| hotswan report [--open] | The last failure as an issue-ready Markdown report. |
| hotswan agent init | Write the Claude Code skills into the project (--agents-md, --mcp). |
| hotswan mcp | An MCP server on stdio that needs no IDE. |
Options for every command: --json, --device <serial>, --project <dir>, --verbose, --quiet and --no-color.