/android-skills:koinfrom android-skills
Sets up Koin DI in Android and KMP projects: module declarations with Classic DSL or KSP annotations, ViewModel injection in Compose, scopes, Nav 3 entry providers, and compile-time verification via verify().
Ships in android-skills. 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.
None: SKILL.md is the whole skill.
Pragmatic Kotlin DI. Koin vs Hilt: Koin runs in commonMain (Hilt doesn't) and verifies the graph via verify() instead of codegen; Hilt is Android-only with codegen + deep Jetpack integration (@HiltViewModel / hiltViewModel()). This reference covers the traps and boundaries, not the Classic DSL basics (single / factory / scoped / viewModel { } with get() resolution and runtime params, koinViewModel / koinInject, startKoin { androidLogger(); androidContext(this@MyApp); modules(...) }). Related: android-skills:kmp-ktor, android-skills:android-data-layer. Deps via koin-bom: koin-core, koin-android, koin-androidx-compose, koin-compose-viewmodel (KMP), koin-compose-navigation3 (Nav 3), koin-test, + optional koin-annotations / koin-ksp-compiler.
@Module @ComponentScan discovers annotated classes and emits a module you pass to startKoin as UserModule().module — the generated .module extension on the annotated class is the part most often missed. Pick one style per module (don't mix Classic DSL + annotations inside a single module; switching between modules is fine).
@Single class UserRepositoryImpl(private val service: UserService) : UserRepository
@Factory class UserFormValidator
@KoinViewModel class UserDetailViewModel(
@InjectedParam private val userId: String,
private val repository: UserRepository,
) : ViewModel()
@Module @ComponentScan("com.example.feature.user") class UserModule
// startKoin { modules(UserModule().module) }
Most bindings live in commonMain; platform-typed ones (HTTP engine, Context, Keychain) go behind expect val platformModule: Module with an actual per platform (mirrors android-skills:kmp-ktor's engine pattern). iOS startup: call InitKoinKt.doInitKoin(config: nil) from iOSApp.init() — Swift reserves init, hence the do prefix.
// commonMain
expect val platformModule: Module
// androidMain: actual = module { single<HttpClientEngine> { OkHttp.create() }; single<TokenStorage> { DataStoreTokenStorage(get()) } }
// iosMain: actual = module { single<HttpClientEngine> { Darwin.create() }; single<TokenStorage> { KeychainTokenStorage() } }
koinViewModel / koinInject require koin-androidx-compose (Android) or koin-compose-viewmodel (KMP). Without that artifact the call compiles but fails at the call site — koin-core knows nothing about ViewModel or the Compose runtime. For testability, default composable params to koinInject(): fun Screen(service: AnalyticsService = koinInject()).
val vm: UserDetailViewModel = koinViewModel { parametersOf(userId) }
// keyed per entity: koinViewModel(key = "detail_$userId", parameters = { parametersOf(userId) })
Survives configuration changes (the common case) → activityRetainedScope — backed by the Activity's retained ViewModel, so it lives across rotation and closes on real finish. Declare with activityRetainedScope { } (or @ActivityRetainedScope) and access via AndroidScopeComponent; do not hand-roll createScope / close for this case.
val checkoutModule = module {
activityRetainedScope { // retained across config changes
scoped { CheckoutCart() }
scoped { CheckoutPricing(get()) }
}
}
class CheckoutActivity : AppCompatActivity(), AndroidScopeComponent {
override val scope: Scope by activityRetainedScope()
private val cart: CheckoutCart by inject()
}
Custom lifetime not tied to an Activity (e.g. a multi-step flow keyed by an order id) → declare a scope<T> and own its lifecycle: getKoin().createScope<CheckoutFlow>("checkout-$orderId"), resolve with scope.get(), and scope.close() when the flow ends.
koinEntryProvider() resolves ViewModels per destination; register destinations inside modules, not inline at the NavDisplay site.
val navigationModule = module {
navigation<HomeRoute> { HomeScreen(viewModel = koinViewModel()) }
navigation<DetailRoute> { route -> DetailScreen(viewModel = koinViewModel { parametersOf(route.id) }) }
}
NavDisplay(backStack = backStack, onBack = { backStack.removeLastOrNull() }, entryProvider = koinEntryProvider())
verify()Walks each declaration's constructor and confirms every dependency is declared — missing bindings become test failures instead of a runtime NoDefinitionFoundException (recovering one of Hilt's advantages). Run it in CI. (checkModules() is deprecated since Koin 4.0.) For constructor params resolved at runtime (e.g. SavedStateHandle), pass extraTypes or verify() false-fails. Override real bindings with fakes (e.g. Ktor MockEngine — see android-skills:kmp-ktor). KoinTestRule (JUnit 4) / KoinTestExtension (JUnit 5) installs a context per test.
class ModuleVerificationTest : KoinTest {
@Test fun `all modules resolve cleanly`() {
// verify() sees a module plus the modules it includes — verify the root, not each module alone,
// or a binding provided by a sibling module reports as missing
module { includes(appModule, networkModule, featureModule) }
.verify(extraTypes = listOf(SavedStateHandle::class)) // runtime-resolved types
}
}
What SKILL.md sets; muted values are Claude Code's defaults
21 skills in this plugin
/android-data-layerUse when implementing the data layer in Android or KMP — the Repository pattern's layered error-propagation model (repository as the error boundary, sealed DataError, Result placement with and without a domain layer) and Room in commonMain (@ConstructedBy, BundledSQLiteDriver, per-target KSP)./android-debuggingUse when debugging Android or KMP issues — crashes, ANRs, performance regressions, obfuscated release stack traces, wrong on-screen UI state, or a bad value crossing several layers.
/android-devUse this skill as the baseline for ALL Android and Kotlin Multiplatform (KMP) work — whenever the user mentions Android, Kotlin (in an Android context), KMP, CMP, commonMain, androidMain, iosMain, AndroidManifest, Gradle, build.gradle, Hilt, Dagger, Room, Retrofit, Ktor, ViewModel, LiveData, StateFlow, SharedFlow, Compose, Activity, Fragment, Intent, ADB, Logcat, MVVM, MVI, repository pattern, or any Android SDK / Jetpack / AndroidX API. Always load this skill alongside the more specific skills (android-skills:compose, android-skills:kotlin-flows, android-skills:kmp-ktor, android-skills:android-retrofit, etc.): it routes to them and adds the few baseline rules that are easy to get wrong. Casual mentions like "fix this bug in my Android app," "refactor this ViewModel," "my KMP project," or any work inside an Android project directory should trigger this skill.
/android-gradle-logicUse when setting up or refactoring Android Gradle build logic — convention plugins, composite builds, version catalogs, and shared build configuration across modules./android-retrofitUse when setting up or working with Retrofit in Android — service interface definitions, coroutines integration, OkHttp configuration, Hilt module setup, and error handling in the repository layer./android-source-searchUse when needing to fetch Android source code — AOSP platform internals (@hide APIs, framework classes, system services) or AndroidX/Jetpack library source and samples. Also use when public docs are insufficient to complete a task and implementation details must be read directly from source.npx claudepluginhub rcosteira79/android-skills --plugin android-skillsOther plugins' skills for the same job