home / skills / shotaiuchi / dotclaude / context-kmp

context-kmp skill

/dotclaude/skills/context-kmp

This skill assists Kotlin Multiplatform development tasks by guiding shared module creation, expect/actual usage, and Koin/SQLDelight/Ktor setup.

npx playbooks add skill shotaiuchi/dotclaude --skill context-kmp

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.5 KB
---
name: context-kmp
description: >-
  Kotlin Multiplatform development context. Apply when working with
  shared/ or commonMain/, expect/actual declarations, .kt files in
  multiplatform modules, Koin, SQLDelight, Ktor, Compose Multiplatform.
user-invocable: false
---

# Kotlin Multiplatform Context Rule

Auto-applied context when working on KMP development tasks.

## When to Apply

Apply this context when:
- Creating shared modules in KMP
- Using expect/actual declarations
- Setting up Koin, SQLDelight, or Ktor
- Implementing Compose Multiplatform UI

## Reference Documents

Read and apply patterns from:

| Document | Purpose |
|----------|---------|
| [Clean Architecture](../../references/common/clean-architecture.md) | Layer separation principles |
| [Testing Strategy](../../references/common/testing-strategy.md) | Test patterns and coverage |
| [Kotlin Conventions](../../references/languages/kotlin/conventions.md) | Naming, structure, idioms |
| [Library Patterns](../../references/languages/kotlin/library-patterns.md) | Koin, SQLDelight, Ktor usage |
| [Feature Patterns](../../references/languages/kotlin/feature-patterns.md) | Feature module structure |
| [KMP Architecture](../../references/languages/kotlin/kmp-architecture-patterns.md) | Multiplatform patterns |

## External References

| Resource | URL |
|----------|-----|
| Kotlin Multiplatform | https://kotlinlang.org/docs/multiplatform.html |
| Compose Multiplatform | https://www.jetbrains.com/lp/compose-multiplatform/ |
| Kotlin Coroutines | https://kotlinlang.org/docs/coroutines-overview.html |

Overview

This skill provides a focused Kotlin Multiplatform (KMP) development context to apply when working on shared modules, expect/actual declarations, and multiplatform UI. It guides usage patterns for common KMP libraries like Koin, SQLDelight, Ktor, and Compose Multiplatform. Use it to keep architecture, testing, and Kotlin conventions consistent across targets.

How this skill works

When enabled, the skill inspects project layout for shared/, commonMain/, and .kt files inside multiplatform modules and assumes expect/actual patterns are in play. It recommends layered architecture, dependency injection setup, multiplatform database and network patterns, and Compose Multiplatform UI approaches. It references established conventions and testing strategies to produce code and suggestions that fit KMP best practices.

When to use it

  • Creating or refactoring shared/ or commonMain/ modules
  • Designing or implementing expect/actual APIs across targets
  • Setting up or integrating Koin, SQLDelight, or Ktor in a multiplatform module
  • Building Compose Multiplatform screens and reusable UI components
  • Writing tests that target commonMain or multiple platforms

Best practices

  • Keep platform-specific code minimal and behind expect/actual boundaries
  • Follow clean architecture layers: domain, data, and presentation in shared code
  • Configure Koin modules in commonMain where possible and provide platform modules via actual
  • Use SQLDelight with multiplatform drivers and abstract database APIs in commonMain
  • Prefer suspend coroutines in shared APIs and expose Flow/SharedFlow for streams
  • Write tests for common behavior in commonTest and platform-specific tests separately

Example use cases

  • Create an expect interface for file I/O and implement actuals for Android and iOS
  • Set up a shared Ktor HttpClient with platform-specific engines via expect/actual
  • Define a shared SQLDelight database schema and provide platform drivers in actual modules
  • Register shared use-cases and repositories in a Koin module declared in commonMain
  • Build cross-platform UI components with Compose Multiplatform and share business logic

FAQ

When should I use expect/actual versus platform-specific modules?

Use expect/actual when behavior must differ by platform but share an API; use platform modules when entire implementations and dependencies are large or platform-only.

Where should dependency injection configuration live?

Declare DI bindings for shared abstractions in commonMain and provide platform-specific bindings (drivers, clients) via actual implementations or platform modules.