chrisbanes/skills

kotlin-concurrency-and-flow

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.

Trending #7019 First seen Aug 6, 2026

Installation

$ npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from chrisbanes/skills · top by installs.

npx skills add chrisbanes/skills

Browse all from chrisbanes/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 1.0K
License LICENSE
Default branch main
Open issues 0
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,412 B
  • docs SUMMARY.md 2,352 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 435 installs

SKILL.md

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.

  1. 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.

  1. Select a scope whose lifecycle owns the work; do not retain arbitrary scopes

or hide unstructured launches behind non-suspending APIs.

  1. Model renderable, current data as state and imperative one-shot work as an

event only when its loss and replay behavior are explicitly acceptable. For a one-consumer navigation handoff that must survive a collector gap, choose a buffered Channel exposed as receiveAsFlow(); do not preserve a replay-zero SharedFlow after identifying event loss as the defect.

  1. Choose Flow sharing and buffering semantics from the producer and consumer

lifetimes rather than from a default.

  1. Read the focused reference for the material concern below.
  2. 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)
Compose collection or UI effect handling [Compose state and effects](../compose-state-and-effects/SKILL.md)