Setting Up Compose Hotswan 标志

Setting Up Compose Hotswan

社区
skydoves
setting-up-compose-hotswan

使用此技能,端到端安装并验证 Compose HotSwan,让开发者在一次操作中从零开始,在真实设备或模拟器上实现低于一秒的热重载。涵盖 JetBrains IDE 插件安装、`com.github.skydoves.compose.hotswan.compiler` Gradle 插件配置、标准的 `hotSwanCompiler { enabled = true; debugOnly = true }` DSL 代码块、HotSwan 工具窗口操作流程,以及首次保存后验证重载。用户提到 HotSwan、Compose 热重载、UI 即时更新、“保存后就能看到”“无需重新构建”、设备上的实时编辑、快速迭代 Compose,或已安装 JetBrains 插件并询问如何应用 Gradle 编译器插件时,触发此技能。

Add to TypingMind

概览

发布者skydoves
代码仓库compose-performance-skills
技能名称setting-up-compose-hotswan
星标数
515
复刻数
19
附带文件
仅含指令
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 skydoves 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Setting Up Compose Hotswan AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/skydoves/compose-performance-skills/tree/main/hot-reload/setting-up-compose-hotswan
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/skydoves/compose-performance-skills.git /tmp/compose-performance-skills
mkdir -p .claude/skills
cp -r /tmp/compose-performance-skills/hot-reload/setting-up-compose-hotswan .claude/skills/setting-up-compose-hotswan
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Setting Up Compose Hotswan,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Setting Up Compose Hotswan。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Setting Up Compose Hotswan 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Setting Up Compose HotSwan: zero to sub-second reload on a real device

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.

Versions verified at the time of authoring. Confirm against the current release notes for newer minors.

When to use this skill

  • The developer mentions HotSwan, hot reload, instant UI update, "save and see", "no rebuild", live edit, or fast Compose iteration on device.
  • The developer has the HotSwan JetBrains Marketplace plugin installed and asks how to apply the Gradle compiler plugin.
  • A team is onboarding a new project to HotSwan and wants the canonical libs.versions.toml + root build + app build wiring.
  • The developer just installed the IDE plugin and the tool window status is stuck before WATCHING.

When NOT to use this skill

  • The question is about JetBrains' own Live Edit or Apply Changes features. HotSwan and those are separate products with different boundaries; do not conflate.
  • The question is about Compose Preview rendering inside the IDE. HotSwan targets the running app on a real device or emulator, not preview canvases.
  • The question is about which changes hot-reload vs force a rebuild. See ../understanding-hot-reload-limits/SKILL.md.
  • The question is about preserving complex state across reloads. See the state-preservation sibling skill (out of scope here).

Prerequisites

  • Android Studio 2024.3+ or IntelliJ IDEA 2024.3+.
  • Kotlin 2.0+ with the org.jetbrains.kotlin.plugin.compose Gradle plugin already applied on the Compose modules.
  • Gradle 8+.
  • A real device or emulator with USB debugging enabled and visible to adb devices.
  • The HotSwan IDE plugin installed from JetBrains Marketplace (https://plugins.jetbrains.com/plugin/30551-compose-hotswan/).

Workflow

  1. Declare the plugin in libs.versions.toml so the version pins centrally:

    toml
    [plugins]
    hotswan-compiler = { id = "com.github.skydoves.compose.hotswan.compiler", version = "1.2.10" }

    Pin 1.2.10 (latest verified at the time of authoring). Check the HotSwan releases page 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.

  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:

    kotlin
    plugins {
        alias(libs.plugins.hotswan.compiler) apply false
    }
  3. Apply in each Compose app module's build.gradle.kts:

    kotlin
    plugins {
        alias(libs.plugins.android.application)
        alias(libs.plugins.kotlin.android)
        alias(libs.plugins.kotlin.compose)
        alias(libs.plugins.hotswan.compiler)
    }
  4. Configure the canonical DSL block in the same module file. The capital S in hotSwanCompiler is part of the identifier:

    kotlin
    hotSwanCompiler {
        enabled = true
        debugOnly = true
    }

    debugOnly = true is the default and the rule for production. Release builds MUST NOT carry the HotSwan transformations.

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

  6. Open the HotSwan tool window via View -> Tool Windows -> HotSwan. Click Start. The status indicator should change to READY.

  7. Run the app normally with the Run action. Once the app process connects, the tool window status moves from READY to WATCHING.

  8. Make a body-only edit and save. Change the color or text inside one composable function body, then save the file. The change should appear on device in under one second; navigation, scroll position, and remember values stay intact.

  9. If the change does not appear, fall through to the troubleshooting checklist below before changing any Gradle configuration.

Patterns

Pattern: configure with debugOnly true (production safety)

kotlin
// WRONG
hotSwanCompiler {
    enabled = true
}
// WRONG because: omitting `debugOnly = true` allows the HotSwan transformations to attach to release
// builds. They are diagnostic-only and MUST NOT ship in production.
kotlin
// RIGHT
hotSwanCompiler {
    enabled = true
    debugOnly = true
}

Pattern: respect the capital S in the DSL block name

kotlin
// WRONG
hotswanCompiler {
    enabled = true
    debugOnly = true
}
// WRONG because: the extension is hotSwanCompiler with a capital S in the middle. Lowercase will
// not resolve and Gradle reports an unknown extension.
kotlin
// RIGHT
hotSwanCompiler {
    enabled = true
    debugOnly = true
}

Pattern: apply at root with apply false, in modules with alias(...)

kotlin
// WRONG (root build.gradle.kts)
plugins {
    alias(libs.plugins.hotswan.compiler)
}
// WRONG because: applying at the root project triggers the compiler plugin everywhere, including
// modules without Compose. Use apply false at the root and alias(...) inside each Compose module.
kotlin
// RIGHT (root build.gradle.kts)
plugins {
    alias(libs.plugins.hotswan.compiler) apply false
}
kotlin
// RIGHT (app/build.gradle.kts; Compose module)
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    alias(libs.plugins.kotlin.compose)
    alias(libs.plugins.hotswan.compiler)
}

