/koin:di-migrationfrom koin
Migrates Kotlin/Android/KMP projects to Koin 4.x with the Koin Compiler Plugin from Hilt, Dagger 2, Toothpick, Kodein, Metro, or Koin 3.x. Supports progressive module-by-module migration, KSP removal, and DSL-to-compiler plugin conversion.
Ships in koin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Migrate Kotlin/Android/KMP projects between DI frameworks, targeting Koin 4.x
with the Koin Compiler Plugin. The per-source reference files in
references/ hold the concrete mappings and examples — this file is the
contract and the workflow.
Read references/rules.md first (non-negotiable). references/index.md lists
the other shared references and what each owns — read the owner of any detail
you need instead of inferring from memory.
rules.md §1, an explicit choice):
references/dsl-to-compiler.md)references/dsl-to-compiler.mdreferences/ksp-to-compiler.md.references/gradle.md) and Step 5 (wiring,
references/entry-points.md) — with the style from rule 1.All target Koin 4.x + Koin Compiler Plugin. Read the relevant reference before generating code. If the source is ambiguous, ask.
| Source | Reference File |
|---|---|
| Hilt (+ Dagger) | references/hilt-to-koin.md |
| Dagger 2 (no Hilt) | references/dagger-to-koin.md |
| Toothpick | references/toothpick-to-koin.md |
| Kodein | references/kodein-to-koin.md |
| Metro | references/metro-to-koin.md |
| Koin 3.x | references/koin3-to-koin4.md |
| Koin DSL | references/dsl-to-compiler.md |
| Koin KSP Annotations | references/ksp-to-compiler.md |
Not covered by this skill: greenfield projects and manual-DI /
service-locator code have no source framework to map from. Use the
koin-setup skill instead.
Recommended approach: leaf-first, smallest-first, then ack-and-grow.
Two strategies exist for ordering a multi-module migration:
| Strategy | When | Trade-off |
|---|---|---|
| Leaf-first (small leaf/feature modules first, then grow toward core) — default | Almost every project | Small early wins, validates the whole workflow on a low-risk module, builds team confidence with Koin idioms, surfaces tooling/Gradle gotchas before they hit critical code |
| Bottom-up (core / data first, then features above) | Rare — only if the core graph is tiny and unambiguous, and feature modules already compile against an interface boundary | Avoids bridging from core into Koin (because nothing depends on feature modules), but blocks all feature work until the foundational layer is rewritten and validated |
Default recommendation: leaf-first. Start with the smallest, most peripheral
module you can find, bridge any dependencies it still has back into the legacy
container, validate the full per-module loop end-to-end, then get explicit user
acknowledgement before picking the next target. Each subsequent target moves
one level toward core / data / app. Never jump straight to AppModule.
Rank candidates inside the leaf-first strategy and propose the top 1–3; ask for confirmation before any code:
core / common — limited call-site reachAfter each module migrates and passes validation (Step 7), explicitly ask the user before moving on: "next target?", with a fresh ranked list reflecting what's now eligible. This ack-per-module rhythm is what keeps the migration safe — it prevents Claude from chaining several migrations without the user catching a regression.
Defer: AppModule, @EntryPoint-exposed bindings, Worker/ContentProvider-used
bindings, custom component hierarchies.
Present a ranked table (Rank | Module | Bindings | Dependants | Complexity | Recommended?) before proceeding.
When: Koin source (Koin 3.x, Classic/Constructor DSL, Koin KSP) — after the plan is confirmed, before Step 3, on the current version before any change. Other source (Hilt, Dagger, Toothpick, Kodein, Metro) — before the first module.
Detect Kotzilla ("Detect first" in references/kotzilla.md). Not in place, or
MCP only (no SDK) → propose it once, here (handoff rules), because a
baseline can't be captured once code has changed. For a migration it checks
each moved module (loop item 5) and diagnoses a Koin crash, then shows how the
app behaves once migrated. Accepted → used from here on, no new offer.
Then, if the SDK is in place:
references/kotzilla.md, with the scope mapping of
the per-source reference).Declined → the loop runs without item 5, and Kotzilla isn't offered again.
Migration is a loop, not a waterfall. For each module (Steps 4, 6 and 7 of the workflow):
references/rules.md §6). When the report isn't enough and the Kotzilla
MCP is connected, koin_diagnose on the full [KOIN-…] error text —
optionalandroidContext, wrong scope, stale bridge call) only surface at
runtime. A Koin crash: Kotzilla MCP connected → koin_diagnose with the full
stack trace (MCP alone, no SDK); not connected → diagnose from the stack
trace and references/rules.md, and propose the MCP once (handoff rules in
references/kotzilla.md) unless already declinedreferences/kotzilla.md). Report each definition
as verified, a mismatch, or not verified (no session). A mismatch — a
@Singleton migrated to a factory, a scope never closed, a new main-thread
cost — is fixed before the commit. Bindings still behind a bridge are
reported as not checkable yet.The loop is references/rules.md §10 applied to migration: a small project
(one Gradle module, about five bindings) migrates in one verified step; a
single-module app with more is split by feature (a screen's ViewModel and what
it needs), the rest staying in the old container.
Do not batch un-validated migrations. If validation fails, fix or revert before touching anything else.
Koin definitions that still need bindings from the old container use a bridge
co-located in the consumer module — per source, with startup ordering:
references/bridging.md.
koin skill takes the task.koin-setup.2.3.20 and the bump is impossible → stop and say so
(references/rules.md §3); only the Koin runtime upgrade without the plugin
remains (references/koin3-to-koin4.md).Scan for every DI-related file: modules, components, entry points, qualifiers, scopes, workers. Classify each binding (singleton, factory, scoped, assisted, multibinding, viewModel). Search for every construct in the source column of the per-source reference, its Warning and Blocker rows included, and list those bindings apart. Flag anything needing manual attention (custom scopes, reflection-based injection). Count total bindings.
Present as a table (# | Source File | Binding Type | Scope | Notes) before proceeding.
Produce:
references/bridging.md. Say whichStop here. Present the inventory and the plan, then end your turn: no file
edits until the user confirms the plan, the first target and any Kotlin bump
(references/rules.md §3). Skip the stop only when the user's message already
confirms them. Declined → Koin source: koin continues the task in the
current setup. Other source (Hilt, Dagger, Toothpick, Kodein, Metro): the work stays in
the existing container — koin only if Koin already runs alongside it.
Koin source: runtime check setup first (see above).
Versions — per references/rules.md §3 (latest on Maven Central, Kotlin
bump cascade).
Then produce the Gradle diff:
references/gradle.md — only the artifacts the project needs.
The old framework stays until Step 8; a Koin source swaps Koin KSP for the
Compiler Plugin here, for the whole project (references/ksp-to-compiler.md)Use the target style from migration rule 1. Produce BEFORE/AFTER blocks per
module, following the relevant per-source reference and the style's cheat
sheet. KMP → expect/actual at any granularity (@Module class, annotated
class, or plain function).
Configuration per references/rules.md §5 — code in the style's cheat sheet
("App entry point"). Annotations: @KoinApplication + startKoin<App>, each
Gradle module root discovered. DSL: startKoin loads one app module that
includes(...) the migrated modules. Old container still running → both start
in the Application — "Two containers at startup" in references/bridging.md.
Field injection (@Inject lateinit var): at framework entry points (Activity,
Fragment, Service…) → the Koin API for that entry point (references/entry-points.md);
in normal classes → constructor injection, never KoinComponent (references/rules.md §8).
hiltViewModel() → koinViewModel(), scope access → references/scopes.md. Remove
@AndroidEntryPoint per entry point once it no longer uses the old container;
@HiltAndroidApp (and the Dagger component, Toothpick root scope, Kodein
DI creation or Metro graph) stays until Step 8 — bridges read through it. Show each changed file with before/after.
Run after every module, not only at the end.
KoinTestRule or startKoin in test setup,
mock replacement (references/testing.md). Graph verification is
compile-time (Compiler Plugin) — no new checkModules { } / verify()
tests. Show before/after for existing test files.When the last module has been migrated and validated:
@Inject, @Module, @Component, @HiltAndroidApp, etc.)Dagger*Component, *_Factory, *_MembersInjector)dagger<T>() / toothpick<T>() / kodein<T>() / @Component delegation) removed, with MetroBridgeModule and the Metro graph holderbuild.gradle.kts; KSP/kapt plugins removed if no longer neededConstructor and function parameters (T, T?, Lazy<T>, List<T>,
@InjectedParam, qualifiers, properties) are resolved by the Compiler Plugin —
see "Parameter resolution" in references/koin-compiler-plugin-dsl.md and "Parameters &
qualifiers" in references/koin-annotations.md. JSR-330 annotations from the
source framework are reused as-is.
Read the relevant reference section:
@InjectedParam + parametersOf(); an assisted
ViewModel call site with a key keeps it (Compose in references/entry-points.md)T,
consumers inject List<T> — "Multibindings" in references/dagger-to-koin.md.
Kodein set bindings and multiton: "Set Bindings and Multiton" in
references/kodein-to-koin.mdreferences/scopes.md —
a child graph with its own lifetime maps to a scope, not a factory: the
archetype when it follows an Activity, Fragment or ViewModel, otherwise a
custom scope ("Choose the scope"); a runtime input → "Scope with a runtime value"@BindsInstance, graph factory arguments) → "Values known
at startup" in references/entry-points.mdLazy<T> constructor parameter (references/principles.md rule 7);
Provider<T> for a fresh instance per call → "Lazy and Provider" in references/dagger-to-koin.mdreferences/entry-points.mdreferences/koin-compiler-plugin-dsl.md). For each default
whose type the graph provides, pass it with a function builder or drop the
default — otherwise the behavior changes silentlyProposed at "Runtime check setup", and the MCP once on a Koin crash (loop item
4) if not declined. Once in place, used for Koin crashes (loop item 4) and the
per-module check (loop item 5). A runtime question during the migration ("is it
slower now?") → Kotzilla when in place, otherwise proposed — unless declined,
then one line (handoff rules). Rules and expected behavior:
references/kotzilla.md.
io.insert-koin.compiler.plugin — versions in references/rules.md §3references/rules.md §6@Module, @Configuration, @KoinApplication, @Monitor, top-level functionsWhen explaining why Koin: "Koin in short" in references/index.md. Plus, for a
migration: progressive — Koin and the old container coexist until the last
binding moves.
references/bridging.md (opens in a new tab)references/dagger-to-koin.md (opens in a new tab)references/dsl-to-compiler.md (opens in a new tab)references/entry-points.md (opens in a new tab)references/gradle.md (opens in a new tab)references/hilt-to-koin.md (opens in a new tab)references/index.md (opens in a new tab)references/kodein-to-koin.md (opens in a new tab)references/koin-annotations.md (opens in a new tab)references/koin-compiler-plugin-dsl.md (opens in a new tab)references/koin3-to-koin4.md (opens in a new tab)references/kotzilla.md (opens in a new tab)references/ksp-to-compiler.md (opens in a new tab)references/metro-to-koin.md (opens in a new tab)references/principles.md (opens in a new tab)references/rules.md (opens in a new tab)references/scopes.md (opens in a new tab)references/testing.md (opens in a new tab)references/toothpick-to-koin.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub insertkoinio/koin-skills --plugin koin4 skills in this plugin
/koinUse for the dependency-injection part of ANY task in a Kotlin, Android, Compose, KMP or Ktor project that uses Koin, even when the request never mentions DI or Koin: adding a feature, screen, ViewModel, repository, use case, service, worker or Gradle module; adding Navigation 3; writing tests; refactoring or splitting modules; upgrading AGP, Kotlin or Gradle. Load it alongside other skills whenever the change creates, injects or wires a class. Covers definitions, modules, entry points, scopes, Koin tests, and pushing back on DI mistakes (a ViewModel as single, an Activity in a singleton, I/O in a constructor). Koin APIs: koinViewModel, koinInject, by inject, @KoinViewModel, single<T>(). On Koin KSP, Koin 3.x or without the Compiler Plugin (build upgrades included): do the task, propose compile safety once per conversation. Koin not set up → koin-setup. Moving off Hilt, Dagger, Toothpick, Kodein, Metro → di-migration. Crashes, slow startup, instances created twice, memory → koin-diagnose.
/koin-diagnoseDiagnose and fix Koin dependency injection problems in Android, KMP and Ktor apps — from Koin compile errors and runtime exceptions to how the app behaves: slow startup, ANRs, main-thread freezes, slow screens, memory, instances created twice, scope leaks. Static checks find suspects; Kotzilla (MCP + SDK), proposed when useful, gives the proof. Use when the build shows a [KOIN-…] error, a stacktrace contains org.koin.core.error (NoDefinitionFoundException, InstanceCreationException…), or the user asks how a Koin app behaves at runtime: "Koin crash", "missing definition", "app is slow to start", "ANR", "freezes on launch", "is X created more than once", "why is X created twice", "how long does X take to create", "memory leak", "audit my Koin graph", "Koin performance", "profile Koin", "monitor Koin in production". Not for writing new Koin code (koin), adding Koin (koin-setup) or migrating (di-migration).
Other plugins' skills for the same job