/ 目錄 / 演練場 / claude-android-skill
● 社群 dpconde ⚡ 即開即用

claude-android-skill

作者 dpconde · dpconde/claude-android-skill

教導 Claude Code 以 Google 推薦的方式建構現代 Android 應用程式——Clean Architecture、Compose、Hilt、Room、Flow、離線優先、按功能分模組。

一個將現代 Android 最佳實踐(對應 NowInAndroid 參考專案)編碼進 Claude Code 的技能:Clean Architecture 包含 UI/Domain/Data 分層、MVVM + UDF、Jetpack Compose 負責 UI、Hilt 負責依賴注入、Room 負責資料持久化、Kotlin Flow 負責響應式串流、Retrofit 負責網路請求,以及按功能優先的多模組專案結構。

為什麼要用

核心特性

即時演示

實際使用效果

claude-android-skill.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

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

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

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

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

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

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

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

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

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

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

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

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

claude mcp add claude-android-skill -- git clone https://github.com/dpconde/claude-android-skill ~/.claude/skills/claude-android-skill

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

使用場景

實戰用法: claude-android-skill

使用現代架構為新 Android 應用程式建立骨架

👤 正在開始全新專案的 Android 開發者 ⏱ ~60 min intermediate

何時使用: 當你要開始一個新應用程式,且不想在六個月後才來修正架構上的錯誤。

前置條件
  • Skill cloned — git clone https://github.com/dpconde/claude-android-skill ~/.claude/skills/claude-android-skill
  • Android Studio + JDK 17 — 安裝最新穩定版 Android Studio
步驟
  1. 請 Claude 建立模組結構骨架
    Use claude-android-skill. Scaffold a multi-module Android app called 'HabitTracker' with features: home, tracking, settings. Compose UI, Hilt DI, Room DB, offline-first.✓ 已複製
    → 模組 :app、:core:database、:core:ui、:feature:home… 已產生
  2. 端對端加入第一個功能
    Implement the tracking feature: data layer with Room entity, domain layer with use cases, UI with Compose and ViewModel. Include unit tests.✓ 已複製
    → 橫跨三個分層的檔案與測試均可編譯

結果: 一個遵循 NowInAndroid 風格模式且可執行的應用程式。

注意事項
  • 將一個小型應用程式過度設計成 8 個模組 — 明確告訴技能:'這裡用單一模組就好',適用於簡單專案
搭配使用: filesystem · github

將 Fragment/XML 畫面遷移至 Compose

👤 正在現代化舊有畫面的 Android 團隊 ⏱ ~45 min intermediate

何時使用: 當你有一個 XML 畫面,想要採用 Compose 但不想一次全部重寫。

步驟
  1. 分析現有畫面
    Here's the Fragment + XML for SettingsScreen. Plan a Compose migration keeping the ViewModel intact.✓ 已複製
    → 步驟計畫:以 ComposeView 包裝、移植 View、清除 XML
  2. 執行遷移
    Implement step 1 — add ComposeView and move the header to Compose.✓ 已複製
    → 混合畫面正常運作;後續步驟分段進行

結果: 一個保留原有 ViewModel 合約的 Compose 畫面。

注意事項
  • 遷移過程中狀態遺失 — 保留相同的 ViewModel,只有 UI 層會變動
搭配使用: github

為僅支援線上的功能加入離線優先支援

👤 應用程式在無網路時會出現問題的開發者 ⏱ ~90 min advanced

何時使用: 當你有一個只使用 Retrofit 的功能,且想要快取或佇列行為。

步驟
  1. 引入 Room 與 Repository
    Use claude-android-skill to convert the profile feature to offline-first. Add Room entity, repository returning Flow, and a sync worker.✓ 已複製
    → 資料層已重構,Repository 成為唯一的資料來源
  2. 將 UI 連接至 Flow
    Update ViewModel to collect from the repository Flow; handle loading/empty/error states in Compose.✓ 已複製
    → 同步後首次啟動時,UI 在離線狀態下仍可正常運作

結果: 一個在飛航模式下仍可正常運作的功能。

注意事項
  • 忘記處理衝突解決策略 — 事先決定策略:LWW、伺服器優先或合併——技能會提示你

組合

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

claude-android-skill + github

每個功能開一個 PR,讓骨架易於審查

Generate the home feature and open a GitHub PR with just those files.✓ 已複製
claude-android-skill + filesystem

在單一工作階段中跨多個模組進行編輯

Apply the Hilt migration across every :feature:* module.✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
scaffold_module_tree app name, feature list 全新專案開始時使用 0
generate_feature feature name, data model 新增功能時使用 0
migrate_to_compose fragment/xml path 舊有畫面現代化時使用 0

成本與限制

運行它的成本

API 配額
技能本身不消耗配額;Android SDK 免費
每次呼叫 Token 數
用量較大——骨架加上測試可能超過 20k token
費用
免費
提示
骨架只建一次,之後逐一功能迭代——避免使用「產生整個應用程式」的提示詞

安全

權限、密鑰、影響範圍

憑證儲存: API 金鑰存放於 local.properties + BuildConfig,絕不提交至版本控制
資料出站: 技能本身不傳送任何資料至外部

故障排查

常見錯誤與修復

Hilt compile error: missing @HiltAndroidApp

確認 Application 類別已加上 @HiltAndroidApp 標註,並在 manifest 中宣告

驗證: grep -r '@HiltAndroidApp' app/src/
Room schema mismatch on migration

提供 Migration 實作,或在開發環境中設定 fallbackToDestructiveMigration

Compose preview won't render

加入 Compose preview 依賴項,並確認 @Preview 標註正確

替代方案

claude-android-skill 對比其他方案

替代方案何時用它替代權衡
Google's NowInAndroid repo你只是想要一個可以參考複製的範例專案靜態參考——不會為你產生程式碼

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

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