smol-rust

Applies smol async runtime conventions when writing or reviewing async Rust code.

2|Updated May 16, 2026
One-click install
npx skills add https://github.com/avbel/ai-skills --skill smol-rust-avbel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: smol-rust
Source: https://github.com/avbel/ai-skills/tree/main/skills/smol-rust
Command: npx skills add https://github.com/avbel/ai-skills --skill smol-rust-avbel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing async Rust with the smol runtime involves subtle rules—dropping a Task cancels it, the global executor defaults to one worker thread, and tokio-based libraries panic without a runtime context. This Skill encodes those conventions so generated or reviewed smol code avoids deadlocks, silent task cancellation, and reactor conflicts. ## Core Features & Use Cases - Core API guidance: Covers block_on, spawn, Task detach semantics, Executor/LocalExecutor, Timer, Async<T> I/O adapters, and unblock/Unblock for offloading blocking work. - Ecosystem interop: Explains how to run tokio-based crates like reqwest or tonic under smol using async-compat, and when to prefer futures-lite over the full futures crate. - Antipattern detection: Flags common mistakes such as calling block_on inside a task, holding std::sync::Mutex across .await, or expecting multi-core throughput without setting SMOL_THREADS. - Use Case: When building a small CLI that fetches HTTP resources with reqwest, the Skill directs you to wrap the reqwest future in async_compat::Compat and drive it with smol::block_on instead of pulling in the full tokio runtime. ## Quick Start Ask the agent to write a smol-based async TCP client in Rust that connects to a server, sends a request, and prints the response to stdout.

Frequently Asked Questions about smol-rust

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

FAQPage Schema
How do I run async Rust code with the smol runtime?▼

Call smol::block_on(future) from main to drive a future to completion; smol needs no #[main] macro. Use smol::spawn for concurrent tasks and .await or .detach() the returned Task handles.

smol vs tokio: which async runtime should I use in Rust?▼

Choose smol for small binaries, fast compiles, and composable executors; choose tokio for its ecosystem (axum, tonic, sqlx) and work-stealing scheduler. They interoperate via the async-compat crate when you need tokio-based libraries under smol.

Can I use reqwest or other tokio libraries with smol?▼

Yes, wrap the future that touches tokio types in async_compat::Compat::new(...) and run it under smol::block_on. Without this wrapper, tokio-based crates panic with a missing reactor error.

Why does my smol task never run to completion?▼

Dropping a smol Task cancels it, so spawned work silently stops if the handle is discarded. Await the Task or call .detach(), and ensure main does not return before spawned tasks finish.

How do I get multi-threaded execution with smol?▼

The global executor defaults to one worker thread. Set the SMOL_THREADS environment variable for multi-core throughput, or build a multi-threaded Executor and run it on several threads, as shown in the smol-macros crate.