dependency-injection-koin

Configure Koin dependency injection modules for Kotlin Multiplatform projects.

Updated Sep 12, 2026
One-click install
npx skills add https://github.com/Vierco/citoVisionApp --skill dependency-injection-koin-vierco
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dependency-injection-koin
Source: https://github.com/Vierco/citoVisionApp/tree/main/.claude/skills/dependency-injection-koin
Command: npx skills add https://github.com/Vierco/citoVisionApp --skill dependency-injection-koin-vierco

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up dependency injection in Kotlin Multiplatform projects is error-prone: modules end up scattered across layers, ViewModels get registered with the wrong scope, platform-specific bindings leak into commonMain, and missing interface bindings cause runtime failures instead of compile-time errors. This Skill defines a consistent, architecture-aligned way to configure Koin 4.2 across Android, iOS, and Desktop. ## Core Features & Use Cases - Layered module structure: Organizes Koin modules by Clean Architecture layer (application, infrastructure, presentation) inside composition/di, with a single shared initKoin() entry point. - Platform bindings via expect/actual: Declares platformModule as expect/actual so SQLDelight drivers, Ktor engines, Keychain, and Android Context stay out of common code. - Registration rules and anti-patterns: Enforces constructor-reference DSL (singleOf, factoryOf, viewModelOf), explicit interface binding with bind, and graph verification with koin-test checkModules. - Use Case: You add a new Repository, UseCase, and ViewModel to a KMP app. The Skill tells you exactly which module each class goes in, how to bind the implementation to its interface, and how to verify the graph resolves on all platforms before merging. ## Quick Start Ask the AI to register a new Repository, UseCase, and ViewModel with Koin in your Kotlin Multiplatform project following the layered module structure.

Frequently Asked Questions about dependency-injection-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?▼

Define layered modules (applicationModule, infrastructureModule, presentationModule) in commonMain under composition/di, declare an expect val platformModule, and create one initKoin() function that calls startKoin with all modules. Each platform provides its actual platformModule and invokes initKoin from its entry point.

How do I register a ViewModel with Koin in Compose Multiplatform?▼

Register ViewModels exclusively with viewModelOf(::MyViewModel) inside the presentationModule, never with single or factory. Include the koin-compose-viewmodel artifact from the koin-bom to resolve them in Compose screens.

How do I inject platform-specific dependencies like SQLDelight drivers in KMP?▼

Declare expect val platformModule: Module in commonMain and provide actual implementations in androidMain, iosMain, and desktopMain containing the platform bindings, such as AndroidSqliteDriver, NativeSqliteDriver, or Ktor engines like OkHttp and Darwin.

Should I use single, factory, or viewModelOf in Koin?▼

Use singleOf for long-lived shared instances like repositories, HTTP clients, and databases; factoryOf for short-lived stateless objects like use cases; and viewModelOf exclusively for ViewModels. Prefer constructor-reference functions over manual lambdas.

Why does Koin fail at runtime instead of compile time in Kotlin?▼

Runtime failures usually come from forgetting to bind an implementation to its interface with bind, so the concrete type resolves but the interface does not. Verify the graph early with koin-test checkModules() in commonTest to catch missing bindings before merging.

When should I not use Koin Annotations or the Koin Compiler Plugin?▼

Avoid the Koin Compiler Plugin in production while it remains in Release Candidate, since its API is not yet stable. The classic DSL with singleOf, factoryOf, and viewModelOf is the recommended stable baseline for Koin 4.2.