kotlin-multiplatform-expect-actual

Designs Kotlin Multiplatform expect/actual and interface boundaries for platform services and shared Compose UI.

1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill kotlin-multiplatform-expect-actual-citytexi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kotlin-multiplatform-expect-actual
Source: https://github.com/citytexi/team-yg-pesonal-agent/tree/main/.claude/skills/kotlin-multiplatform-expect-actual
Command: npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill kotlin-multiplatform-expect-actual-citytexi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Kotlin Multiplatform projects often leak Android or iOS types into commonMain, making shared code untestable and forcing changes across platforms when adding a new target. This Skill guides you to keep common APIs semantic and push platform mechanics behind small expect/actual declarations or interfaces. ## Core Features & Use Cases - Boundary Selection: Decision table for choosing between expect/actual declarations, common interfaces with platform bindings, or leaf composables based on whether you need fakes, DI, or lifecycle ownership. - Semantic API Design: Rules and code examples for keeping commonMain signatures free of platform types like Context, Activity, Uri, or UIViewController. - Compose Multiplatform Guidance: Patterns for platform leaf composables, Modifier passing, interop containers (AndroidView, UIKitView), and effect handling in actuals. - Use Case: You need to add a share sheet that works on Android and iOS. The Skill directs you to define a common ShareSheet interface, bind an Activity-owned Android implementation, and keep common callers unaware of platform details. ## Quick Start Ask the AI to design a Kotlin Multiplatform boundary for a platform capability such as clipboard access, haptics, or sharing, keeping commonMain free of platform types.

Frequently Asked Questions about kotlin-multiplatform-expect-actual

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

FAQPage Schema
How do I use expect/actual in Kotlin Multiplatform?▼

Declare a semantic expect function, value, or class in commonMain and provide platform-specific actual implementations in androidMain and iosMain. Keep the common signature free of platform types like Context or UIViewController so callers describe intent, not platform mechanics.

When should I use an interface instead of expect/actual in KMP?▼

Use a common interface with platform bindings when the implementation needs injected dependencies, lifecycle ownership, runtime selection, or test fakes. Reserve expect/actual for simple compile-time platform specialization without those requirements.

How do I handle platform-specific UI in Compose Multiplatform?▼

Keep platform-specific composables at leaf nodes, pass Modifier through expected composables, and hide native view lifecycle inside the platform actual using interop containers like AndroidView or UIKitView. Never put platform types in commonMain composable signatures.

Can commonMain code reference Android Context or Activity?▼

No, commonMain signatures must reject platform types such as Context, Activity, Uri, Bundle, or UIViewController. If an operation needs an Activity or lifecycle owner, define a common interface and supply the implementation from platform code instead of an expect class.

Why does my KMP change break other platform targets?▼

Changes often break other targets when actuals are updated for only one platform or common signatures leak platform vocabulary. Compile every affected source set after each change and keep business branching in common code so actuals stay thin translation layers.