No slash command · from kotlin-plugin
Provides guidance on Kotlin coroutines for JVM: suspend functions, structured concurrency, dispatchers, cancellation, Flow, and testable patterns. Useful when writing concurrent Kotlin code.
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.
suspend. It must be main-safe: callers can invoke it from any dispatcher, so it switches context itself when it blocks.class ReportRepository(private val io: CoroutineDispatcher = Dispatchers.IO) {
suspend fun load(path: Path): Report = withContext(io) {
Files.newBufferedReader(path).use { parse(it) } // blocking JDBC/file/HTTP-client calls live here
}
}
suspend if it never suspends.withContext(IO).coroutineScope { } (one failure cancels siblings) or supervisorScope { } (children fail independently);CoroutineScope(SupervisorJob() + Dispatchers.Default) owned by a component with close()).GlobalScope. Never runBlocking except in main or tests — inside a server it blocks a request thread and can deadlock.suspend fun dashboard(userId: UserId): Dashboard = coroutineScope {
val orders = async { orderClient.recent(userId) }
val profile = async { profileClient.get(userId) }
Dashboard(orders.await(), profile.await())
}
Semaphore, chunked, or flatMapMerge(concurrency = N)) — never map { async { } } over thousands of items.ensureActive() / yield().CancellationException. A broad catch around suspend calls must rethrow it:try {
client.send(event)
} catch (e: CancellationException) {
throw e
} catch (e: IOException) {
log.warn("send failed", e)
}
runCatching { suspendCall() } swallows cancellation — avoid it around suspend calls, or rethrow CancellationException from the failure.finally; suspending cleanup needs withContext(NonCancellable) { … }.withTimeout(5.seconds) { … } (throws TimeoutCancellationException) or withTimeoutOrNull.coroutineScope/async, exceptions propagate to the caller of await/the scope — handle them there.CoroutineExceptionHandler only on root coroutines of an app-owned scope, for logging; it does not make failures recoverable.launch for fire-and-forget within a scope; its failures cancel the parent unless under a SupervisorJob.Flow is cold: nothing runs until collected. Build with flow { emit(…) }, channelFlow { } for concurrent producers, callbackFlow { … awaitClose { unregister() } } for callback APIs.flowOn(io), never withContext inside flow { } around emit.map, filter, onEach, catch (upstream errors only), retryWhen, debounce, distinctUntilChanged, flatMapLatest.StateFlow (current value, conflated) via MutableStateFlow kept private and exposed as StateFlow; events: SharedFlow. Convert a cold flow with stateIn(scope, SharingStarted.WhileSubscribed(5_000), initial).CompletableFuture → future.await() (kotlinx-coroutines-jdk8, built into core on recent versions).suspendCancellableCoroutine { cont -> … cont.invokeOnCancellation { cancel() } }.CompletableFuture via scope.future { }.withContext(Dispatchers.IO).call's scope; hand it to an application-owned scope or a queue.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
3 skills in this plugin
/kotlin-conventionsIdiomatic Kotlin for JVM projects: null safety without !!, val and read-only collections, data/sealed/value classes, exhaustive when, scope functions (let/apply/also/run/with) used sparingly, extension functions, default and named arguments, Result vs exceptions, collections vs sequences, Java interop annotations, package and file layout, Kotlin coding conventions. Stack-agnostic within Kotlin/JVM.
Use this skill to:
- Model domain types with data, sealed and value classes.
- Handle absence and errors explicitly and exhaustively.
- Keep code readable — no scope-function chains or clever one-liners.
- Interoperate with Java libraries without platform-type surprises.
Do NOT use this skill for:
- Coroutines and Flow (see kotlin-coroutines).
- Testing (see kotlin-testing).
- Gradle/Maven dependency management (see java-foundation:build-tooling).
/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