Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

kotlin-review

БесплатноБез исполняемых скриптовНе проверен

Reviewing Kotlin code - what to flag, and what the compiler, detekt and ktlint already flag for you USE WHEN: you are reviewing, critiquing or auditing…

claude-dev-suiteот claude-dev-suite★ 51 звезда на GitHub

Об этом скилле

Reviewing Kotlin

A reviewer's leverage is what the toolchain cannot say. Kotlin's compiler closes the single largest hole in Java — null — so the findings that remain are mostly about the two places its guarantees stop: the boundary with Java, and structured concurrency.

The snippets are fragments cut down to the defect, not runnable programs.

Already covered - do not spend review on it

Defect Reported by
Dereferencing a nullable without a check the compiler
Non-exhaustive when used as an expression the compiler
Unused variable, unreachable code the compiler
Unused import, formatting, naming ktlint
Long method, high complexity, magic number detekt — only if detekt runs
!! usage detekt UnsafeCallOnNullableType — opt-in, not in the default ruleset
Swallowed exception (catch { } empty) detekt SwallowedException, EmptyCatchBlock
println left in production code detekt ForbiddenMethodCall if configured

Kotlin projects vary more than most in whether detekt runs at all. Check build.gradle.kts for the plugin and for detekt.yml, because the !! and swallowed-exception rows flip sides depending on it.

The table above dates; the tools do not. Verify a default set with mcp__documentation__fetch_docs on technology kotlin-quality — topics detekt-potential-bugs, detekt-configuration, detekt-suppressing. Those entries point at the indexes the tool authors maintain, so they follow the version the project actually pins rather than the one this skill was written against.

The checks that earn their place

A platform type from Java, trusted as non-null

val name = javaService.getName()   // type is String!, not String
name.length                        // NPE if Java returned null

When you see it: any value coming from Java or a Java-based library without @Nullable/@NotNull annotations — JPA entities, Jackson-deserialised objects, older SDKs.

Ask: is the Java side annotated? A platform type (String!) opts out of null checking: the compiler accepts both nullable and non-null use, so Kotlin's central guarantee simply does not apply at this line. Declaring the local explicitly as String? restores it.

A coroutine launched on a scope that outlives its work

GlobalScope.launch { refresh() }   // never cancelled; survives the screen

When you see it: GlobalScope, or a CoroutineScope(Dispatchers.IO) created as a field and never cancelled.

Ask: who cancels this? Structured concurrency is the language's answer to leaked work, and GlobalScope is the documented way to opt out of it. On Android the job outlives the Activity holding its references; on a server it survives the request. viewModelScope, lifecycleScope or a scope cancelled in close() is the fix.

Cancellation swallowed by a broad catch

try { work() } catch (e: Exception) { log(e) }   // also catches CancellationException

When you see it: catch (e: Exception) or catch (e: Throwable) inside a suspend function or a coroutine builder.

Ask: does this run in a coroutine? Cancellation is delivered as a CancellationException, so a broad catch turns a cancelled job into one that keeps running and reports a spurious error. The idiom is to rethrow it explicitly, or catch only the exceptions actually expected.

A blocking call inside a suspend function

suspend fun load(): String {
    return File(path).readText()   // blocks whichever dispatcher thread runs it
}

When you see it: JDBC, Thread.sleep, File I/O or a synchronous HTTP client inside suspend fun, with no withContext(Dispatchers.IO).

Ask: which dispatcher runs this? suspend is a promise not to block, and nothing enforces it. On Dispatchers.Default, whose pool is sized to the CPU count, a handful of these stall everything.

A data class whose copy bypasses the constructor's validation

data class Email(val value: String) {
    init { require(value.contains("@")) }
}
val bad = Email("[email protected]").copy(value = "nope")   // init DOES run — but see below

When you see it: a data class used as a value type with invariants, and especially one with a private constructor.

Ask: is the constructor the only way in? init does run for copy, but a private constructor does not make a data class closed: the generated copy stays public and re-exposes it. That is the case worth flagging, and the compiler is only beginning to warn about it.

A lateinit read on a path that may precede initialisation

private lateinit var client: Client
fun handle() = client.send(msg)    // UninitializedPropertyAccessException

When you see it: lateinit initialised in a lifecycle callback, an @PostConstruct, or conditionally.

Ask: is every entry point downstream of the initialiser? lateinit moves a nullabili

Полный SKILL.md на GitHub

Установить kotlin-review в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Grep
Glob

FAQ

Что делает скилл kotlin-review?

Reviewing Kotlin code - what to flag, and what the compiler, detekt and ktlint already flag for you USE WHEN: you are reviewing, critiquing or auditing existing Kotlin code - a "code review", a "review" of a .kt file, a diff, a PR or a pull request; deciding what to comment on in Kotlin; avoiding false positives on Kotlin code DO NOT USE FOR: writing, explaining or learning Kotlin - use `languages/kotlin`; anything the compiler, detekt or ktlint already reports (this skill lists those so you can stay silent about them); Android framework specifics - use the Android skills; Spring specifics - use the Spring skills

Как установить скилл kotlin-review?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл kotlin-review запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить kotlin-review с