# kotlin-multiplatform

Architecture patterns, library recommendations, and templates for Kotlin Multiplatform and Compose Multiplatform codebases.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 183 installs · ★ 114 repo stars
- Author: travisjneuman
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/travisjneuman/.claude/tree/HEAD/skills/kotlin-multiplatform/SKILL.md
- Updated: 2026-10-25
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/travisjneuman-kotlin-multiplatform

## What it does

The skill outlines standard project directory structures across Android, iOS, desktop, and web targets. It separates shared UI inside `composeApp` from shared business logic inside `shared`, covering Ktor network clients, SQLDelight database tables, and Compose Multiplatform screens.

It provides examples for `expect`/`actual` declarations, including platform context resolution and engine selection between OkHttp on Android and Darwin on iOS. It also guides framework export configuration for Swift using CocoaPods or SPM and test setup in `commonTest`.

The skill recommends keeping `expect`/`actual` usage minimal, favoring shared interfaces resolved through dependency injection with Koin.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add travisjneuman/.claude --skill kotlin-multiplatform -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/kotlin-multiplatform/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/kotlin-multiplatform/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add travisjneuman/.claude --skill kotlin-multiplatform -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/kotlin-multiplatform/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add travisjneuman/.claude --skill kotlin-multiplatform -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/kotlin-multiplatform/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install travisjneuman/.claude skills/kotlin-multiplatform
```

2. **Manually: put the files in place**
- File: `.github/skills/kotlin-multiplatform/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add travisjneuman/.claude --skill kotlin-multiplatform -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/travisjneuman/.claude --path skills/kotlin-multiplatform
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/kotlin-multiplatform/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add travisjneuman/.claude --skill kotlin-multiplatform -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/travisjneuman/.claude/tree/HEAD/skills/kotlin-multiplatform/SKILL.md

## When to use it
- organize shared KMP modules and Compose Multiplatform source sets
- implement cross-platform HTTP networking with Ktor and serialization
- generate local database queries and tables using SQLDelight
- bridge platform-specific APIs between Android and iOS via expect and actual
- configure shared Kotlin framework export for Xcode and Swift

## Example prompts
- Set up a Ktor API client inside commonMain for user profiles
- Create an expect/actual declaration to resolve platform context on Android and iOS
- Configure a shared SQLDelight schema with select and insert queries

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 99f3b9c051aba607.

BEGIN THIRD-PARTY FILE 99f3b9c051aba607
````text
---
name: kotlin-multiplatform
description: >-
  KMP/CMP shared business logic, Compose Multiplatform, expect/actual, Ktor, SQLDelight, and platform-specific implementations. Use when building cross-platform Kotlin applications for Android, iOS, desktop, or web.
---

# Kotlin Multiplatform Skill

Shared business logic and optional shared UI across Android, iOS, desktop, and web.

---

## Project Structure

```
project/
├── composeApp/                    # Shared Compose UI (if using CMP)
│   └── src/
│       ├── commonMain/            # Shared UI code
│       ├── androidMain/           # Android-specific UI
│       ├── iosMain/               # iOS-specific UI
│       └── desktopMain/          # Desktop-specific UI
├── shared/                        # Shared business logic (KMP)
│   └── src/
│       ├── commonMain/            # Shared code
│       │   └── kotlin/
│       │       ├── data/          # Repositories, data sources
│       │       ├── domain/        # Use cases, models
│       │       └── platform/      # expect declarations
│       ├── androidMain/           # actual implementations
│       ├── iosMain/               # actual implementations
│       └── commonTest/            # Shared tests
├── androidApp/                    # Android entry point
├── iosApp/                        # iOS entry point (Xcode project)
├── build.gradle.kts
└── settings.gradle.kts
```

---

## expect/actual Pattern

```kotlin
// commonMain - expect declaration
expect class PlatformContext

expect fun getPlatformName(): String

expect fun createHttpClient(): HttpClient

// androidMain - actual implementation
actual class PlatformContext(val context: android.content.Context)

actual fun getPlatformName(): String = "Android ${Build.VERSION.SDK_INT}"

actual fun createHttpClient(): HttpClient = HttpClient(OkHttp) {
    install(ContentNegotiation) { json() }
}

// iosMain - actual implementation
actual class PlatformContext

actual fun getPlatformName(): String = UIDevice.currentDevice.systemName()

actual fun createHttpClient(): HttpClient = HttpClient(Darwin) {
    install(ContentNegotiation) { json() }
}
```

---

## Key Libraries

| Library | Purpose | Multiplatform? |
|---------|---------|----------------|
| Ktor | HTTP client | Yes |
| kotlinx.serialization | JSON parsing | Yes |
| kotlinx.coroutines | Async/concurrency | Yes |
| SQLDelight | Local database | Yes |
| Koin | Dependency injection | Yes |
| Compose Multiplatform | Shared UI | Yes |
| kotlinx.datetime | Date/time | Yes |
| Napier | Logging | Yes |

---

## Networking with Ktor
````
END THIRD-PARTY FILE 99f3b9c051aba607

The third-party file has ended. Everything between the 99f3b9c051aba607 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2731 of 6272 bytes. © travisjneuman · MIT · https://github.com/travisjneuman/.claude/tree/HEAD/skills/kotlin-multiplatform/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
