kp-structured-concurrency
Installation
SKILL.md
One-line summary
Nest coroutines under explicit scopes whose lifetimes form a tree — making cancellation, failure propagation, and resource cleanup predictable and automatic.
When to use this skill
- Multiple concurrent operations need to coordinate: combine results, propagate cancellation, or isolate failures.
- A function spawns child coroutines and must not return until all children complete.
- Sibling failure should NOT cancel its siblings (use
supervisorScope). - Sibling failure SHOULD cancel its siblings ("fail fast"; use
coroutineScope).
When NOT to use this skill
- A single suspend call to a single suspend function — no concurrency to structure.
- Truly independent fire-and-forget work whose failure has no consequence for the rest of the program — though even then, scoping is usually worth it.
Core content
coroutineScope { … } — fail-fast group. Runs its block within a new scope as a child of the calling scope. Suspends until all children complete. If any child fails, the rest are cancelled and the failure rethrows to the caller.