kp-coroutine-scope

Installation
SKILL.md

One-line summary

Every coroutine belongs to a CoroutineScope. The scope owns the coroutine's lifecycle — when the scope is cancelled, the coroutine is cancelled. Choosing the right scope is the most common Coroutines design decision.

When to use this skill

  • Launching a coroutine and unsure which scope to attach it to.
  • Coroutines outliving their useful work (running after the screen closes, the request returns, the test finishes) — a scope-ownership problem.
  • Code that uses GlobalScope — almost always wrong; this skill explains the alternatives.
  • Test setup that leaks coroutines into other tests.

When NOT to use this skill

  • A single suspend function called directly from another suspend function — no launch needed.
  • The work is a one-shot transform that does not need to outlive the call — use withContext instead of launch.

Core content

Scopes are lifecycle anchors. A CoroutineScope is created with a Job (or SupervisorJob) and a CoroutineContext. When the job is cancelled, every coroutine launched from the scope is cancelled. Structured concurrency depends on this.

Installs
1
GitHub Stars
1
First Seen
Jul 13, 2026
kp-coroutine-scope — yonatankarp/software-design-skills