/kotlin:kotlinfrom kotlin
Writes, reviews and fixes idiomatic Kotlin outside @Composable code. Use for "Smart cast to String is impossible, because name is a mutable property", a non-exhaustive when, !! NullPointerException, events lost from a MutableSharedFlow, stateIn that never emits, a coroutine that outlives its owner, GlobalScope or runBlocking freezing the caller, swallowed CancellationException, or a Java-to-Kotlin conversion. Covers null safety, sealed classes, scope functions, structured concurrency, Flow and Java interop.
Ships in kotlin. 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.
Read when SKILL.md points to them.
Follow the project's Kotlin style and toolchain; improve the code at hand without reformatting the file.
Not for: tests (kotlin-testing), Android lifecycle, ViewModel state policy and Room (android), @Composable code (jetpack-compose), build files (gradle, or android-build for AGP), plain .java files (java), Spring Boot configuration (spring-boot).
kotlin { compilerOptions }, jvmToolchain and compiler plugins (plugin.jpa, plugin.spring, plugin.serialization). Under AGP 9 Kotlin support is built in, so there may be no kotlin-android plugin line.when (is X if cond ->) need Kotlin 2.2 or later.!! without a stated invariant in a comment or requireNotNull(x) { "why" }. Prefer ?: with return, error(...) or a default.var property or an open or custom-getter property: copy it to a local val (val name = name ?: return), or make the property val.val, read-only List/Set/Map in public types, and copy() over mutation.@JvmInline value class for one domain-meaningful field; sealed interface or class for closed hierarchies. Read references/api-design.md before adding an extension, a value class or a public factory.when over a sealed type, enum or Boolean is an expression with every case named and no else, so a new subtype breaks compilation. Give each data-bearing subtype its own is branch.require for arguments, check for state, error() for unreachable states. Expected absence returns null or a sealed result; Result suits operations whose failure is an exception to hand on, and runCatching around suspend code needs the cancellation guard below.let for nullable transforms, apply for configuring an object, also for side effects. Use a plain val when it reads better.asSequence()) for long chains over large collections or when first/take can stop early; plain collection operators for short lists.!!, as or else on a closed when.launch has an owner scope that is cancelled when the work stops mattering (viewModelScope, a request scope, an injected CoroutineScope tied to a lifecycle). No GlobalScope.suspend functions or Flow, not a stored CoroutineScope or a fire-and-forget launch.runBlocking only in main, a required blocking framework bridge, and test edges. Blocking IO goes in withContext(ioDispatcher) with the dispatcher injected; runInterruptible makes a blocking JVM call cancellable.ensureActive() in long loops, rethrow CancellationException from any broad catch or runCatching, and put cleanup that suspends in withContext(NonCancellable).coroutineScope { async { } }; supervisorScope when a child's failure must not cancel its siblings.init, exception handling and refactoring order.Flow for a stream per collector; StateFlow for current state with a .value; SharedFlow or Channel for events. A SharedFlow with replay = 0 drops an event emitted while nobody collects. A Channel delivers each event to one collector and buffers until it arrives.MutableStateFlow, expose asStateFlow(), and change it with update { it.copy(...) }, never value = value.copy(...).stateIn(scope, SharingStarted.WhileSubscribed(5_000), initial); use Eagerly when .value must be correct with no collector.flowOn moves the upstream, not the collector. catch handles upstream errors only, so put it before collect/launchIn and rethrow cancellation.stateIn pitfalls and operator choices.android; operator, cancellation and delivery semantics stay here. A defect that spans both needs both skills.@Jvm* annotations, @Throws, SAM overloads, Kotlin called from Java. Read when Java and Kotlin call each other..java files, in dependency order, with framework annotation targets. Read for any conversion request.data class entities, equality, open and the JPA plugin, DTOs). Read when a Kotlin class carries @Entity or @Service.catch (e: Exception) and runCatching both catch CancellationException; the coroutine then keeps running as if it was not cancelled.MutableSharedFlow<Event>() with a UI collector that starts after the emit loses the event. Do not "fix" it with replay = 1, which replays a stale event to every new collector.StateFlow skips equal values; mutating a list in place and re-assigning the same instance never emits.stateIn(..., WhileSubscribed) returns the initial value until a collector arrives, so reading .value right after construction sees the placeholder.init {} runs before the subclass is initialised and cannot be tested in isolation. Start it from a named function.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin kotlin