Agent Skillschrisbanes/skills › kotlin-concurrency-and-flow

kotlin-concurrency-and-flow

GitHub

指导 Kotlin 协程作用域所有权、生命周期管理及 Flow 状态/事件建模的最佳实践,确保异步工作具备明确的所有者和可观测的取消行为。

skills/kotlin-concurrency-and-flow/SKILL.md chrisbanes/skills

Trigger Scenarios

审查 Kotlin 协程作用域所有权 处理 StateFlow/SharedFlow 状态更新 解决 runBlocking 或 init launch 问题 设计非恢复性事件与可恢复状态的边界

Install

npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -g -y
More Options

Use without installing

npx skills use chrisbanes/skills@kotlin-concurrency-and-flow

指定 Agent (Claude Code)

npx skills add chrisbanes/skills --skill kotlin-concurrency-and-flow -a claude-code -g -y

安装 repo 全部 skill

npx skills add chrisbanes/skills --all -g -y

预览 repo 内 skill

npx skills add chrisbanes/skills --list

SKILL.md

Frontmatter
{
    "name": "kotlin-concurrency-and-flow",
    "description": "Use when writing or reviewing Kotlin coroutine scope ownership, 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. Select a scope whose lifecycle owns the work; do not retain arbitrary scopes or hide unstructured launches behind non-suspending APIs.
  3. Model renderable, current data as state and imperative one-shot work as an event only when its loss and replay behavior are explicitly acceptable.
  4. Choose Flow sharing and buffering semantics from the producer and consumer lifetimes rather than from a default.
  5. Read the focused reference for the material concern below.
  6. 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, init { launch }, fire-and-forget API, runBlocking, broad catch, or cancellation boundary Structured concurrency
StateFlow, SharedFlow, Channel, stateIn, SharingStarted, .value, state updates, sentinel values, or one-shot events Flow state and events
Compose collection or UI effect handling Compose state and effects

RED/GREEN agent scenarios

  1. RED stores a long-lived CoroutineScope in a service and launches from arbitrary callers. GREEN makes ownership and cancellation follow a defined lifecycle boundary.
  2. Novel case: a screen needs replayable loading state and non-replayable navigation. GREEN uses distinct state and event contracts with documented delivery semantics.
  3. Counterexample: a suspend function already has a caller-owned scope. GREEN does not add an internal scope merely to make the API look asynchronous.

Version History

  • 2026.8.5 Current 2026-08-16 02:45

Same Skill Collection

skills/compose-animations/SKILL.md
skills/compose-component-design/SKILL.md
skills/compose-focus-navigation/SKILL.md
skills/compose-modifier-and-layout-style/SKILL.md
skills/compose-performance/SKILL.md
skills/compose-recomposition-performance/SKILL.md
skills/compose-side-effects/SKILL.md
skills/compose-slot-api-pattern/SKILL.md
skills/compose-stability-diagnostics/SKILL.md
skills/compose-state-and-effects/SKILL.md
skills/compose-state-authoring/SKILL.md
skills/compose-state-deferred-reads/SKILL.md
skills/compose-state-hoisting/SKILL.md
skills/compose-state-holder-ui-split/SKILL.md
skills/compose-ui-testing-patterns/SKILL.md
skills/implement-issue/SKILL.md
skills/kotlin-api-design/SKILL.md
skills/kotlin-control-flow/SKILL.md
skills/kotlin-coroutines-structured-concurrency/SKILL.md
skills/kotlin-flow-state-event-modeling/SKILL.md
skills/kotlin-functions/SKILL.md
skills/kotlin-multiplatform-expect-actual/SKILL.md
skills/kotlin-types-value-class/SKILL.md
skills/run-github-project/SKILL.md
skills/shepherd/SKILL.md
skills/to-plan/SKILL.md
skills/using-chrisbanes-skills/SKILL.md

Metadata

Files
0
Version
2026.8.5
Hash
f64e8bf0
Indexed
2026-08-16 02:45

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 20:28
浙ICP备14020137号-1 $mapa de visitantes$