home / skills / shotaiuchi / dotclaude / kmp-architecture

kmp-architecture skill

/dotclaude/skills/kmp-architecture

This skill helps you design and apply Kotlin Multiplatform architecture patterns, share modules, and implement expect/actual, Koin, SQLDelight, and Compose

npx playbooks add skill shotaiuchi/dotclaude --skill kmp-architecture

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.4 KB
---
name: Kotlin Multiplatform Architecture
description: This skill should be used when implementing KMP features, creating shared modules, using expect/actual, setting up Koin/SQLDelight/Ktor, or implementing Compose Multiplatform.
references:
  - path: ../../references/common/clean-architecture.md
  - path: ../../references/common/testing-strategy.md
  - path: ../../references/languages/kotlin/conventions.md
  - path: ../../references/languages/kotlin/library-patterns.md
  - path: ../../references/languages/kotlin/feature-patterns.md
  - path: ../../references/languages/kotlin/kmp-architecture-patterns.md
external:
  - id: kmp-docs
  - id: compose-multiplatform
  - id: kotlin-coroutines
---

**Always respond in Japanese.**

# Kotlin Multiplatform Architecture

Multiplatform development patterns based on Kotlin official documentation and Google's KMP recommendations.

Read and apply the patterns from the referenced documents to the user's implementation task.

## Reference Documents

- [Clean Architecture Guide](../../references/common/clean-architecture.md)
- [Testing Strategy Guide](../../references/common/testing-strategy.md)
- [KMP Conventions](../../references/languages/kotlin/conventions.md)
- [Library Patterns](../../references/languages/kotlin/library-patterns.md)
- [Feature Patterns](../../references/languages/kotlin/feature-patterns.md)
- [Architecture Patterns](../../references/languages/kotlin/kmp-architecture-patterns.md)

Overview

This skill helps implement robust Kotlin Multiplatform (KMP) architectures for shared modules, feature boundaries, and platform-specific integration. It focuses on practical patterns for expect/actual separation, dependency wiring, and multi-platform UI with Compose. Use it to align implementations with clean architecture, testing strategy, and KMP conventions.

How this skill works

The skill analyzes your module layout, boundary definitions, and DI/DB/network wiring and recommends concrete patterns: where to place expect/actual types, how to structure shared domain/data/presentation layers, and how to adapt libraries like Koin, SQLDelight, and Ktor. It also produces test strategies and Compose Multiplatform integration steps tailored to your targets and build configuration.

When to use it

  • Creating a new shared module intended for Android, iOS, and desktop
  • Deciding how to model expect/actual APIs for platform-specific behavior
  • Setting up dependency injection and lifecycle integration across targets
  • Configuring SQLDelight schemas and drivers for multiple platforms
  • Integrating Ktor clients and platform-specific engines
  • Implementing Compose Multiplatform UI with shared state and navigation

Best practices

  • Design a minimal, platform-agnostic domain layer; keep expect/actual only for unavoidable platform APIs
  • Use feature modules with clear public contracts and internal implementations per platform
  • Prefer constructor injection and interfaces; provide platform bindings in a single DI entry point
  • Keep SQLDelight schema and migrations in shared code, inject drivers via expect/actual
  • Write unit tests for shared logic and small integration tests per platform using the recommended testing strategy
  • Start Compose Multiplatform with small, stateless components and lift state to shared view models

Example use cases

  • Shared authentication feature: domain logic and token storage in shared module, secure store via expect/actual
  • Offline caching: SQLDelight in shared data layer with platform drivers injected at startup
  • Networking: Ktor interfaces in shared code with platform engine selection via DI
  • DI bootstrapping: single function that registers common modules and platform-specific modules
  • Compose MPP screen: shared UI components and platform-specific window/host setup

FAQ

When should I use expect/actual vs platform libraries in shared code?

Use expect/actual for small, stable abstractions (file I/O, secure storage, platform-specific features). Avoid wrapping large platform SDKs; instead, isolate and expose minimal interfaces.

How do I manage database migrations across targets with SQLDelight?

Keep the schema and migration scripts in shared code. Provide platform-specific SQLDelight drivers via expect/actual and initialize the database through your DI entry point during app startup.