Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Design and review Rust async code around task ownership, suspension points, cancellation, blocking work, and runtime boundaries. Use when writing, refactoring, or reviewing futures, async functions, Tokio tasks, spawn, JoinHandle, Send futures, async traits, cancellation, or mutexes across await points.
.claude/skills/hashgraph-online-rust-async-task-design/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | 10% | 0% |
| case-10 | ✓→✓ | = Same ✓ | 7% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 22% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 13% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 19% | 0% |
Use this skill to make Rust async code explicit about task ownership, suspension points, blocking work, and cancellation. Async is a concurrency model, not a default replacement for threads or a performance guarantee.
stream, background task, or trait method.
.await as a possible suspension point. Check what state is heldacross it.
tokio::spawn(async move { ... }) only when the task can own everythingit needs and its future is Send + 'static on the selected runtime.
JoinHandles when task success, panic, cancellation, or shutdownmatters. Do not silently detach important work.
spawn_blocking, Rayon, or dedicated threads as the workload requires.
MutexGuard, RefCell borrow, or non-Send valueacross .await.
when those outcomes affect behavior.
Read references/async-runtime-patterns.md when reviewing task spawning, shared state in async code, or blocking work.
std::sync::Mutex in async code only for short, low-contention criticalsections that do not cross .await.
tokio::sync::Mutex when a lock must be held across .await, but firstconsider moving the state behind a task and interacting by messages.
spawn_blocking for blocking operations that eventually finish. Limitparallelism for CPU-heavy work; Tokio's blocking pool can grow large.
tokio::time::timeout or explicit cancellation tokens for boundedoperations.
select! carefully: dropping a future can cancel it. Check cancellationsafety before using it around IO or partially completed work.
async fn in traits is fine for private traits and static dispatchwhen callers do not need to add bounds to the returned future.
Send futures should usually spell the method asfn name(...) -> impl Future<Output = T> + Send or use trait-variant to offer local and Send variants.
future return type, such as Pin<Box<dyn Future<Output = T> + Send + '_>>. Use async-trait as an ergonomics layer only when the dependency and allocation tradeoff are acceptable.
intentionally runtime-specific.
.await accidentally.async move.JoinHandles are awaited, monitored, or aborted on shutdown.JoinError or timeout noise.Other measured skills in the registry, with their headline benchmark lift.