Understanding Hot Reload Limits: stay inside the fast path
Android Runtime (ART) enforces strict rules for class redefinition: a redefined class must have an identical schema (fields, method signatures, interfaces) as the previous version. Only method bodies are mutable at runtime. HotSwan automatically detects schema changes and falls back to a full incremental build, so failures are not silent. Knowing the boundary in advance is what keeps an iteration loop sub-second instead of multi-second.
When to use this skill
- The developer asks "why did this trigger a full rebuild?", "why isn't this hot reloading?", or "what does HotSwan support?".
- A PR review surfaces a refactor (parameter change, constructor change, interface extraction, new resource id) that would push a hot-reload session into a rebuild.
- The developer is planning a session and wants to order edits so the slow ones happen at the end.
- The developer reports an
inline fun change that "didn't reload" and is debugging.
When NOT to use this skill
- Setup or first-run troubleshooting. See
../setting-up-compose-hotswan/SKILL.md.
- Pure state-preservation question (the reload happened but state was lost). See the state-preservation sibling skill.
- Configuration of the AI iteration loop or MCP server. See the AI-loop sibling skill.
Prerequisites
- HotSwan installed and verified per
../setting-up-compose-hotswan/SKILL.md (tool window status WATCHING, body-only edit reloads in under one second).
- Familiarity with the Kotlin compiler's distinction between method-body changes and class-schema changes.
Boundary tables
Hot-reloadable (no rebuild)
| Change |
Notes |
| Composable function body |
text, colors, modifiers, layout, control flow inside the function |
| Non-composable function body |
ViewModel methods, mappers, utilities, repositories |
| Adding a new composable |
same file or new file |
| Reordering composables |
HotSwan 1.2.0+ |
| Resource value changes |
strings.xml value, colors.xml value, dimens.xml value |
| Extension functions |
including suspend, including vararg |
Adding data class properties |
API 30+ only |
| Numeric, string, float literal patches |
compiled separately for fastest reload |
Forces full rebuild (fallback)
| Change |
Reason |
| Adding or removing function parameters |
method signature changes |
| Constructor changes |
parameter list, default values, init blocks affecting fields |
| Interface or superclass changes |
class hierarchy is part of the schema |
| Adding new resource ids |
new R.string, R.drawable, R.id entries require generated R class regeneration |
| Inline functions |
expanded at every call site; no discrete unit to swap |
| Lambda count change inside a function |
internal lambda class renumbering |
| Removing a previously defined function |
method table shrinks; schema changes |
Adding data class properties below API 30 |
constructor schema change without ART support |
Workflow when a change does not hot-reload
- Watch the HotSwan tool window status at the moment of save. A schema change surfaces as a "falling back to incremental build" status. That is the explicit signal, not a silent failure.
- Read the change diff. Decide: is this a body-only change, or a schema change (signature, constructor, interface, field, new resource id, inline body, lambda count)?
- If a refactor must change a signature, batch it. First make the body-only changes that get the screen to a working visual state and hot-reload them. Then, in a separate save, change the signature and accept the rebuild as the last step of the session.
- For inline functions, drop
inline for the duration of iteration. Refactor the function out of inline while iterating, hot-reload as needed, and restore inline before commit. If iteration is rare or the perf characteristic must be preserved, accept the rebuild.
- For new resource ids, batch all id additions first, accept one rebuild, then iterate on values. Editing
<string name="title">Updated Title</string> (existing id) hot-reloads; adding <string name="brand_new_id">...</string> does not.
Patterns
Pattern: function-body change (fast path) vs signature change (rebuild)
// RIGHT (body-only change, hot-reloads)
@Composable
fun Greeting() {
Text("Hello, World", color = Color.Blue)
}
// WRONG for the fast path (signature change, forces rebuild)
@Composable
fun Greeting(name: String) {
Text("Hello, $name")
}
// WRONG because: adding a parameter changes the method signature, which violates ART's class
// schema constraint. To stay inside the fast path, introduce the parameter with a default value
// in one save (still a rebuild; accept it once), then iterate on the body across subsequent saves.
Pattern: adding a new composable (fast path) vs changing a constructor (rebuild)
// RIGHT (new composable in the same file, hot-reloads on HotSwan 1.2.0+)
@Composable
fun SecondaryAction() {
Text("New")
}
// WRONG for the fast path (constructor change)
data class User(val id: Long, val name: String, val age: Int)
// WRONG because: adding `age` extends the constructor. On API 30+ HotSwan supports adding
// data class properties; below API 30 the schema change forces a rebuild. When targeting older
// minSdk, batch property additions and accept a rebuild for each.
Pattern: inline function body change (rebuild)
// WRONG for the fast path
inline fun <T> Modifier.observer(value: T, body: (T) -> Modifier): Modifier = body(value)
// WRONG because: inline functions are expanded at every call site at compile time. There is no
// discrete unit to swap, so editing the inline body forces a full rebuild of every call site.
// Drop `inline` for the duration of iteration, or accept the rebuild.
// RIGHT for the fast path (non-inline variant during iteration)
fun <T> Modifier.observer(value: T, body: (T) -> Modifier): Modifier = body(value)
Pattern: resource value change (fast path) vs new resource id (rebuild)
<!-- RIGHT: value change on an existing id, hot-reloads -->
<string name="title">Updated Title</string>
<!-- WRONG for the fast path: new id, forces rebuild -->
<string name="brand_new_id">Hello</string>
<!-- WRONG because: adding a new string id grows the generated R class. R class regeneration
is a schema change that ART cannot redefine in place. -->
Pattern: lambda count change (rebuild)
// RIGHT (body change inside the existing lambda, hot-reloads)
@Composable
fun Row() {
Button(onClick = { log("tapped") }) { Text("Tap") }
}
// WRONG for the fast path (adds a second lambda, renumbers inner lambda classes)
@Composable
fun Row() {
Button(onClick = { log("tapped") }) { Text("Tap") }
Button(onClick = { log("second") }) { Text("Second") }
}
// WRONG because: a Kotlin function's compiled lambdas are anonymous classes named like
// Row$lambda$1, Row$lambda$2. Adding a lambda renumbers them and changes the class table,
// which is a schema change. The fix is to add the second composable as a separate top-level
// function (which is supported), then call it from Row once the structural change has rebuilt.
Mandatory rules
- MUST consult the boundary tables before suggesting a change to a composable that the developer is iterating on. Suggesting a parameter add when the developer wanted speed wastes the iteration loop.
- MUST NOT claim a change will hot-reload without checking it against the supported-changes table above.
- MUST NOT disable HotSwan to "force a clean rebuild". Use Gradle's
:app:clean for a clean build; HotSwan auto-falls-back when needed and turning it off costs the next round-trip.
- MUST treat new resource ids and inline-function body changes as rebuild-forcing on every Android API level. The data-class-property exception is API 30+ only.
- PREFERRED: order an iteration session so body-only edits come first and signature, constructor, interface, or new-resource-id changes are batched at the end.
- PREFERRED: when a refactor needs a parameter add, introduce it once with a default value (accept the rebuild), then iterate on the body across subsequent saves.
Verification
References
1---2name: understanding-hot-reload-limits3description: Use this skill to teach Claude exactly which Kotlin and Compose changes hot-reload under Compose HotSwan and which trigger a full incremental rebuild fallback. Root cause is Android Runtime (ART) class schema immutability; only method bodies are mutable at runtime, so any change to fields, signatures, constructors, interfaces, inline functions, or new resource ids forces a rebuild. Covers the supported-changes table, the rebuild-forcing list, the diff-then-batch workflow that keeps a hot-reload session inside the fast path, and the inline-function and new-resource-id pitfalls. Trigger when the user asks "why did this rebuild?", "why isn't this hot reloading?", wants to learn HotSwan's boundaries before adopting it, or when reviewing a refactor that risks pushing a hot-reload session into a full rebuild.4license: Apache-2.0. See LICENSE for complete terms.5---6
7# Understanding Hot Reload Limits: stay inside the fast path
8
9Android Runtime (ART) enforces strict rules for class redefinition: a redefined class must have an identical schema (fields, method signatures, interfaces) as the previous version. Only method bodies are mutable at runtime. HotSwan automatically detects schema changes and falls back to a full incremental build, so failures are not silent. Knowing the boundary in advance is what keeps an iteration loop sub-second instead of multi-second.
10
11## When to use this skill
12
13- The developer asks "why did this trigger a full rebuild?", "why isn't this hot reloading?", or "what does HotSwan support?".
14- A PR review surfaces a refactor (parameter change, constructor change, interface extraction, new resource id) that would push a hot-reload session into a rebuild.
15- The developer is planning a session and wants to order edits so the slow ones happen at the end.
16- The developer reports an `inline fun` change that "didn't reload" and is debugging.
17
18## When NOT to use this skill
19
20- Setup or first-run troubleshooting. See `../setting-up-compose-hotswan/SKILL.md`.
21- Pure state-preservation question (the reload happened but state was lost). See the state-preservation sibling skill.
22- Configuration of the AI iteration loop or MCP server. See the AI-loop sibling skill.
23
24## Prerequisites
25
26- HotSwan installed and verified per `../setting-up-compose-hotswan/SKILL.md` (tool window status `WATCHING`, body-only edit reloads in under one second).
27- Familiarity with the Kotlin compiler's distinction between method-body changes and class-schema changes.
28
29## Boundary tables
30
31### Hot-reloadable (no rebuild)
32
33| Change | Notes |
34|---|---|
35| Composable function body | text, colors, modifiers, layout, control flow inside the function |
36| Non-composable function body | ViewModel methods, mappers, utilities, repositories |
37| Adding a new composable | same file or new file |
38| Reordering composables | HotSwan 1.2.0+ |
39| Resource value changes | `strings.xml` value, `colors.xml` value, `dimens.xml` value |
40| Extension functions | including suspend, including vararg |
41| Adding `data class` properties | API 30+ only |
42| Numeric, string, float literal patches | compiled separately for fastest reload |
43
44### Forces full rebuild (fallback)
45
46| Change | Reason |
47|---|---|
48| Adding or removing function parameters | method signature changes |
49| Constructor changes | parameter list, default values, init blocks affecting fields |
50| Interface or superclass changes | class hierarchy is part of the schema |
51| Adding new resource ids | new `R.string`, `R.drawable`, `R.id` entries require generated `R` class regeneration |
52| Inline functions | expanded at every call site; no discrete unit to swap |
53| Lambda count change inside a function | internal lambda class renumbering |
54| Removing a previously defined function | method table shrinks; schema changes |
55| Adding `data class` properties below API 30 | constructor schema change without ART support |
56
57## Workflow when a change does not hot-reload
58
591. **Watch the HotSwan tool window status** at the moment of save. A schema change surfaces as a "falling back to incremental build" status. That is the explicit signal, not a silent failure.
602. **Read the change diff.** Decide: is this a body-only change, or a schema change (signature, constructor, interface, field, new resource id, inline body, lambda count)?
613. **If a refactor must change a signature, batch it.** First make the body-only changes that get the screen to a working visual state and hot-reload them. Then, in a separate save, change the signature and accept the rebuild as the last step of the session.
624. **For inline functions, drop `inline` for the duration of iteration.** Refactor the function out of `inline` while iterating, hot-reload as needed, and restore `inline` before commit. If iteration is rare or the perf characteristic must be preserved, accept the rebuild.
635. **For new resource ids, batch all id additions first**, accept one rebuild, then iterate on values. Editing `<string name="title">Updated Title</string>` (existing id) hot-reloads; adding `<string name="brand_new_id">...</string>` does not.
64
65## Patterns
66
67### Pattern: function-body change (fast path) vs signature change (rebuild)
68
69```kotlin
70// RIGHT (body-only change, hot-reloads)
71@Composable
72fun Greeting() {
73 Text("Hello, World", color = Color.Blue)
74}
75```
76
77```kotlin
78// WRONG for the fast path (signature change, forces rebuild)
79@Composable
80fun Greeting(name: String) {
81 Text("Hello, $name")
82}
83// WRONG because: adding a parameter changes the method signature, which violates ART's class
84// schema constraint. To stay inside the fast path, introduce the parameter with a default value
85// in one save (still a rebuild; accept it once), then iterate on the body across subsequent saves.
86```
87
88### Pattern: adding a new composable (fast path) vs changing a constructor (rebuild)
89
90```kotlin
91// RIGHT (new composable in the same file, hot-reloads on HotSwan 1.2.0+)
92@Composable
93fun SecondaryAction() {
94 Text("New")
95}
96```
97
98```kotlin
99// WRONG for the fast path (constructor change)
100data class User(val id: Long, val name: String, val age: Int)
101// WRONG because: adding `age` extends the constructor. On API 30+ HotSwan supports adding
102// data class properties; below API 30 the schema change forces a rebuild. When targeting older
103// minSdk, batch property additions and accept a rebuild for each.
104```
105
106### Pattern: inline function body change (rebuild)
107
108```kotlin
109// WRONG for the fast path
110inline fun <T> Modifier.observer(value: T, body: (T) -> Modifier): Modifier = body(value)
111// WRONG because: inline functions are expanded at every call site at compile time. There is no
112// discrete unit to swap, so editing the inline body forces a full rebuild of every call site.
113// Drop `inline` for the duration of iteration, or accept the rebuild.
114```
115
116```kotlin
117// RIGHT for the fast path (non-inline variant during iteration)
118fun <T> Modifier.observer(value: T, body: (T) -> Modifier): Modifier = body(value)
119```
120
121### Pattern: resource value change (fast path) vs new resource id (rebuild)
122
123```xml
124<!-- RIGHT: value change on an existing id, hot-reloads -->
125<string name="title">Updated Title</string>
126```
127
128```xml
129<!-- WRONG for the fast path: new id, forces rebuild -->
130<string name="brand_new_id">Hello</string>
131<!-- WRONG because: adding a new string id grows the generated R class. R class regeneration
132 is a schema change that ART cannot redefine in place. -->
133```
134
135### Pattern: lambda count change (rebuild)
136
137```kotlin
138// RIGHT (body change inside the existing lambda, hot-reloads)
139@Composable
140fun Row() {
141 Button(onClick = { log("tapped") }) { Text("Tap") }
142}
143```
144
145```kotlin
146// WRONG for the fast path (adds a second lambda, renumbers inner lambda classes)
147@Composable
148fun Row() {
149 Button(onClick = { log("tapped") }) { Text("Tap") }
150 Button(onClick = { log("second") }) { Text("Second") }
151}
152// WRONG because: a Kotlin function's compiled lambdas are anonymous classes named like
153// Row$lambda$1, Row$lambda$2. Adding a lambda renumbers them and changes the class table,
154// which is a schema change. The fix is to add the second composable as a separate top-level
155// function (which is supported), then call it from Row once the structural change has rebuilt.
156```
157
158## Mandatory rules
159
160- **MUST** consult the boundary tables before suggesting a change to a composable that the developer is iterating on. Suggesting a parameter add when the developer wanted speed wastes the iteration loop.
161- **MUST NOT** claim a change will hot-reload without checking it against the supported-changes table above.
162- **MUST NOT** disable HotSwan to "force a clean rebuild". Use Gradle's `:app:clean` for a clean build; HotSwan auto-falls-back when needed and turning it off costs the next round-trip.
163- **MUST** treat new resource ids and inline-function body changes as rebuild-forcing on every Android API level. The data-class-property exception is API 30+ only.
164- **PREFERRED:** order an iteration session so body-only edits come first and signature, constructor, interface, or new-resource-id changes are batched at the end.
165- **PREFERRED:** when a refactor needs a parameter add, introduce it once with a default value (accept the rebuild), then iterate on the body across subsequent saves.
166
167## Verification
168
169- [ ] A body-only change to a composable hot-reloads on save with the tool window status remaining `WATCHING`.
170- [ ] Adding a parameter to a composable triggers the fallback status in the tool window.
171- [ ] Adding a new `<string>` resource triggers the fallback; editing an existing `<string>` value does not.
172- [ ] Editing the body of an `inline` function triggers the fallback; converting it to a non-`inline` function and editing the body hot-reloads.
173- [ ] Adding a property to a `data class` hot-reloads on a device running API 30+; on API 29 and below it triggers the fallback.
174
175## References
176
177- HotSwan supported-changes documentation: https://github.com/skydoves/compose-hotswan-web (under `/docs/supported-changes`).
178- HotSwan limitations documentation: https://github.com/skydoves/compose-hotswan-web (under `/docs/limitations`).
179- Android Runtime class redefinition (JVMTI) reference: https://source.android.com/docs/core/runtime/jvmti
180- Sibling skill `../setting-up-compose-hotswan/SKILL.md` for installation and the first save-to-reload verification.