kmp-conventions

Document and enforce Kotlin Multiplatform conventions for mobile codebases.

1|Updated Oct 13, 2024
One-click install
npx skills add https://github.com/cliveportman/way-of-the-goat --skill kmp-conventions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kmp-conventions
Source: https://github.com/cliveportman/way-of-the-goat/tree/main/.claude/skills/kmp-conventions
Command: npx skills add https://github.com/cliveportman/way-of-the-goat --skill kmp-conventions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This reference defines and enforces consistent Kotlin Multiplatform and Compose Multiplatform conventions across the Way of the Goat mobile codebase, reducing ambiguity and onboarding time for developers.

Core Features & Use Cases

  • MVVM + Repository pattern with clear layer responsibilities: UI components (Composables) render state, ViewModels manage actions, Repositories abstract DB/network, and DataManagers cache session data.
  • Source set discipline and naming: avoid platform leaks by keeping common logic in commonMain and platform-specific code in androidMain/iosMain, with proper expect/actual usage.
  • Type-safe identifiers and sealed results: use @JvmInline value classes for IDs and sealed classes for operation results to improve safety and maintainability.
  • Guidance for tests and architecture documentation: be explicit about structure, testing approach, and conventions to ease reviews and onboarding.

Quick Start

Read this guide before writing or reviewing any mobile Kotlin code to ensure adherence to the project conventions.

Frequently Asked Questions about kmp-conventions

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

FAQPage Schema
How do I structure a Kotlin Multiplatform project to avoid platform code leaking into shared logic?

Keep common logic in commonMain and platform-specific code in androidMain or iosMain, using expect/actual declarations to enforce source set discipline and prevent platform leaks in your Kotlin Multiplatform architecture.

What is the best way to manage state and architecture in a Kotlin Multiplatform mobile app?

Use the MVVM and Repository pattern: Composables render state, ViewModels manage actions, Repositories abstract database and network access, and DataManagers cache session data for clear Kotlin Multiplatform layer responsibilities.

How do I handle operation results and identifiers safely in Kotlin Multiplatform?

Use @JvmInline value classes for type-safe identifiers and sealed classes for operation results to improve safety and maintainability across your Kotlin Multiplatform shared code.

Does this Kotlin Multiplatform convention guide cover testing patterns for shared and platform-specific code?

Yes, it provides explicit testing guidance and architecture documentation to ensure consistent, testable Kotlin Multiplatform projects across both common and platform-specific source sets.

Why should I enforce file naming rules and layer boundaries in a Kotlin Multiplatform codebase?

Enforcing file naming rules and layer boundaries reduces ambiguity and onboarding time for developers, ensuring consistent architecture and easier code reviews across the mobile codebase.

Can I use Compose Multiplatform with the MVVM pattern defined in these Kotlin Multiplatform conventions?

Yes, the conventions standardize Compose Multiplatform UI components as Composables that render state, while ViewModels manage actions, aligning perfectly with the defined MVVM architecture.