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.

The CLI has shipped with HotSwan since 2.4.0 and needs the HotSwan Gradle plugin 2.3.0 or newer in your project. 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 reload pushes 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-ready report.md with versions, device, Gradle and device logs.
  • The screen as text. hotswan ui reads 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. --json prints 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-path

The 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 plugin

It 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 of pluginManagement and dependencyResolutionManagement when 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 doctor warns 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 of pluginManagement in settings.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 the plugins block of settings.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 screen

hotswan 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 back

A 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.

OutcomeWhat to do
APPLIEDThe edit is live. With screen.changed: true it reached the screen; look at screen.images.compare.
NO_CHANGESNo file changed since the last reload. Name the file: hotswan reload path/to/File.kt.
NO_CODE_CHANGEThe compiled code is the same, such as a comment edit. If the screen looks old, run hotswan run.
COMPILE_ERRORFix errors[] (file, line, column, message) and reload again.
RESTART_REQUIREDThe edit cannot be applied live. hotswan reload --restart rebuilds and walks back to the screen.
APP_CRASHEDThe app crashed after the push. hotswan logs --crash shows why; --restart recovers.
NOT_RENDERED / NOTHING_APPLIEDThe push did not reach the screen (exit 5). Read message.
RESTARTEDResult of --restart. Trust its screen result only when restart.returned is true.
PARTIALSome targets took the edit and others did not; message names them.
NOT_RELOADABLEThe edit cannot be reloaded, for example because its module does not apply HotSwan; remedy says what to run.
anything elseRead message and remedy; report points to an issue-ready report.md.
Exit codeMeaning
0Reloaded, or nothing to reload.
1Failed: a compile error, a refused push or a crash.
2Usage error: an unknown command or option.
3Not ready: no device, no running app, or no HotSwan plugin.
4Restart required: the edit cannot be applied to the running app.
5Reloaded, but the edit did not reach the screen.
6Not found: a ui selector, a journey step, a scroll that moved nothing, or a wait that timed out.

Diagnose and Report

  • hotswan doctor checks 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 logs shows the app's HotSwan lines and warnings; --crash shows its last crash.
  • hotswan report prints the last failure as Markdown, with paths rewritten to <project> and ~; --open opens a prefilled GitHub issue.

Coding Agents

hotswan agent init writes two Claude Code skills into the project:

  • hotswan-setup installs 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.
  • hotswan runs 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@hotswan

The 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 desktop reloads a running Compose Desktop app, and --target ios --udid <UDID> an app on the iOS simulator. The screen check, ui, journey and status are Android only; screenshot also works on a simulator.
  • Resource value and manifest edits are not reloaded live: use hotswan reload --restart or hotswan run.
  • The app must be a debug build with the plugin applied. Run hotswan help <command> for every option.

Command Reference

CommandWhat 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 doctorCheck Java, the project, adb, the device and its screen, the plugin, the running app and versions.
hotswan runBuild, 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 watchReload on every save, with one verdict line per save (one JSON document per reload with --json).
hotswan screenshotSave the screen as a PNG and print its path.
hotswan ui treeThe 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-toScroll 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 statusThe device, the running app and the last reload.
hotswan devicesAndroid devices, booted iOS simulators and a running desktop app.
hotswan report [--open]The last failure as an issue-ready Markdown report.
hotswan agent initWrite the Claude Code skills into the project (--agents-md, --mcp).
hotswan mcpAn MCP server on stdio that needs no IDE.

Options for every command: --json, --device <serial>, --project <dir>, --verbose, --quiet and --no-color.