Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add santimattius/structured-coroutines --skill kotlin-coroutines-skillgit clone --depth 1 https://github.com/santimattius/structured-coroutinesWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/santimattius/structured-coroutines/kotlin-coroutines-skill)<a href="https://agentmods.dev/skills/santimattius/structured-coroutines/kotlin-coroutines-skill"><img src="https://agentmods.dev/badge/skills/santimattius/structured-coroutines/kotlin-coroutines-skill/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/santimattius/structured-coroutines/kotlin-coroutines-skill"><img src="https://agentmods.dev/badge/skills/santimattius/structured-coroutines/kotlin-coroutines-skill.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector warn
SkillSpector: 1 finding, up to medium
These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →
- medium Prompt Injection · line 109 Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.Fix: Remove the large whitespace padding (blank-line blocks or long space runs) and review any content hidden below or to the right of it. Keep skill files compact and reviewable so no instructions can be
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00071 | $0.05631 |
| Opus 5 | $0.00036 | $0.02815 |
| Sonnet 5 | $0.00014 | $0.01126 |
| Haiku 4.5 | $0.00007 | $0.00563 |
Grade A, and why
kotlin-coroutines-skill scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 318 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Kotlin Coroutines
Overview
This skill provides expert guidance on Kotlin Coroutines, covering structured concurrency, scopes,
Dispatchers (including main-safe suspend and dispatcher injection), cancellation (including
withTimeout semantics), exception handling (CoroutineExceptionHandler, launch vs async),
Channels, Flow (cold vs hot, collectLatest, SharedFlow configuration, blocking in flow {}),
lifecycle-aware collection on Android, and testing (virtual time, setMain/resetMain). Use this
skill to help developers write safe, maintainable concurrent code aligned with Kotlin 1.9+/2.0+
conventions and official best practices.
Agent Behavior Contract (Follow These Rules)
- Identify the practice or error from the user's code or question (e.g. GlobalScope,
runBlocking in suspend, swallowing CancellationException) and open the corresponding
reference from the Triage table in
references/. - Apply the strict rules below in every response. Do not suggest or leave code that violates them.
- Respond in the required format: Analysis → Erroneous code → Optimized code → Explanation. If the user only asks a conceptual question (no code), skip erroneous/optimized snippets and focus on analysis and explanation.
- Do not recommend
GlobalScopein production. Use framework scopes (viewModelScope,lifecycleScope,rememberCoroutineScope), injected scopes, or local scopes (coroutineScope { },withContext { }). If an external scope is required, justify and document it. - Use
asynconly when a return value is needed; ifawait()is never called, uselaunch. Preserve structured concurrency: inside suspend functions usecoroutineScope { }+async/launch; do not launch in an external scope from suspend unless work must outlive the flow, and then document it. - Never use
runBlockinginside suspend functions or coroutine-based code. Avoid ending a suspend function withcoroutineScope { launch { } }as the last line when the intent is fire-and-forget —coroutineScopewaits for all children and blocks the caller; use an explicit external scope and document it if the work must truly run in the background beyond the caller's lifetime. - Use explicit Dispatchers:
Dispatchers.Defaultfor CPU-bound work,Dispatchers.Main/Main.immediatefor UI,withContext(Dispatchers.IO)for blocking I/O. Never perform blocking I/O on Default or Main. Do not useDispatchers.Unconfinedin production unless for a rare, documented case. Make suspend functions main-safe: move blocking work intowithContext(Dispatchers.IO)so callers on Main are never blocked. InjectCoroutineDispatcheras a constructor parameter (default to real dispatcher; replace withTestDispatcherin tests). - Never pass
Job()orSupervisorJob()directly to builders (e.g.launch(Job()) { }). UsesupervisorScope { }or a scope defined withSupervisorJob()for supervisor semantics. When running independent tasks withawaitAll, usesupervisorScopeinstead ofcoroutineScopeso one failure does not cancel sibling deferreds. - Cancellation handling (apply all):
- Never swallow
CancellationException; rethrow it in catch blocks. - Do not use
CancellationExceptionfor domain errors; use normal exceptions instead. - In long loops and repeating/polling work, add
yield(),ensureActive(), orwhile (isActive)withdelay(interval)so the coroutine responds to cancellation. - For suspend calls in
finally, usewithContext(NonCancellable) { }. - Do not reuse a scope after
scope.cancel(); usecoroutineContext.job.cancelChildren()to stop only children while keeping the scope alive. - Prefer
withTimeoutOrNulloverwithTimeoutto avoid unintentionally cancelling the parent scope. If usingwithTimeout, catchTimeoutCancellationExceptionexplicitly. Always ensure resources opened insidewithTimeoutare cleaned up infinally.
- Never swallow
- Exception handling:
- Uncaught exceptions in
launchpropagate toCoroutineExceptionHandler; inasync, the exception is stored in theDeferredand only thrown onawait(). Always callawait()onasyncblocks to avoid silently losing exceptions. - Use
CoroutineExceptionHandlerat scope level forlaunchuncaught exceptions.
- Uncaught exceptions in
- In tests use
kotlinx-coroutines-test:runTest, virtual time,advanceTimeBy,advanceUntilIdle, and injectTestDispatcher/StandardTestDispatcher; avoid realdelay()withrunBlocking. ReplaceDispatchers.MainusingDispatchers.setMain(TestDispatcher())in@BeforeandDispatchers.resetMain()in@After. - Prefer
produce { }for channels so they close when the coroutine ends. Do not shareconsumeEachacross multiple consumers; usefor (x in channel)per consumer. - Flow best practices:
- Keep
flow { }builder non-blocking; useflowOn(Dispatchers.IO)or suspend APIs. - Use
StateFlowfor shared UI state (replays last value); useSharedFlowfor events with explicitreplay,extraBufferCapacity, andonBufferOverflowconfiguration. - Use
collectLatestonly when cancelling in-progress work is intentional (e.g. search); usecollectwhen each item must be processed to completion. - On Android, collect flows with
repeatOnLifecycle(Lifecycle.State.STARTED)orflowWithLifecycleto stop collection when the UI goes to background.
- Keep
- When several practices apply (e.g. GlobalScope + wrong Dispatchers), use each relevant reference and combine the fixes in one optimized snippet.
What ships with it
59 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- references/ref-1-1-global-scope.md 1.2 KB
- references/ref-1-2-async-without-await.md 982 B
- references/ref-1-3-breaking-structured-concurrency.md 1.9 KB
- references/ref-1-4-awaitall-exception-propagation.md 1.6 KB
- references/ref-101-interop-suspend-cancellable.md 2.0 KB
- references/ref-102-interop-callbackflow-awaitclose.md 1.8 KB
- references/ref-103-interop-channelflow-callbackflow.md 1.4 KB
- references/ref-104-interop-future-get.md 1.2 KB
- references/ref-111-kmp-dispatchers-io.md 2.0 KB
- references/ref-112-kmp-runblocking.md 1.2 KB
- references/ref-113-kmp-mainscope-without-cancel.md 1.2 KB
- references/ref-121-concur-synchronized.md 1.3 KB
- references/ref-122-concur-shared-mutable-state.md 1.3 KB
- references/ref-131-backend-blocking.md 1.3 KB
- references/ref-141-debug-coroutine-name.md 1.1 KB
- references/ref-15-concur-sequential-async.md 1.8 KB
- references/ref-2-1-launch-last-line-coroutine-scope.md 1.2 KB
- references/ref-2-2-runblocking-in-suspend.md 1.2 KB
- references/ref-3-1-blocking-wrong-dispatchers.md 1.1 KB
- references/ref-3-2-dispatchers-unconfined.md 1.1 KB
- references/ref-3-2-main-safe-suspend.md 1.5 KB
- references/ref-3-3-job-context-builders.md 1.2 KB
- references/ref-3-5-inject-dispatchers.md 1.7 KB
- references/ref-36-concur-redundant-withcontext.md 1.3 KB
- references/ref-37-backend-mdc.md 1.3 KB
- references/ref-4-1-cancellation-intensive-loops.md 1.0 KB
- references/ref-4-2-periodic-repeating-work.md 1.6 KB
- references/ref-4-2-swallowing-cancellation-exception.md 1.1 KB
- references/ref-4-3-suspend-cleanup-noncancellable.md 1.0 KB
- references/ref-4-4-reusing-cancelled-scope.md 1.1 KB
- references/ref-4-6-withtimeout-scope-cancellation.md 1.7 KB
- references/ref-4-7-withtimeout-resource-cleanup.md 1.8 KB
- references/ref-5-1-supervisor-job-single-builder.md 1.3 KB
- references/ref-5-2-cancellation-exception-domain-errors.md 1.3 KB
- references/ref-5-3-exception-handler-async.md 1.9 KB
- references/ref-6-1-slow-tests-real-delays.md 1.1 KB
- references/ref-6-2-uncontrolled-fire-and-forget-tests.md 1.3 KB
- references/ref-6-3-setmain-resetmain.md 2.1 KB
- references/ref-64-test-runtest.md 1.5 KB
- references/ref-65-test-hardcoded-dispatcher.md 1.4 KB
- references/ref-66-test-not-completed.md 1.3 KB
- references/ref-7-1-channel-close.md 1.1 KB
- references/ref-7-2-consume-each-multiple-consumers.md 1.2 KB
- references/ref-8-2-lifecycle-aware-flow.md 2.2 KB
- references/ref-8-architecture-patterns.md 1.5 KB
- references/ref-83-compose-collect-lifecycle.md 1.6 KB
- references/ref-84-compose-remember-scope-init.md 1.3 KB
- references/ref-85-compose-side-effect.md 1.0 KB
- references/ref-9-1-flow-blocking-call.md 1.8 KB
- references/ref-9-2-cold-vs-hot-flows.md 2.3 KB
- references/ref-9-3-collect-latest.md 1.8 KB
- references/ref-9-4-shared-flow-configuration.md 2.3 KB
- references/ref-910-flow-flatmap-choice.md 1.2 KB
- references/ref-911-flow-oneshot-events.md 1.3 KB
- references/ref-95-flow-mutable-exposed.md 1.5 KB
- references/ref-96-flow-missing-catch.md 1.6 KB
- references/ref-97-flow-statein-eagerly.md 1.4 KB
- references/ref-98-flow-launchin-unstructured.md 1.1 KB
- references/ref-99-flow-sideeffect-map.md 1.1 KB
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 11d ago First seen · 318 lines · 71 tokens per session scan A 900338b0fca2
kotlin-coroutines-skill is a skill published in the GitHub repository santimattius/structured-coroutines (147 stars, last pushed today), licensed Apache-2.0. It adds 71 tokens to every session and 5,631 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
compose-animations
Use when writing or reviewing Jetpack Compose motion: visibility enter/exit, animating one property toward a target, color or size transitions, multiple properties from one state, switching composable content, or choosing between AnimatedVisibility, animateAsState, rememberTransition, AnimatedContent, and Crossfade.
compose-focus-navigation
Use when writing or reviewing Jetpack Compose UI for TV, keyboard, desktop, accessibility focus, D-pad navigation, FocusRequester, focusProperties, key events, or initial focus behavior.
kotlin-control-flow
Use when writing or reviewing Kotlin branching and control flow: when expressions, guard conditions, sealed type exhaustiveness, smart casts, nullable branching, early returns, or replacing complex if/else chains.
release-kotlin-library
Use when preparing, publishing, or checking readiness for a new Kotlin library version in a repository using gradle-maven-publish-plugin, including release changelog reconciliation, API snapshots, and publication verification.
using-chrisbanes-skills
Use when debugging, benchmarking, or profiling leads into Kotlin or Jetpack Compose source before the cause is known, or when one task spans multiple Kotlin or Compose concerns, especially plain Kotlin Flow or navigation delivery plus sealed branching.
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.