kmp-presenter-module

Sets up a pure Kotlin presenter module with MVI ViewModels and Koin wiring for KMP features.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up a presentation layer in Kotlin Multiplatform often couples ViewModels to Compose or Android, making them untestable on plain JVM and leaking UI dependencies into business logic. This Skill scaffolds a :presenter module with pure Kotlin ViewModels, MVI contracts, and Koin wiring that compiles and tests without an emulator. ## Core Features & Use Cases - MVI Contract Scaffolding: Generates UiState and UiIntent sealed classes plus a ViewModel exposing StateFlow<UiState> with an onIntent dispatcher. - Convention Plugin & Build Setup: Provides a feature.presenter Gradle convention plugin using the KMP androidx.lifecycle.viewmodel artifact with no Compose dependency, plus a jvm() target for CI tests. - Koin Wiring: Supports both annotated mode (@KoinViewModel with the Koin compiler plugin) and manual module { viewModel { ... } } declarations. - Multi-Source State Patterns: Shows combine for merging independent flows, flatMapLatest for dependent flows, and SharingStarted.WhileSubscribed(5_000) for lifecycle-aware sharing. - Use Case: Add a :presenter module to a new auth feature, define AuthUiState/AuthUiIntent, wire AuthViewModel into Koin, and test it with runTest and Turbine on plain JVM. ## Quick Start Ask the agent to set up a presenter module with an MVI ViewModel and Koin wiring for a specific KMP feature such as authentication.

Frequently Asked Questions about kmp-presenter-module

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

FAQPage Schema
How do I make a KMP ViewModel testable on plain JVM?▼

Keep the ViewModel in a dedicated `:presenter` module with no Compose or Android UI dependencies, declare a `jvm()` target, and use the KMP `androidx.lifecycle.viewmodel` artifact. Then test with `runTest` and Turbine in `commonTest` without an emulator.

How do I combine multiple flows into one UiState in a ViewModel?▼

Use `combine` to merge independent flows into a single `StateFlow`, then apply `stateIn` with `SharingStarted.WhileSubscribed(5_000)`. Never nest `collect` inside `collect`, since the inner coroutine leaks and misses updates.

Should I use StateFlow or SharedFlow for ViewModel state?▼

Use `MutableStateFlow` for screen state because it always holds a current value and replays it to new collectors. `SharedFlow` with replay is for one-shot events, not state holders.

Can I share a KMP presenter ViewModel with a native SwiftUI iOS app?▼

Sharing the presenter assumes Compose Multiplatform UI on every target. For genuinely native SwiftUI/UIKit iOS, share only `:domain` and `:data` and write a platform-native presentation layer instead.

Why is viewModelScope not available in my KMP commonMain code?▼

The `viewModelScope` API comes from the KMP `androidx.lifecycle.viewmodel` artifact, not the Compose variant. Ensure that artifact is on the `commonMain` classpath and recheck `libs.versions.toml` for the correct lifecycle version.