kotlin-multiplatform

Guide Kotlin Multiplatform architecture decisions for expect/actual patterns and source sets.

Updated Feb 26, 2026
One-click install
npx skills add https://github.com/felipebrgs1/skills --skill kotlin-multiplatform-felipebrgs1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-multiplatform
Source: https://github.com/felipebrgs1/skills/tree/main/mobile/kotlin-multiplatform
Command: npx skills add https://github.com/felipebrgs1/skills --skill kotlin-multiplatform-felipebrgs1

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides expert guidance on making platform abstraction decisions in Kotlin Multiplatform (KMP) projects, ensuring efficient code sharing, correct source set placement, and effective use of expect/actual patterns.

Core Features & Use Cases

  • Abstraction Decision Tree: Guides you on when to abstract code versus keeping it platform-specific.
  • Source Set Guidance: Explains the mental model of source sets and the purpose of commonMain, jvmAndroid, androidMain, jvmMain, and iosMain.
  • expect/actual Mechanics: Details how to implement platform-dependent code using expect and actual declarations.
  • Target-Specific Advice: Covers current targets (Android, JVM, iOS) and future considerations (Web/Wasm).
  • Integration with Other Skills: Guides when to invoke gradle-expert for dependency issues.
  • Use Case: You're unsure if a piece of business logic should go into commonMain or if a UI component needs platform-specific implementation. This Skill provides a clear decision-making process and examples.

Quick Start

Use the kotlin-multiplatform skill to decide where to place a new feature module in your KMP project.

Frequently Asked Questions about kotlin-multiplatform

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

FAQPage Schema
How do I decide whether to put business logic in commonMain or keep it platform-specific in Kotlin Multiplatform?

Use an abstraction decision tree to evaluate whether business logic belongs in commonMain or requires platform-specific implementation in Kotlin Multiplatform. This Skill guides you through analyzing code dependencies and platform constraints to ensure efficient code sharing and maintainability.

How does the expect actual pattern work for sharing code across iOS and Android in KMP?

The expect/actual pattern in KMP allows you to declare expected platform-dependent contracts in commonMain and provide actual implementations in platform-specific source sets like iosMain and androidMain. This Skill details the mechanics for integrating platform-specific code safely.

What is the purpose of intermediate source sets like jvmAndroid in a Kotlin Multiplatform project?

Intermediate source sets like jvmAndroid in Kotlin Multiplatform allow you to share code specifically between the JVM and Android targets before splitting into androidMain and jvmMain. This Skill explains the mental model of source set organization for optimal cross-platform compatibility.

Can I use Kotlin Multiplatform to share code for future Web and Wasm targets alongside iOS and Android?

Yes, Kotlin Multiplatform supports sharing code across Android, JVM, iOS, and includes future considerations for Web and Wasm targets. This Skill provides target-specific advice for managing cross-platform compatibility and source set placement for these expanding environments.

When should I not abstract code and instead keep it isolated in androidMain or iosMain?

You should avoid abstracting code in KMP when platform constraints make sharing inefficient or when UI components require strictly platform-specific implementations. This Skill provides a clear decision-making process to determine when keeping code isolated is better for project maintainability.