agentleFS
prasad-vennamprasad-vennam/Awesome-Android-AI-Agent-Skills/skills/android-kmp-shared/SKILL.md

android-kmp-shared

Skill11 starsChanged 8 months agoMITView on GitHub

Use when building Kotlin Multiplatform (KMP) shared modules, integrating with iOS, or sharing business logic across platforms.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use ContentNegotiation and Serialization for shared DTOs.

    line 38
  2. Distinctive:

    Use for consistent date/time logic without platform-specific issues (java.time vs NSDate).

    line 48
  3. Distinctive:

    Use for platform-specific APIs when no shared library exists.

    line 52
  4. Very specific:

    Rule: Avoid expect/actual if a shared library is available.

    line 53
  5. Distinctive:

    Good: Use interfaces and DI to provide platform-specific implementations.

    line 55
  6. Very specific:

    Use kotlin.test for standard assertions (assertTrue, assertEquals).

    line 83

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Android Kotlin Multiplatform (KMP) 🌍🤝

Professional patterns for sharing code between Android and iOS using the next-generation Kotlin Multiplatform technology.

⚡ When to Use

  • Shared Business Logic: Centralizing ViewModels, Use Cases, and Domain Models.
  • Data Layer Sharing: Using Ktor (Network) and SQLDelight (Database) across platforms.
  • Modularization: Creating a cross-platform library module.
  • Migration: Moving from 100% native to shared logic.
  • Validation: Building one logic for both apps (e.g., Auth, Calculations).

🏗️ The Multiplatform Architecture

  • commonMain: The heart of the app. Pure Kotlin code shared by all platforms.
  • androidMain: Platform-specific implementation for Android.
  • iosMain: Platform-specific implementation for iOS (via Kotlin/Native).

🛠️ Essential Shared Tools

1. Ktor (Networking)

  • Benefit: Async, multiplatform HTTP client.
  • Use ContentNegotiation and Serialization for shared DTOs.

2. SQLDelight (Local Persistence)

  • Benefit: Type-safe SQL queries that generate Kotlin code.
  • Shared schema, platform-specific drivers (SQLite for Android, Native for iOS).

3. Koin (Dependency Injection)

  • Benefit: Simple and lightweight DI that works across commonMain.

4. kotlinx-datetime

  • Use for consistent date/time logic without platform-specific issues (java.time vs NSDate).

🚀 The expect / actual Pattern

  • Use for platform-specific APIs when no shared library exists.
  • Rule: Avoid expect/actual if a shared library is available.
  • Bad: expect fun getPlatformName(): String
  • Good: Use interfaces and DI to provide platform-specific implementations.

🏁 Shared Logic Workflow

  • ViewModel Sharing: Use multiplatform-viewmodel library for consistent lifecycle mapping.
  • State Management: Use StateFlow in commonMain to expose UI state.
  • iOS Interoperability: Be aware of Swift/Kotlin memory management and @ObjCName for clean iOS APIs.

📦 Gradle Configuration

kotlin {
    androidTarget()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    sourceSets {
        commonMain.dependencies {
            implementation("io.ktor:ktor-client-core:2.3.0")
        }
    }
}

🧪 Testing with KMP

  • Tests in commonTest run on both Android and iOS targets.
  • Use kotlin.test for standard assertions (assertTrue, assertEquals).
  • Mocking: Use libraries like Mockative or KMock for multiplatform mocking.

🔗 Related Resources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.