coding-kotlin

Installation
SKILL.md

coding-kotlin

Purpose

This skill equips the AI to generate, debug, and optimize Kotlin code, focusing on coroutines for async operations, data classes for immutable data handling, sealed classes for type-safe hierarchies, extension functions for reusable code, Gradle for project builds, and KMM for multiplatform development.

When to Use

Use this skill for Android app development requiring async tasks (e.g., network calls), data modeling in APIs, or cross-platform projects with shared logic. Apply it when performance matters, like using coroutines to avoid blocking threads, or when setting up Gradle for dependency management in KMM setups.

Key Capabilities

  • Coroutines: Handle asynchronous code with structured concurrency; use kotlinx.coroutines for non-blocking I/O.
  • Data classes: Automatically generate equals, hashCode, and toString; define with data class User(val name: String, val id: Int).
  • Sealed classes: Restrict class inheritance for exhaustive when expressions; e.g., sealed class Result { data class Success(val data: String) : Result() }.
  • Extension functions: Add methods to existing classes without inheritance; e.g., fun String.reverse() = this.reversed().
  • Gradle: Manage builds with scripts like build.gradle.kts for dependencies and tasks.
  • KMM: Share code between Android/iOS; configure with shared modules in Gradle.

Usage Patterns

To accomplish tasks, always import necessary packages first (e.g., import kotlinx.coroutines.*). For async operations, wrap code in a coroutine scope like runBlocking { } and use launch for fire-and-forget or async for awaited results. When modeling data, use data classes for POJOs and sealed classes for state machines. For Gradle tasks, run commands from the project root and pass flags like --info for debugging. In KMM projects, structure code into shared and platform-specific modules, then link via Gradle configurations. Always check for nullability with ? to prevent crashes.

Related skills
Installs
24
GitHub Stars
5
First Seen
Mar 5, 2026