koin

Configure Koin dependency injection for Android and Kotlin Multiplatform projects.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill koin-w0lzard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: koin
Source: https://github.com/w0lzard/Wolzard-s-Marketplace/tree/main/plugins/personal-skills/skills/koin
Command: npx skills add https://github.com/w0lzard/Wolzard-s-Marketplace --skill koin-w0lzard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up dependency injection in Android and Kotlin Multiplatform projects involves many decisions — DSL vs KSP annotations, module organization across source sets, ViewModel wiring in Compose, and catching missing bindings before runtime. This Skill provides concrete, tested patterns for each of these so the DI graph is correct and verifiable. ## Core Features & Use Cases - Module Declarations: Declare bindings with the Classic DSL (single, factory, scoped, viewModel) or KSP annotations (@Single, @KoinViewModel, @ComponentScan), with guidance on when to use each lifecycle. - KMP Source Set Layout: Structure shared modules in commonMain with expect/actual platform modules for engines, storage, and platform-typed bindings. - Compose & Navigation Integration: Inject ViewModels with koinViewModel and parametersOf, wire Nav 3 destinations via koinEntryProvider(), and manage flow-scoped state with scopes. - Compile-Time-Style Verification: Use verify() and checkModules() in tests to catch missing bindings as test failures instead of runtime NoDefinitionFoundException. - Use Case: When adding a new feature module to a KMP app, ask for the Koin module, platform bindings, Compose ViewModel injection, and a verification test — all following the patterns in this Skill. ## Quick Start Set up Koin dependency injection for my Android and KMP project, including the app module, Compose ViewModel injection, and a module verification test.

Frequently Asked Questions about koin

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Koin in a Kotlin Multiplatform project?

Declare shared bindings in commonMain modules and put platform-typed bindings behind an expect val platformModule with actual implementations in androidMain and iosMain. Call startKoin from the Android Application class and an initKoin function from Swift on iOS.

Koin vs Hilt: which DI framework for Android?

Koin runs in commonMain so it works for KMP, and verifies the graph via verify() in tests; Hilt is Android-only and validates through codegen with deep Jetpack integration like @HiltViewModel. Both are first-class choices depending on whether you need multiplatform support.

How do I inject a ViewModel with parameters in Compose using Koin?

Use koinViewModel with a parameters lambda: koinViewModel { parametersOf(userId) }, and declare the ViewModel in a module as viewModel { (id: String) -> DetailViewModel(id, get()) }. This requires koin-androidx-compose on Android or koin-compose-viewmodel for KMP.

Why does koinViewModel fail at runtime in my Compose app?

The call compiles but fails at the call site when the Compose integration artifact is missing, because koin-core knows nothing about ViewModel or the Compose runtime. Add koin-androidx-compose on Android or koin-compose-viewmodel for KMP.

How do I verify Koin modules have no missing bindings?

Call checkModules() on a koinApplication with your modules in a test, or verify() per module; missing bindings become test failures instead of runtime NoDefinitionFoundException. For runtime-resolved constructor params like SavedStateHandle, pass them via extraTypes to avoid false failures.

Should I use Koin Classic DSL or KSP annotations?

Pick one style per module — mixing both inside a single module forces reviewers to trace bindings across two systems, though switching styles between modules is fine. The Classic DSL needs no annotation processor, while KSP annotations generate modules from @Single, @Factory, and @KoinViewModel classes.