# 策展 · X (Twitter) 🔥

> 📖 本站完整內容索引（documentation index）：[llms.txt](/llms.txt)

> 作者：Arnaud Giuliani (@arnogiu) · 平台：X (Twitter) · 日期：2026-04-22

> 原始來源：https://x.com/arnogiu/status/2046514309547598103

## 中文摘要

Koin Migration Skill自動化Kotlin DI遷移至Koin 4.x。

**Koin Migration**推出Claude Code plugin，專為Kotlin、Android及KMP專案提供遷移指南與AI自動化工具，將Hilt、Dagger等框架轉換至Koin 4.x搭配Compiler Plugin。該工具結合參考文件與AI技能，支援多種DI框架遷移路徑，避免直接改寫既有模組。

**支援遷移路徑**  
涵蓋以下來源框架至目標Koin 4.x + Compiler Plugin：  
- Hilt (+ Dagger) → Koin 4.x + Compiler Plugin (annotations)  
- Dagger 2 (no Hilt) → Koin 4.x + Compiler Plugin (annotations)  
- Toothpick → Koin 4.x + Compiler Plugin (annotations)  
- Kodein → Koin 4.x + Compiler Plugin (Safe DSL)  
- Koin 3.x → Koin 4.x Safe DSL + Compiler Plugin  
- Koin DSL → Koin 4.x Safe DSL + Compiler Plugin  
- Koin KSP Annotations → Koin 4.x Annotations + Compiler Plugin  

綠地專案或手動DI無需遷移，直接依官方文件insert-koin.io使用Safe DSL + Compiler Plugin慣例。

**安裝方式**  
推薦透過Claude Code執行：  
```
/plugin marketplace add InsertKoinIO/koin-migration
/plugin install koin-migration@koin-migration
```  
更新時重跑第二指令。手動安裝則git clone https://github.com/InsertKoinIO/koin-migration.git，並以claude --plugin-dir指向目錄，或複製skills/di-migration至.claude/skills目錄（專案級或個人級）。

**使用流程**  
直接向Claude下達指令，如「Migrate this Hilt module to Koin」或「Upgrade my Koin 3.x project to Koin 4.x」。技能遵循8步工作流程：Inventory → Plan → Gradle Setup → Generate Code → Wire Up → Update Injection Sites → Test Configuration → Verify & Cleanup。預設漸進式遷移，建議新建Koin模組逐步移轉定義，避免改寫既有DI模組；Hilt/Dagger專案可透過koin-android-dagger橋接，讓Koin與Hilt共存。

**核心功能**  
- **Koin Compiler Plugin** (`io.insert-koin.compiler.plugin`)：編譯時驗證依賴，無生成檔案。  
- **Auto parameter resolution**：自動處理`T`、`T?`、`Lazy<T>`、`List<T>`。  
- **Auto-bind**：單一介面實作自動偵測，無需明確`binds`。  
- **JSR-330 support**：`javax.inject.*`及`jakarta.inject.*`註解直接重用。  
- **Custom qualifiers**：Dagger/Hilt的`@Qualifier`註解直接相容。  
- **Scope archetypes**：`@ActivityScope`、`@FragmentScope`、`@ViewModelScope`、`@ActivityRetainedScope`。  
- **Safe DSL**：`single<T>()`、`factory<T>()`、`viewModel<T>()`支援reified型別參數。  

版本1.0.0，Apache-2.0授權，需Kotlin ≥ 2.3.20 (K2 compiler)及Koin 4.2.1+。

**Kotzilla MCP Server輔助**  
遷移期間及後續，使用Kotzilla MCP Server提供AI輔助Koin配置修復、最佳實務及除錯。免費註冊https://kotzilla.io，端點https://mcp.kotzilla.io/mcp (HTTP transport，需認證)。Claude Code範例：  
```bash
claude mcp add kotzilla --transport http https://mcp.kotzilla.io/mcp
```

**貢獻與建置**  
歡迎開issue回報bug或遷移路徑缺失，提供來源框架、最小程式碼片段及預期Koin輸出。新遷移路徑新增references/<source>-to-koin.md，註冊至skills/di-migration/SKILL.md，執行./build.sh建置plugin。本地建置產生koin-migration-plugin.zip及di-migration-skill.skill；發行參考RELEASING.md。

**儲存庫結構**  
```
.claude-plugin/
  plugin.json                       # plugin manifest (name, version, metadata)
  marketplace.json                  # makes this repo installable via /plugin marketplace add
skills/di-migration/
  SKILL.md                          # skill entry point
  references/*.md                   # per-path migration guides
  evals/evals.json                  # evaluation cases
build.sh                            # validates + packages the plugin
```

該工具強調Koin 4.x的輕量與編譯時安全，透過Claude AI大幅簡化DI遷移痛點，特別適合既有Kotlin專案轉型，避免手動重構風險。GitHub連結：http://github.com/InsertKoinIO/koin-migration。

## 標籤

Skills, Claude Code, Kotlin, Android, 自動化, 功能更新, Koin, Anthropic, Claude
