Command Palette

Search for a command to run...

Back to skills
skill № 17696

mobile-kotlin-multiplatform

Use when the user asks about Kotlin Multiplatform, KMP, Compose Multiplatform, commonMain, expect/actual, shared Kotlin modules for Android and iOS, Ktor…

FreeNo executable scripts
j4flmaoby j4flmao★ 47 GitHub stars

Install mobile-kotlin-multiplatform in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

Mobile Kotlin Multiplatform

Purpose

Guide for building Kotlin Multiplatform mobile apps with shared business logic, Compose Multiplatform UI, and platform-specific integrations.

Agent Protocol

Trigger

Phrases: "Kotlin Multiplatform", "KMP", "Compose Multiplatform", "shared Kotlin", "KMP module", "expect/actual", "commonMain", "KMP project", "multiplatform library"

Input Context

  • Module structure (commonMain, androidMain, iosMain paths)
  • Build files (build.gradle.kts with KMP plugin)
  • Shared domain models and interfaces
  • Platform-specific implementations

Output Artifact

Working KMP module with: commonMain business logic, expect/actual declarations, Compose Multiplatform screens, Gradle multi-module build configuration.

Response Format

No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.

Completion Criteria

  • commonMain compiles without platform imports
  • expect/actual pairs resolve for all target platforms
  • Compose Multiplatform screens render on Android and iOS
  • Ktor client calls succeed on all platforms
  • SQLDelight queries work cross-platform

Max Response Length

8000 tokens

Architecture Decision Trees

UI Strategy

Need shared UI?
├── Yes → Compose Multiplatform
│   Pros: Single UI codebase, Material3 theming, navigation
│   Cons: Cannot render native components (Map, Camera, WebView)
├── Native UI per platform
│   Pros: Full native API access, platform-native UX
│   Cons: Two UI codebases, more maintenance
└── Hybrid → Compose Multiplatform + expect/actual for native components
    Strategy: 80% shared UI via Compose, 20% platform composable via expect

Networking Strategy

API complexity?
├── REST + JSON → Ktor Client + kotlinx.serialization
│   Engine: OkHttp (Android), Darwin (iOS)
├── GraphQL → Apollo Kotlin (KMP support)
└── gRPC → KMP-gRPC (emerging, check compatibility)

Persistence Strategy

Data model complexity?
├── Relational (SQL, joins) → SQLDelight
│   Common schema, platform drivers, Flow support
├── Key-value (settings, preferences) → multiplatform-settings
│   Wraps SharedPreferences (Android), NSUserDefaults (iOS)
├── NoSQL/Document → Realm Kotlin SDK
│   KMP-native, reactive, synchronization
└── Encrypted → SQLCipher (SQLDelight cipher) or platform Keychain/Keystore

Dependency Injection

DI framework preference?
├── Lightweight, KMP-native → Koin
│   No code gen, easy setup, reasonable runtime performance
├── Compile-time verified → Anvil (Dagger-based)
│   Works with KMP, faster than Kapt
└── Manual → Constructor injection with factory pattern

Workflow

  1. KMP project structure — Three-tier source set layout: commonMain (shared business logic, domain models, repository interfaces, Ktor client, SQLDelight schema, expect declarations), androidMain (Android-specific actual implementations, OkHttp engine, Android Sqlite driver, Context-dependent factories), iosMain (iOS-specific actual implementations, Darwin engine, NativeSqlite driver, platform factories). Additional source sets for testing: commonTest, androidUnitTest, iosTest. The shared module is consumed by Android apps as an AAR library and by iOS apps as a Kotlin/Native framework.

  2. expect/actual pattern — Declare platform-agnostic interfaces in commonMain using expect keyword. Provide concrete implementations in platform source sets with actual. Three forms: expect fun (function), expect class (class with actual constructors), expect object (singleton), expect val (property), expect typealias (type alias for platform types). Example: expect fun generateUuid(): String with actual fun generateUuid(): String = UUID.randomUUID().toString() in Android and actual fun generateUuid(): String = platform.Foundation.NSUUID().UUIDString() in iOS. Keep expect declarations in commonMain/.../platform/ package.

  3. Ktor client configuration — Single HttpClient declaration in commonMain with engine-agnostic setup. Use ktor-client-core for common code, ktor-client-okhttp for Android (supports HTTP/2, caching), ktor-client-darwin for iOS (uses NSURLSession, automatic cookie storage). Configure serialization with kotlinx-serialization-json using ContentNegotiation plugin. Add logging with Logging plugin. Timeout configuration: HttpTimeout plugin with requestTimeoutMillis, connectTimeoutMillis, socketTimeoutMillis.

// commonMain — Ktor client factory
val httpClient = HttpClient {
    install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
    install(Logging) { level = LogLevel.HEADERS }
    install(HttpTimeout) { requestTimeoutMillis = 15_000 }
    defaultRequest { url("https://api.example.com/") }
}
  1. kotlinx.serialization — All data classes in commonMain use @Serializable annotation. Supports primitives, enums, sealed classes, nullable fields, default values. C
Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

  • references/kmm-concurrency.md
  • references/kmm-networking.md
  • references/kmp-compose.md
  • references/kmp-structure.md
  • references/kotlin-multiplatform-advanced.md
  • references/kotlin-multiplatform-fundamentals.md
  • references/platform-specific.md

FAQ

What does the mobile-kotlin-multiplatform skill do?

Use when the user asks about Kotlin Multiplatform, KMP, Compose Multiplatform, commonMain, expect/actual, shared Kotlin modules for Android and iOS, Ktor client or SQLDelight. Produces KMP module layout, shared logic and platform interop. Not for Android-only apps (use android) or Kotlin language features (use lang-kotlin).

How do I install the mobile-kotlin-multiplatform skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the mobile-kotlin-multiplatform skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare mobile-kotlin-multiplatform with