kotlin-multiplatform-expect-actual

Designs Kotlin Multiplatform expect/actual boundaries separating shared code from platform implementations.

1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/leogallego/ansible-jane --skill kotlin-multiplatform-expect-actual-leogallego
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-multiplatform-expect-actual
Source: https://github.com/leogallego/ansible-jane/tree/main/skills/kotlin-multiplatform-expect-actual
Command: npx skills add https://github.com/leogallego/ansible-jane --skill kotlin-multiplatform-expect-actual-leogallego

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kotlin Multiplatform architecture often struggles with enforcing clean boundaries between common and platform-specific code. This Skill provides guidance on designing expect/actual declarations and interfaces to minimize platform leakage and keep shared code stable.

Core Features & Use Cases

  • Define stable common APIs and thin actual bindings to platform implementations.
  • Decide when to use expect/actual, interfaces, or dependency injection to isolate platform specifics.
  • Apply across files, permissions, UI interop, and native SDKs to keep codebase maintainable and testable.

Quick Start

Design a shared boundary for a cross-platform file reader using expect/actual.

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 separate shared code from platform-specific implementations in Kotlin Multiplatform?

Use expect/actual declarations to establish clear Kotlin Multiplatform boundaries, defining semantic common APIs in commonMain and providing thin actual bindings in platform modules to isolate platform details effectively.

When should I use expect/actual versus interfaces for Kotlin Multiplatform architecture?

Use expect/actual for direct compile-time boundaries and interfaces with dependency injection when you need flexible runtime swapping or testability across commonMain and platform-specific modules.

How do I design a cross-platform file reader boundary using expect/actual in Kotlin Multiplatform?

Declare a semantic expect function in commonMain and provide thin actual bindings in platform modules to isolate native file system permissions and native interop details.

Does Kotlin Multiplatform expect/actual work for isolating native SDKs and UI interop?

Yes, expect/actual applies clear boundaries across files, permissions, UI interop, and native SDKs to keep cross-platform code clean, maintainable, and testable.

What are the limitations of using expect/actual declarations in Kotlin Multiplatform?

Expect/actual declarations risk platform leakage if actual bindings are not kept thin, which makes shared code unstable and harder to test if platform-specific details bleed into the commonMain API surface.