hotSwanCompiler {
    enabled = true
    debugOnly = true
}

Pattern: do not depend on HotSwan at the source level

kotlin
// WRONG
import com.github.skydoves.compose.hotswan.runtime.HotReloadable

@HotReloadable
@Composable
fun Greeting() { Text("Hello") }
// WRONG because: HotSwan is a build-time and IDE-time tool. Production code must not import
// HotSwan runtime classes or annotations; the Gradle plugin attaches transformations during
// compilation without requiring source-level coupling.
kotlin
// RIGHT
@Composable
fun Greeting() { Text("Hello") }

Pattern: canonical three-file setup (paste-ready)

toml
# gradle/libs.versions.toml
[plugins]
hotswan-compiler = { id = "com.github.skydoves.compose.hotswan.compiler", version = "1.2.10" }
kotlin
// build.gradle.kts (root)
plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.kotlin.android) apply false
    alias(libs.plugins.kotlin.compose) apply false
    alias(libs.plugins.hotswan.compiler) apply false
}
kotlin
// app/build.gradle.kts
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    alias(libs.plugins.kotlin.compose)
    alias(libs.plugins.hotswan.compiler)
}

hotSwanCompiler {
    enabled = true
    debugOnly = true
}

Troubleshooting

  • Status stuck at READY after Run. The device is not connected. Run adb devices and confirm the device or emulator is listed; reconnect USB or restart the emulator.
  • Status WATCHING but no reload on save. The save was a structural change (parameter, constructor, interface, inline function, new resource id). Cross-link ../understanding-hot-reload-limits/SKILL.md to identify the boundary.
  • Reload happens but state is lost. The change cascaded to a tier-2 (composition reset) or tier-3 (Activity.recreate()) recomposition. Cross-link the state-preservation sibling skill once available.
  • The hotSwanCompiler { ... } block does not resolve. Gradle did not sync after adding the plugin. Re-sync; verify Kotlin 2.0+ is the active Kotlin version on the module; verify the alias matches the entry in libs.versions.toml.

Mandatory rules

  • MUST set debugOnly = true. HotSwan transformations are diagnostic-only and MUST NOT ship in release builds.
  • MUST apply the Gradle plugin only on Compose modules. Apply at the root project with apply false so non-Compose modules are not transformed.
  • MUST NOT depend on HotSwan classes at the source level. No annotations, no runtime imports. HotSwan is a build-time and IDE-time tool; production code stays pure.
  • MUST NOT mix HotSwan with a stale Compose Compiler. Verify org.jetbrains.kotlin.plugin.compose is applied on Kotlin 2.0+ before adding HotSwan.
  • MUST pin the HotSwan version in libs.versions.toml so all Compose modules in the project use a single version. The latest verified version is 1.2.10; check hotswan.dev/docs/releases for newer stable releases before pinning.
  • PREFERRED: combine HotSwan with the AI iteration loop sibling skill (../iterating-with-ai-and-mcp/SKILL.md) once the developer is comfortable with manual hot reload and wants Claude to drive the edit-reload-screenshot cycle via MCP.

Verification

  • ./gradlew :app:buildEnvironment lists the com.github.skydoves.compose.hotswan.compiler plugin among applied plugins.
  • The HotSwan tool window status reads WATCHING after the app launches with Run.
  • Editing a Text color inside a composable and saving the file changes the color on device within one second.
  • remember values, scroll position, and the navigation back stack survive the change.
  • A release build (./gradlew :app:assembleRelease) does not include HotSwan transformations. Verify by confirming debugOnly = true is set, or by inspecting the release dex with dexdump for the absence of HotSwan-injected helper classes.
  • No production source file in the module imports a com.github.skydoves.compose.hotswan.* symbol (grep -R "com.github.skydoves.compose.hotswan" src/main/ returns zero hits).

References

常见问题

Setting Up Compose Hotswan AI 技能有什么作用?

使用此技能,端到端安装并验证 Compose HotSwan,让开发者在一次操作中从零开始,在真实设备或模拟器上实现低于一秒的热重载。涵盖 JetBrains IDE 插件安装、`com.github.skydoves.compose.hotswan.compiler` Gradle 插件配置、标准的 `hotSwanCompiler { enabled = true; debugOnly = true }` DSL 代码块、HotSwan 工具窗口操作流程,以及首次保存后验证重载。用户提到 HotSwan、Compose 热重载、UI 即时更新、“保存后就能看到”“无需重新构建”、设备上的实时编辑、快速迭代 Compose,或已安装 JetBrains 插件并询问如何应用 Gradle 编译器插件时,触发此技能。

为什么在 TypingMind 中使用 Setting Up Compose Hotswan?

因为您只需安装一次,就能搭配任何模型使用。Setting Up Compose Hotswan 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Setting Up Compose Hotswan?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/skydoves/compose-performance-skills/tree/main/hot-reload/setting-up-compose-hotswan。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Setting Up Compose Hotswan?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Setting Up Compose Hotswan 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Setting Up Compose Hotswan 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Setting Up Compose Hotswan AI 技能免费吗?

是的。skydoves 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