kmp-dependency-injection

Configures Koin dependency injection modules for Kotlin Multiplatform apps and features.

2|Updated Jun 6, 2026
One-click install
npx skills add https://github.com/ronjunevaldoz/kmp-agent-skills --skill kmp-dependency-injection-ronjunevaldoz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kmp-dependency-injection
Source: https://github.com/ronjunevaldoz/kmp-agent-skills/tree/main/skills/kmp-dependency-injection
Command: npx skills add https://github.com/ronjunevaldoz/kmp-agent-skills --skill kmp-dependency-injection-ronjunevaldoz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Wiring dependencies in a Kotlin Multiplatform project involves repeated decisions about Koin module organization, manual versus annotated bindings, scoping, and test overrides, and mistakes often hide architecture problems or fail only at runtime. ## Core Features & Use Cases - Manual and annotated Koin modes: Recommends manual modules with constructor injection as the default, with annotated mode via the Koin compiler plugin when less wiring is preferred. - Scope and lifecycle guidance: Covers app, feature, screen, platform, and session scopes, including named scopes created on login and closed on logout. - ViewModel and SavedStateHandle wiring: Shows viewModelOf bindings with automatic SavedStateHandle resolution from CreationExtras for back-stack results and navigation arguments. - Use Case: When adding a new auth feature to a KMP app, use this Skill to create data, domain, and UI Koin modules, register them in the existing startKoin call, and set up fake bindings for tests. ## Quick Start Ask the agent to wire Koin dependency injection for a new feature module in your KMP project using manual modules and constructor injection.

Frequently Asked Questions about kmp-dependency-injection

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

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

Add Koin 4.x entries to gradle/libs.versions.toml, define manual modules with constructor injection per layer, and call startKoin once from the app or platform bootstrap. Feature modules split into data, domain, and UI bindings.

Should I use manual Koin modules or annotated mode?▼

Manual modules with constructor injection are the recommended default because the dependency graph stays visible and tests are easier to override. Use annotated mode only when bindings are straightforward and the team accepts the compiler-plugin workflow.

How do I inject SavedStateHandle into a ViewModel with Koin?▼

Declare SavedStateHandle as a constructor parameter and register the ViewModel with viewModelOf(::MyViewModel). Koin's ViewModelFactory resolves it automatically from CreationExtras, so never construct SavedStateHandle manually.

Why does my Koin setup fail on Kotlin/Wasm with IrLinkageError?▼

A version mismatch between koin-compose-viewmodel and androidx.lifecycle.viewmodelCompose can stay hidden on JVM, Android, and iOS but fail on Wasm as an IrLinkageError. Keep the pair aligned and include Wasm in verification.

How do I handle dependencies that only exist while a user is logged in?▼

Use a named Koin scope created on login and closed on logout, with scoped bindings for objects like authenticated API clients. Never use single bindings for session-lifecycle objects, since they hold stale state after logout.

Can Kotlin context parameters replace Koin for dependency injection?▼

No. Context parameters thread cross-cutting values like loggers implicitly through call chains but have no scoping or lifecycle model. Keep using Koin to construct and manage the object graph.