coding-kotlin

Kotlin: coroutines, data classes, sealed classes, extension functions, Gradle, KMM multiplatform

16 stars

Best use case

coding-kotlin is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Kotlin: coroutines, data classes, sealed classes, extension functions, Gradle, KMM multiplatform

Teams using coding-kotlin should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/coding-kotlin/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/coding-kotlin/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/coding-kotlin/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How coding-kotlin Compares

Feature / Agentcoding-kotlinStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Kotlin: coroutines, data classes, sealed classes, extension functions, Gradle, KMM multiplatform

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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.

## Common Commands/API
- Gradle commands: Run `gradle build --stacktrace` to compile and debug; use `gradle assembleDebug` for Android builds; in KMM, add dependencies in build.gradle.kts like `implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")`.
- Coroutines API: Use `launch { delay(1000L); println("Task completed") }` for delayed execution; or `val deferred = async { someFunction() }; deferred.await()` for concurrent tasks.
- Data classes: Define and use as `data class Person(val name: String); val p = Person("John"); println(p.copy(name = "Jane"))` to create copies with modifications.
- Sealed classes: Handle with `when (result) { is Result.Success -> process(data); is Result.Error -> handleError() }` for exhaustive checking.
- Extension functions: Implement as `fun Int.isEven() = this % 2 == 0; val num = 4; println(num.isEven())` to extend built-ins.
- KMM setup: In build.gradle.kts, add `kotlin { android { compilations.all { kotlinOptions.jvmTarget = "1.8" } } ios { binaries { framework() } } }` for multiplatform configuration.
- API endpoints: For external services in Kotlin, use libraries like Ktor; e.g., `HttpClient().get("https://api.example.com/data")` with auth via env var like `$KOTLIN_API_KEY` in headers.

## Integration Notes
Integrate this skill by ensuring the environment has Kotlin SDK installed (e.g., via SDKMAN: `sdk install kotlin`). For Android, add Kotlin plugins in build.gradle: `plugins { id("org.jetbrains.kotlin.android") }` and set minSdk to 21 for coroutines. In KMM projects, link shared modules with `expect fun platformFunction()` in common code and `actual fun platformFunction() = ...` in platform-specific files. Use environment variables for secrets, like setting `$GRADLE_API_KEY` for repository access in gradle.properties: `apiKey=$GRADLE_API_KEY`. Test integrations with `./gradlew test` and handle platform differences by checking OS via `System.getProperty("os.name")`.

## Error Handling
Always use structured error handling in coroutines: wrap code in `try { launch { riskyOperation() } } catch (e: CancellationException) { log("Coroutine cancelled") } finally { cleanup() }`. For data classes, validate inputs at construction: e.g., `data class User(val name: String) { init { require(name.isNotBlank()) { "Name cannot be blank" } } }`. In sealed classes, ensure all subclasses are handled in when expressions to avoid `UnreachableCode` errors. For Gradle, parse output with `--stacktrace` and check for common issues like dependency conflicts by running `gradle dependencies`. In KMM, handle platform-specific errors with `expect class PlatformException() { actual constructor() }` and catch in common code.

## Concrete Usage Examples
1. **Example: Asynchronous network call with coroutines**  
   Import coroutines and launch a scope: `import kotlinx.coroutines.*; suspend fun fetchData() = "Data"; fun main() = runBlocking { val result = async { fetchData() }.await(); println(result) }`. This fetches data without blocking the main thread.
   
2. **Example: Modeling API response with sealed classes and data classes**  
   Define structures: `sealed class ApiResult { data class Success(val data: String) : ApiResult(); data class Error(val message: String) : ApiResult() }; fun process(result: ApiResult) = when (result) { is Success -> println(result.data); is Error -> println(result.message) }`. Use this to handle responses safely in KMM shared code.

## Graph Relationships
- Related to: coding-android (shares tags like "android" and focuses on Kotlin integration).
- Connected via: coding cluster (links to other coding skills like coding-java for JVM interoperability).
- Overlaps with: tools-kmm (via KMM multiplatform features) and build-gradle (for shared Gradle usage).

Related Skills

dev-coding

16
from diegosouzapw/awesome-omni-skill

Implement features as a Principal Engineering Developer

create-spring-boot-kotlin-project

16
from diegosouzapw/awesome-omni-skill

Create Spring Boot Kotlin Project Skeleton

coding-style

16
from diegosouzapw/awesome-omni-skill

Coding style, testing, and PR guidelines for the Kubb ecosystem. Use when writing or reviewing code for the Kubb ecosystem.

coding-standards

16
from diegosouzapw/awesome-omni-skill

Provides coding standards for React Native — performance patterns, consistency rules, and clean React architecture. Use when writing, modifying, or reviewing code.

coding-principles

16
from diegosouzapw/awesome-omni-skill

Language-agnostic coding principles for maintainability, readability, and quality. Use when implementing features, refactoring code, or reviewing code quality.

coding-lead

16
from diegosouzapw/awesome-omni-skill

Smart coding skill that routes tasks by complexity. Simple tasks (<60 lines, single file) execute directly via OpenClaw agent tools. Medium/complex tasks spawn Claude Code via ACP with full project context, coding standards, and historical decisions from agent memory. Use when user asks to write code, fix bugs, build features, refactor, review PRs, deploy, or any software engineering task. Combines OpenClaw long-term memory with Claude Code deep coding ability.

cc-skill-coding-standards

16
from diegosouzapw/awesome-omni-skill

Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.

backend-coding

16
from diegosouzapw/awesome-omni-skill

Expert backend development guidance covering Node.js, Python, Java, Go, API design (REST/GraphQL/gRPC), database patterns, authentication, caching, message queues, microservices, and testing. Produces production-ready, scalable, and secure backend code with industry best practices. Use when building APIs, implementing business logic, designing data models, integrating services, or when users mention backend development, server-side code, APIs, databases, or microservices.

awesome-copilot-root-kotlin-mcp-expert

16
from diegosouzapw/awesome-omni-skill

Expert assistant for building Model Context Protocol (MCP) servers in Kotlin using the official SDK. Use when: the task directly matches kotlin mcp expert responsibilities within plugin awesome-copilot-root. Do not use when: a more specific framework or task-focused skill is clearly a better match.

android-kotlin

16
from diegosouzapw/awesome-omni-skill

Android Kotlin development with Coroutines, Jetpack Compose, Hilt, and MockK testing

android-kotlin-development

16
from diegosouzapw/awesome-omni-skill

Develop native Android apps with Kotlin. Covers MVVM with Jetpack, Compose for modern UI, Retrofit for API calls, Room for local storage, and navigation architecture.

agent-kotlin-specialist

16
from diegosouzapw/awesome-omni-skill

Expert Kotlin developer specializing in coroutines, multiplatform development, and Android applications. Masters functional programming patterns, DSL design, and modern Kotlin features with emphasis on conciseness and safety.