dimitriremoiville/cc-mobile/koin-di
Claude Code and agent skill by dimitriremoiville/cc-mobile
- community
Checking that the SKILL.md file is still in the repository.
How Koin is wired up and used in this KMM project — common modules, platform-specific modules, ViewModel binding for both Android and iOS, and testing. Load when adding a new injectable, creating a Koin module, wiring a repository, writing DI-aware tests, or debugging a Koin error.
Install
npx vskill@latest install dimitriremoiville/cc-mobile/koin-diSKILL.md
The same SKILL.md was published earlier as dimitriremoiville/cc-mobile/koin-di.
Koin (KMP-friendly DI)
Koin is the DI framework here because Hilt is Android-only. Koin runs on every Kotlin Multiplatform target and has a clean DSL.
Where modules live
Colocate modules with the code they bind.
Platform-specific modules:
Root initialization
Platform-specific bindings are carried by an expect val platformModule whose actual definitions live under androidMain/ and iosMain/. initKoin always loads both the shared modules and the platform module — no caller-of-initKoin has to remember to pass it.
Each platform's entry point calls initKoin:
- Android: in
Application.onCreate():
``kotlin class App : Application() { override fun onCreate() { super.onCreate() initKoin { androidContext(this@App) } } } ``
- iOS: exposed as a helper function called from Swift:
``kotlin // commonMain fun initKoinForIos() = initKoin() ` Swift calls AppKoinKt.initKoinForIos()` at app launch.
The KoinAppDeclaration block (extra { … }) is the seam for per-platform extras that can't go in platformModule — the most common one is androidContext(this@App) on Android.
Defining bindings
factory { (orderId: OrderId) -> ... } enables koinViewModel { parametersOf(orderId) } on Android.
Qualifiers (named instances)
When you need more than one instance of the same type:
ViewModels
Android uses the koinViewModel() composable (from koin-androidx-compose):
iOS calls a commonMain factory function, or injects directly from the Koin graph via a helper:
…exposed to Swift as AppKoinKt.makeOrderViewModel(id: ...). From Swift, wrap in an @Observable adapter (see kmm-ios-interop skill).
Platform modules
platformModule is expect/actual: one declaration in commonMain, one implementation per target. commonMain code depends on the shared interfaces, never the per-platform types.
Testing
Don't boot Koin for unit tests — just construct the class manually with fakes:
For integration tests that need a full graph, create a test module and call startKoin { modules(testModule) } in @BeforeTest and stopKoin() in @AfterTest.
Common errors and fixes
- `NoBeanDefFoundException` — the type isn't bound. Check the module's registered and the binding's there. For generics, the type must match exactly (
List<Order>≠List<*>). - `KoinAppAlreadyStartedException` — you called
startKointwice. Guard withif (KoinPlatformTools.defaultContext().getOrNull() == null). - ViewModel dependency not found — missing
factory { … }for the VM, or theparametersOf(...)at the call site is missing an argument the factory expects. - Works on Android, fails on iOS (or vice versa) —
platformModule'sactualis missing a binding, or a new shared dependency needs a platform implementation. Check bothandroidMainandiosMainactuals.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/cc-mobile-kmm/skills/koin-di/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dimitriremoiville/cc-mobile/koin-di)