skillfed

kotlin-multiplatform

Kotlin Multiplatform lets you write business logic once and deploy it across Android, iOS, web, and desktop targets. This skill helps you evaluate the trade-offs between code sharing and platform-specific optimization, ensuring your architecture decisions align with your project's performance and maintenance goals.

Kotlin Multiplatform helps you decide by weighing code reuse against platform-specific optimization needs. Share business logic, serialization, and domain models in commonMain when the logic is truly platform-agnostic. Keep platform-specific code (UI, native APIs, performance-critical paths) in androidMain, iosMain, or jvmMain. The kotlin-multiplatform skill guides you through this trade-off analysis to avoid leaky abstractions while maximizing shared code.

AI-generated summary based on this skill's SKILL.md

1,565 212 MIT updated by vitorpamplona

Install

vitorpamplona/amethyst/kotlin-multiplatform · repository language: Kotlin

CLI (skillfed)coming soon
git clone https://github.com/vitorpamplona/amethyst
cp -r amethyst/.claude/skills/kotlin-multiplatform ~/.claude/skills/kotlin-multiplatform

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

Should I share this code across Android, iOS and desktop?

Kotlin Multiplatform helps you decide by weighing code reuse against platform-specific optimization needs. Share business logic, serialization, and domain models in commonMain when the logic is truly platform-agnostic. Keep platform-specific code (UI, native APIs, performance-critical paths) in androidMain, iosMain, or jvmMain. The kotlin-multiplatform skill guides you through this trade-off analysis to avoid leaky abstractions while maximizing shared code.

Where do I put my code: commonMain, androidMain, or iosMain?

Kotlin Multiplatform uses a source set hierarchy to organize code by platform scope. Place truly cross-platform logic in commonMain. Use androidMain and iosMain for platform-specific implementations. For JVM-only libraries shared between Android and desktop, use the jvmAndroid source set to avoid duplication. The kotlin-multiplatform skill teaches you to evaluate each module's dependencies and constraints to choose the right placement.

What are expect/actual patterns and best practices?

Kotlin Multiplatform's expect/actual mechanism lets you define an interface in commonMain and provide platform-specific implementations in androidMain, iosMain, or other targets. Use expect/actual for crypto, file I/O, or native APIs that vary by platform. Best practices include keeping expect declarations minimal, avoiding leaky abstractions, and testing each actual implementation. The kotlin-multiplatform skill covers real-world examples like serialization and platform abstraction.

When should I use the jvmAndroid source set?

The jvmAndroid source set eliminates duplication when a library (like Jackson for serialization) runs on both JVM and Android but not on iOS or web. Kotlin Multiplatform's jvmAndroid pattern lets you write the code once instead of repeating it in androidMain and jvmMain. This skill explains when jvmAndroid is appropriate and how it fits into your overall architecture without creating brittle dependencies.

How do I structure a Kotlin Multiplatform project?

Kotlin Multiplatform projects organize code into a hierarchy: commonMain for shared logic, intermediate source sets (jvmAndroid) for platform pairs, and leaf source sets (androidMain, iosMain, jvmMain) for platform-specific code. The kotlin-multiplatform skill teaches you to design this hierarchy to maximize reuse, minimize maintenance burden, and future-proof your architecture for web and wasm targets as your project grows.

How do I avoid code duplication and leaky abstractions in KMP?

Kotlin Multiplatform reduces duplication by sharing business logic, but poor abstraction design creates leaky abstractions that force platform-specific workarounds. The kotlin-multiplatform skill helps you identify which code genuinely belongs in commonMain versus what should stay platform-specific. Use expect/actual for true platform variations, not as a workaround for incomplete abstractions. This approach keeps your codebase maintainable as you add web and wasm targets.

SKILL.md

rendered from the published skill — quoted content, verbatim

Kotlin Multiplatform: Platform Abstraction Decisions

Expert guidance for KMP architecture in Amethyst - deciding what to share vs keep platform-specific.

When to Use This Skill

Making platform abstraction decisions: - "Should I create expect/actual or keep Android-only?" - "Can I share this ViewModel logic?" - "Where does this crypto/JSON/network implementation belong?" - "This uses Android Context - can it be abstracted?" - "Is this code in the wrong module?" - Preparing for iOS/web/wasm targets - Detecting incorrect placements

Abstraction Decision

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 7 files
.claude/skills/kotlin-multiplatform/SKILL.md
.claude/skills/kotlin-multiplatform/references/abstraction-examples.md
.claude/skills/kotlin-multiplatform/references/expect-actual-catalog.md
.claude/skills/kotlin-multiplatform/references/source-set-hierarchy.md
.claude/skills/kotlin-multiplatform/references/target-compatibility.md
.claude/skills/kotlin-multiplatform/scripts/suggest-kmp-dependency.sh
.claude/skills/kotlin-multiplatform/scripts/validate-kmp-structure.sh

Related skills

Tags

architecture-patterns code-sharing-strategy platform-abstraction source-set-organization cross-platform-design expect-actual-mechanics jvm-layer-pattern multiplatform-libraries future-target-readiness abstraction-boundaries