/ 目錄 / 演練場 / jetpack-compose-skills
● 社群 anhvt52 ⚡ 即開即用

jetpack-compose-skills

作者 anhvt52 · anhvt52/jetpack-compose-skills

Make Claude an Android Compose dev — idiomatic @Composable, state hoisting, Material 3, proper previews.

jetpack-compose-skills encodes modern Android development patterns for Jetpack Compose: state hoisting, @Composable scoping, Modifier order rules, Material 3 theming, ViewModel + StateFlow wiring, navigation-compose, and Compose-compliant testing. Good for both greenfield Compose projects and migrating Views-based screens.

為什麼要用

核心特性

即時演示

實際使用效果

jetpack-compose-skill.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "jetpack-compose-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anhvt52/jetpack-compose-skills",
        "~/.claude/skills/jetpack-compose-skills"
      ],
      "_inferred": true
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "jetpack-compose-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anhvt52/jetpack-compose-skills",
        "~/.claude/skills/jetpack-compose-skills"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "jetpack-compose-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anhvt52/jetpack-compose-skills",
        "~/.claude/skills/jetpack-compose-skills"
      ],
      "_inferred": true
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "jetpack-compose-skill": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anhvt52/jetpack-compose-skills",
        "~/.claude/skills/jetpack-compose-skills"
      ],
      "_inferred": true
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "jetpack-compose-skill",
      "command": "git",
      "args": [
        "clone",
        "https://github.com/anhvt52/jetpack-compose-skills",
        "~/.claude/skills/jetpack-compose-skills"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "jetpack-compose-skill": {
      "command": {
        "path": "git",
        "args": [
          "clone",
          "https://github.com/anhvt52/jetpack-compose-skills",
          "~/.claude/skills/jetpack-compose-skills"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add jetpack-compose-skill -- git clone https://github.com/anhvt52/jetpack-compose-skills ~/.claude/skills/jetpack-compose-skills

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: jetpack-compose-skills

How to build a new Compose screen with state hoisting

👤 Android developers writing Compose UI ⏱ ~30 min intermediate

何時使用: New screen in a Compose app — get it right the first time rather than refactoring later.

前置條件
  • Android Studio with a recent Compose BOM — Use the latest stable Compose BOM in your build
  • Skill cloned — git clone https://github.com/anhvt52/jetpack-compose-skills ~/.claude/skills/jetpack-compose-skills
步驟
  1. Describe the screen
    Build a Profile screen: avatar, name, bio, follow button. State comes from a ProfileViewModel.✓ 已複製
    → Stateless composable + stateful wrapper + preview
  2. Wire the ViewModel
    Hook up the ViewModel using collectAsStateWithLifecycle.✓ 已複製
    → Lifecycle-aware state collection
  3. Add a preview
    Add @Preview variants for empty, loaded, and error states.✓ 已複製
    → Three previews rendering without a live ViewModel

結果: A clean Compose screen with previews and a testable structure.

注意事項
  • Stateful composables you can't preview — Keep the composable stateless; hoist state to a wrapper
  • Wrong Modifier order — Skill prompts the order rule — padding before background for a padded background, etc.
搭配使用: filesystem

Migrate a Views-based screen to Compose

👤 Teams converting legacy Android screens ⏱ ~90 min advanced

何時使用: You want to convert one screen at a time without rewriting the whole app.

步驟
  1. Map the XML
    Here's fragment_profile.xml. Map each widget to a Compose equivalent with notes on behaviors to preserve.✓ 已複製
    → XML → Compose mapping with behavior notes
  2. Rewrite
    Produce the Compose screen. Keep state + actions identical to the Fragment.✓ 已複製
    → Composable file + ViewModel untouched
  3. Keep the navigation hybrid if needed
    Swap only this screen, leave the rest on Fragments using ComposeView.✓ 已複製
    → Hybrid navigation continues to work

結果: One screen cleanly ported without destabilizing the rest.

注意事項
  • Observer leaks when mixing with Fragment lifecycle — Use viewLifecycleOwner with ComposeView; release on destroy
搭配使用: android

組合

與其他 MCP 搭配,撬動十倍槓桿

jetpack-compose-skill + android

Run the resulting screen in an emulator and iterate

Build the app, launch in the emulator, and show me the Profile screen.✓ 已複製
jetpack-compose-skill + filesystem

Work across modules in a Compose project

Read feature/profile/ and add a Profile screen in ui/.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
compose-authoring screen intent + state Any new Compose UI 0
state-hoisting-review existing composable When a composable is hard to preview 0
view-to-compose-migration XML + behaviors Screen-by-screen migrations 0

成本與限制

運行它的成本

API 配額
none
每次呼叫 Token 數
3–15k per screen
費用
free
提示
Scope to one screen + its ViewModel at a time

安全

權限、密鑰、影響範圍

憑證儲存: none at skill level
資料出站: none

故障排查

常見錯誤與修復

Preview fails to render

Make composables stateless; drop the ViewModel from the preview path.

StateFlow not collecting on background

Use collectAsStateWithLifecycle, not collectAsState, on screens that may be backgrounded.

替代方案

jetpack-compose-skills 對比其他方案

替代方案何時用它替代權衡
apple-hig-designer-skillYou're on iOS SwiftUI instead of Android ComposeDifferent platform
claude-android-skillYou need broader Android help beyond UILess Compose-specific

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills