kotlin-concurrency-and-flow — скилл для Claude Code: корутины и Flow
Скилл для ревью и написания Kotlin-кода с корутинами: разбирает владение scope, отмену, StateFlow, SharedFlow и Channel.
npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -a claude-codeЧто делает kotlin-concurrency-and-flow
Скилл включается, когда вы пишете или проверяете код на Kotlin с корутинами: владение CoroutineScope, работа с Thread и Executor, init { launch }, runBlocking, отмена, а также StateFlow, SharedFlow, Channel, stateIn и SharingStarted.
Внутри — процедура из семи шагов. Сначала нужно найти каждого владельца корутины, границу отмены, производителя, потребителя, долгоживущее состояние и разовое событие. Дальше скилл советует сравнить текущий контракт API с требуемым владельцем и временем жизни: если suspend-функция уже отдаёт вызывающему отмену, результат и ошибки, менять ничего не надо. Отдельно разбирается выбор примитива: Channel отдаёт событие одному потребителю, настроенный SharedFlow рассылает его всем активным. Для навигационного перехода на одного потребителя, который должен пережить паузу коллектора, предлагается Channel(Channel.BUFFERED) через receiveAsFlow().
Есть роутер по темам: сигналы про структурированную конкурентность ведут в references/structured-concurrency.md, про состояние и события — в references/flow-state-events.md. Для проверки изменений скилл отправляет в ../gradle-run/SKILL.md и прямо запрещает запускать ./gradlew вручную. Работа с Compose-состоянием уходит в соседний скилл compose-state-and-effects. Установка идёт через npx skills add.
Какие задачи решает
- найти, кто владеет корутиной и когда её отменят
- убрать fire-and-forget
launchиз-под обычной функции - выбрать между
ChannelиSharedFlowдля разовых событий - проверить, не теряется ли событие в паузе коллектора
- решить, нужен ли
stateInи какойSharingStarted
Примеры запросов агенту
- Проверь этот ViewModel: кто владеет scope и что будет при отмене?
- Стоит ли здесь
SharedFlowили хватитChannel(Channel.BUFFERED)? - Отревьюй обновление состояния: нет ли гонки между
_state.valueиstateIn?
Как установить kotlin-concurrency-and-flow
1Через Skills CLI (Vercel)
npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -a claude-code2Вручную: положить файлы
~/.claude/skills/kotlin-concurrency-and-flow/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/kotlin-concurrency-and-flow/
1Через Skills CLI (Vercel)
npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -a codex2Вручную: положить файлы
.agents/skills/kotlin-concurrency-and-flow/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -a cursor2Вручную: положить файлы
.cursor/skills/kotlin-concurrency-and-flow/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install chrisbanes/skills kotlin-concurrency-and-flow2Вручную: положить файлы
.github/skills/kotlin-concurrency-and-flow/SKILL.md1Через Skills CLI (Vercel)
npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -a gemini-cli2Командой платформы
gemini skills install https://github.com/chrisbanes/skills --path skills/kotlin-concurrency-and-flowВручную: положить файлы
.devin/skills/kotlin-concurrency-and-flow/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о kotlin-concurrency-and-flow
Как установить kotlin-concurrency-and-flow в Claude?
Одной командой: npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -a claude-code. Файл скилла появится по пути ~/.claude/skills/kotlin-concurrency-and-flow/SKILL.md.
Что делает этот скилл?
Помогает писать и ревьюить Kotlin-код с корутинами: разбирает владение scope, границы отмены, а также выбор между состоянием и разовыми событиями во Flow.
Чем Channel отличается от SharedFlow по версии скилла?
Channel доставляет каждое событие одному потребителю, а настроенный SharedFlow рассылает его всем активным. Если контракт потребителя неизвестен, скилл просит сначала его определить.
Исходный текст
SKILL.md · Apache-2.0
---
name: kotlin-concurrency-and-flow
description: Use when writing or reviewing Kotlin coroutine scope ownership, raw Thread or Executor work, init launches, non-suspending launch APIs, runBlocking, cancellation, StateFlow, SharedFlow, Channel, stateIn, SharingStarted, state updates, or one-shot events.
---
# Kotlin concurrency and Flow
## Core principle
Give asynchronous work an explicit owner and lifetime, then model durable state
and transient events with primitives whose delivery and replay semantics match
the product contract.
## Procedure
1. Identify each coroutine owner, cancellation boundary, producer, consumer,
durable state, and transient event.
2. Before changing an API, compare its existing caller-visible contract with
the required owner and lifetime. If a suspend API already gives its caller
cancellation, result, and failure ownership, finish with no change; do not
add a scope, `launch`, callback, or deferred wrapper merely for convenience.
3. Select a scope whose lifecycle owns the work; do not retain arbitrary scopes
or hide unstructured launches behind non-suspending APIs.
4. Model renderable, current data as state and imperative one-shot work as an
event only when its loss and replay behavior are explicitly acceptable.
Ask whether one consumer handles each event or every active consumer must
receive it. A `Channel` hands each event to one consumer; a configured
`SharedFlow` broadcasts to active consumers. If that consumer contract is
unknown, state both options and the decision needed before choosing one.
For a one-consumer navigation handoff that must survive a collector gap,
choose a bounded `Channel(Channel.BUFFERED)` (not `UNLIMITED`) exposed as
`receiveAsFlow()`; do not preserve a
replay-zero `SharedFlow` after identifying event loss as the defect.
5. Choose Flow sharing and buffering semantics from the producer and consumer
lifetimes rather than from a default.
6. Read the focused reference for the material concern below.
7. Finish when cancellation, restart, replay, and failure behavior are all
observable from the public API and no caller must guess who owns the work.
## Topic router
| Signal | Read |
|---|---|
| Stored `CoroutineScope`, raw `Thread` or `Executor` work, `init { launch }`, fire-and-forget API, `runBlocking`, broad catch, or cancellation boundary | [Structured concurrency](references/structured-concurrency.md) |
| `StateFlow`, `SharedFlow`, `Channel`, `stateIn`, `SharingStarted`, `.value`, state updates, sentinel values, or one-shot events | [Flow state and events](references/flow-state-events.md) |
| Running Gradle to validate a change | [Gradle run](../gradle-run/SKILL.md); never raw `./gradlew` |
| Compose collection or UI effect handling | [Compose state and effects](../compose-state-and-effects/SKILL.md) |
© chrisbanes · Apache-2.0 · chrisbanes/skills