$npx -y skills add skydoves/compose-performance-skills --skill setting-up-compose-hotswanUse this skill to install and verify Compose HotSwan end to end so a developer goes from zero to working sub-second hot reload on a real device or emulator in one session. Covers the JetBrains IDE plugin install, the com.github.skydoves.compose.hotswan.compiler Gradle plugin wi
| 1 | # Setting Up Compose HotSwan: zero to sub-second reload on a real device |
| 2 | |
| 3 | Compose HotSwan is a JetBrains IDE plugin plus a Gradle compiler plugin that swaps changed Kotlin classes into a running Compose app on a real device or emulator in under one second, preserving navigation, scroll, and `remember` state. This skill installs both pieces, wires the canonical Gradle DSL with `debugOnly = true`, and verifies the first save-to-reload round-trip. Sibling skills cover what does and does not hot-reload (`../understanding-hot-reload-limits/SKILL.md`), state preservation across reloads, and the AI-driven iteration loop. |
| 4 | |
| 5 | > Versions verified at the time of authoring. Confirm against the current release notes for newer minors. |
| 6 | |
| 7 | ## When to use this skill |
| 8 | |
| 9 | - The developer mentions HotSwan, hot reload, instant UI update, "save and see", "no rebuild", live edit, or fast Compose iteration on device. |
| 10 | - The developer has the HotSwan JetBrains Marketplace plugin installed and asks how to apply the Gradle compiler plugin. |
| 11 | - A team is onboarding a new project to HotSwan and wants the canonical `libs.versions.toml` + root build + app build wiring. |
| 12 | - The developer just installed the IDE plugin and the tool window status is stuck before `WATCHING`. |
| 13 | |
| 14 | ## When NOT to use this skill |
| 15 | |
| 16 | - The question is about JetBrains' own Live Edit or Apply Changes features. HotSwan and those are separate products with different boundaries; do not conflate. |
| 17 | - The question is about Compose Preview rendering inside the IDE. HotSwan targets the running app on a real device or emulator, not preview canvases. |
| 18 | - The question is about which changes hot-reload vs force a rebuild. See `../understanding-hot-reload-limits/SKILL.md`. |
| 19 | - The question is about preserving complex state across reloads. See the state-preservation sibling skill (out of scope here). |
| 20 | |
| 21 | ## Prerequisites |
| 22 | |
| 23 | - Android Studio 2024.3+ or IntelliJ IDEA 2024.3+. |
| 24 | - Kotlin 2.0+ with the `org.jetbrains.kotlin.plugin.compose` Gradle plugin already applied on the Compose modules. |
| 25 | - Gradle 8+. |
| 26 | - A real device or emulator with USB debugging enabled and visible to `adb devices`. |
| 27 | - The HotSwan IDE plugin installed from JetBrains Marketplace (https://plugins.jetbrains.com/plugin/30551-compose-hotswan/). |
| 28 | |
| 29 | ## Workflow |
| 30 | |
| 31 | 1. **Declare the plugin in `libs.versions.toml`** so the version pins centrally: |
| 32 | |
| 33 | ```toml |
| 34 | [plugins] |
| 35 | hotswan-compiler = { id = "com.github.skydoves.compose.hotswan.compiler", version = "1.2.10" } |
| 36 | ``` |
| 37 | |
| 38 | Pin `1.2.10` (latest verified at the time of authoring). Check the [HotSwan releases page](https://hotswan.dev/docs/releases) for newer stable versions before adopting; HotSwan iterates frequently and a newer minor often ships compatibility for a newer Compose runtime. The plugin id is `com.github.skydoves.compose.hotswan.compiler` exactly. Do not swap the `com.github` prefix for any other vendor namespace; HotSwan is published under `com.github.skydoves`. |
| 39 | |
| 40 | 2. **Apply at the root `build.gradle.kts` with `apply false`** so the plugin is resolved once but only attaches to modules that opt in: |
| 41 | |
| 42 | ```kotlin |
| 43 | plugins { |
| 44 | alias(libs.plugins.hotswan.compiler) apply false |
| 45 | } |
| 46 | ``` |
| 47 | |
| 48 | 3. **Apply in each Compose app module's `build.gradle.kts`**: |
| 49 | |
| 50 | ```kotlin |
| 51 | plugins { |
| 52 | alias(libs.plugins.android.application) |
| 53 | alias(libs.plugins.kotlin.android) |
| 54 | alias(libs.plugins.kotlin.compose) |
| 55 | alias(libs.plugins.hotswan.compiler) |
| 56 | } |
| 57 | ``` |
| 58 | |
| 59 | 4. **Configure the canonical DSL block** in the same module file. The capital `S` in `hotSwanCompiler` is part of the identifier: |
| 60 | |
| 61 | ```kotlin |
| 62 | hotSwanCompiler { |
| 63 | enabled = true |
| 64 | debugOnly = true |
| 65 | } |
| 66 | ``` |
| 67 | |
| 68 | `debugOnly = true` is the default and the rule for production. Release builds MUST NOT carry the HotSwan transformations. |
| 69 | |
| 70 | 5. **Sync Gradle.** The build should resolve without errors. Confirm the plugin attached by inspecting the build's plugin list (`./gradlew :app:buildEnvironment` or the IDE Gradle tool window). |
| 71 | |
| 72 | 6. **Open the Hot |