No slash command · from kotlin-plugin
Guides idiomatic Kotlin/JVM code: null safety without !! (use ?., ?:, checkNotNull), val/read-only collections, data/sealed/value classes, exhaustive when, scope functions used sparingly, extension functions, default arguments, Result vs exceptions, Java interop annotations, and package/file layout.
Ships in kotlin-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Follow the official Kotlin coding conventions and whatever ktlint/detekt config the project has. Check the Kotlin version in the build before using newer features (data object ≥ 1.9, entries ≥ 1.9, guard conditions in when ≥ 2.1 stable in 2.2, context parameters are experimental).
?., ?:, early return, or let:val user = repository.findById(id) ?: throw UserNotFound(id)
val city = user.address?.city ?: "unknown"
!! is a crash waiting to happen. Allowed only where a preceding line proves non-null and the compiler cannot see it — and then prefer checkNotNull(x) { "why" } / requireNotNull for a useful message.String!). Declare the Kotlin type explicitly at the boundary (val name: String? = javaObj.getName()) so a null fails where it enters, not three calls later.lateinit var only for framework/test injection; never for values that can legitimately be missing.val over var; var only in tight local scopes.List/Set/Map (read-only interfaces), never MutableList. Build with buildList { } / buildMap { } or toList().data class properties are val; produce changes with copy(...).@JvmInline value class OrderId(val value: UUID)
data class Order(val id: OrderId, val lines: List<OrderLine>, val status: OrderStatus)
sealed interface PaymentResult {
data class Succeeded(val receiptId: String) : PaymentResult
data class Declined(val reason: String) : PaymentResult
data object Timeout : PaymentResult
}
fun describe(r: PaymentResult): String = when (r) {
is PaymentResult.Succeeded -> "Paid (${r.receiptId})"
is PaymentResult.Declined -> "Declined: ${r.reason}"
PaymentResult.Timeout -> "Timed out"
}
when over a sealed type or enum is an expression with no else branch, so adding a subtype breaks the build where it must be handled.value class for typed IDs and units — zero runtime cost, prevents mixing UserId and OrderId.enum class with properties for fixed sets; iterate with entries (not values()) on 1.9+.object for stateless singletons only; anything with dependencies is a class injected by constructor.interface + constructor injection over open classes and inheritance; classes are final by default — keep them that way.fun search(query: String, limit: Int = 20, includeArchived: Boolean = false). Call boolean/same-typed args by name.= …) when the body is one expression and stays readable.OrderMappers.kt), not in a global Utils.kt.XxxUtils objects.internal for module-private API, private for file-private helpers.| Function | Use for |
|---|---|
let | null-checked transform: x?.let { use(it) } |
apply | configure an object you just created |
also | side effect in a chain (logging) |
run / with | rarely — a block that computes a value from one receiver |
Never nest scope functions or chain more than two; name the lambda parameter when it is ambiguous. A plain val + if is often clearer.
require(x > 0) { "..." } for arguments, check(state) for state, custom exceptions for domain errors the caller handles.Either, use it consistently.runCatching catches CancellationException and Errors too — only use it at boundaries, never around suspend calls without rethrowing cancellation (see kotlin-coroutines).use { } for every Closeable/AutoCloseable.map, filter, associateBy, groupBy, partition, sumOf) for clarity.asSequence() only for large collections with several chained steps, or for lazy/infinite sources — not by default.firstOrNull { } instead of filter { }.firstOrNull(); any { } instead of filter { }.isNotEmpty().associateBy/groupBy instead of manual map building."Order $id has ${lines.size} lines"), raw strings ("""…""".trimIndent()) for multi-line text.src/main/kotlin, tests in src/test/kotlin, package path mirrors directories.OrderMappers.kt).@JvmStatic on companion functions, @JvmOverloads on functions with defaults, @Throws for checked exceptions Java callers must catch, @JvmField only for constants.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
3 skills in this plugin
/kotlin-coroutinesKotlin coroutines on the JVM: suspend functions, structured concurrency (coroutineScope, supervisorScope, application-owned scopes), dispatchers and blocking I/O, cancellation and CancellationException rules, timeouts, async/await parallelism, Flow (cold streams, operators, flowOn, StateFlow/SharedFlow), Ktor request coroutines, bridging callbacks and Java futures, dispatcher injection for tests.
Use this skill to:
- Write suspend APIs that are cancellable and do not block threads.
- Run independent work in parallel without leaking coroutines.
- Expose streams with Flow correctly.
- Keep coroutine code testable with injected dispatchers.
Do NOT use this skill for:
- General Kotlin idioms (see kotlin-conventions).
- Testing coroutines (see kotlin-testing — runTest, Turbine).
/kotlin-testingTesting Kotlin/JVM code: choosing between JUnit 5 (+ kotlin.test / AssertJ) and Kotest by what the project uses, MockK (mockk, every/coEvery, verify/coVerify, slot, relaxed mocks), coroutine tests with runTest and test dispatchers, Flow tests with Turbine, Ktor testApplication, Testcontainers integration tests, test fixtures and builders, coverage with Kover or JaCoCo.
Use this skill to:
- Write tests in the project's framework and style.
- Mock collaborators (including suspend functions) with MockK.
- Test coroutines and flows deterministically without real delays.
- Test Ktor routes in-process.
Do NOT use this skill for:
- Java-only test code (see java-foundation:jvm-testing).
- Production Kotlin idioms (see kotlin-conventions).
npx claudepluginhub aratkruglik/claude-sdlc --plugin kotlin-pluginOther plugins' skills for the same job