kotlin-multiplatform

Guide Kotlin Multiplatform source set organization and expect/actual abstraction decisions.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/Zeyden/claude-skills --skill kotlin-multiplatform-zeyden
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-multiplatform
Source: https://github.com/Zeyden/claude-skills/tree/main/skills/kotlin-multiplatform
Command: npx skills add https://github.com/Zeyden/claude-skills --skill kotlin-multiplatform-zeyden

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 and structuring source sets within Kotlin Multiplatform (KMP) projects, ensuring efficient code sharing and maintainability.

Core Features & Use Cases

  • Abstraction Strategy: Guides decisions on what code to abstract using expect/actual versus keeping platform-specific.
  • Source Set Management: Advises on optimal placement of code within commonMain, androidMain, jvmMain, iosMain, and the jvmAndroid intermediate set.
  • Use Case: When deciding whether to abstract a logging utility or a complex UI component, this Skill provides a decision tree and best practices to follow.

Quick Start

Use the kotlin-multiplatform skill to determine if a new feature should be placed in commonMain or a platform-specific source set.

Frequently Asked Questions about kotlin-multiplatform

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

FAQPage Schema
How do I structure source sets in Kotlin Multiplatform for shared code?

Structure Kotlin Multiplatform source sets by placing platform-agnostic code in commonMain and platform-dependent code in androidMain, jvmMain, or iosMain. Use intermediate sets like jvmAndroid to maximize code sharing and maintainability across targets.

When should I use expect actual declarations for platform abstraction in KMP?

Use expect actual declarations in Kotlin Multiplatform when a specific feature requires platform-specific implementations but shares a unified API. This pattern allows commonMain to invoke platform-dependent logic declared in androidMain or iosMain without duplicating the call site.

What is the best way to decide whether code belongs in commonMain or a platform-specific source set?

Decide placement by evaluating dependencies: if the logic relies solely on common Kotlin APIs, place it in commonMain. If it requires native platform APIs or libraries, isolate it in platform-specific source sets like iosMain or androidMain and abstract via expect actual.

Can I use an intermediate source set like jvmAndroid to share code between Android and JVM targets?

Yes, you can use the jvmAndroid intermediate source set to share code that is compatible with both Android and JVM targets. This approach reduces duplication by consolidating shared logic before it branches into androidMain and jvmMain.

How do Kotlin Multiplatform build scripts integrate with source set organization and dependencies?

Kotlin Multiplatform build scripts configure source set hierarchies and manage dependencies for commonMain and platform targets. They define the compilation logic that links expect actual declarations and resolves platform-specific libraries for iosMain and androidMain.