sd-rust-async

Guides writing and debugging async and multithreaded Rust code with correct task, lock, and cancellation discipline.

Updated Jun 26, 2026
One-click install
npx skills add https://github.com/platypeeps/sd-ai-command-pack --skill sd-rust-async-platypeeps
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sd-rust-async
Source: https://github.com/platypeeps/sd-ai-command-pack/tree/main/contrib/sd-rust-async
Command: npx skills add https://github.com/platypeeps/sd-ai-command-pack --skill sd-rust-async-platypeeps

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Async Rust defects — blocked executors, detached tasks, locks held across await points, and cancellation-unsafe state — are invisible to the compiler and to happy-path tests. This Skill provides a structured discipline for writing, restructuring, and debugging async and multithreaded Rust so these failure modes are caught by design rather than in production. ## Core Features & Use Cases - Blocking audit and routing: Detects blocking work inside async code and routes it correctly — synchronous I/O to spawn_blocking, CPU-bound work to a rayon compute pool, long-lived blocking loops to dedicated threads. - Send/'static and spawn hygiene: Resolves Send and 'static bound errors structurally, and ensures every spawned task has an owner with a join or abort path at shutdown. - Cancellation-safety review: Walks every .await point to verify shared state is never left half-mutated when futures are dropped by races, timeouts, or shutdown. - Use Case: You hit a "future cannot be sent between threads safely" error when spawning a task that holds an Rc across an await. The Skill guides you to scope the non-Send value so it drops before the await, or switch shared state to Arc and std::sync::Mutex. ## Quick Start Ask the AI to review your async Rust function for blocking calls, Send bound issues, lock-across-await problems, and cancellation safety using the sd-rust-async skill.

Frequently Asked Questions about sd-rust-async

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix 'future cannot be sent between threads safely' in Rust?▼

The error means non-Send data is held across an .await inside a spawned future. Scope values like Rc or RefCell so they drop before the .await, and use Arc with std::sync::Mutex for shared state instead.

How to handle blocking code inside async Rust functions?▼

Route blocking work by kind: synchronous I/O goes to the runtime's blocking pool via spawn_blocking, sustained CPU-bound computation to a rayon pool with a oneshot channel, and long-lived blocking loops to a dedicated std::thread.

std::sync::Mutex vs tokio Mutex — which should I use in async code?▼

Default to std::sync::Mutex: lock, operate, and drop the guard before the next .await. Use the async mutex only when the guard genuinely must span an .await, since it is slower and harder to reason about.

Why does dropping a JoinHandle not stop a Tokio task?▼

Dropping a JoinHandle detaches the task rather than stopping it, so it keeps running unsupervised and swallows its own panics. Hold the handle or collect tasks into a set that is joined or aborted at shutdown.

When should I not use this async Rust guidance?▼

Do not use it for domain type design, which belongs to sd-rust-design, or for general Rust idioms covered by sd-rust-quality. It also carries no review verdict; the sd-review lane owns review outcomes.