Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
wshobson avatar

Rust Async Patterns

  • 16.3k installs
  • 38.3k repo stars
  • Updated July 22, 2026
  • wshobson/agents

Rust Async Patterns is a skill for production async/await programming with Tokio runtime, covering concurrency, error handling, and performance optimization.

About

Rust Async Patterns teaches production async/await programming with the Tokio runtime for building high-performance concurrent systems. It covers Tokio tasks, channels, streams, error propagation, JoinSet for managing multiple tasks, select! for racing futures, and proper cancellation token handling. Use this skill when building async Rust services, implementing concurrent I/O operations, or debugging async code issues. It emphasizes non-blocking operations, proper error handling with `?`, and best practices like avoiding locks across await points and handling graceful shutdown.

  • Tokio runtime patterns for async/await concurrency without blocking
  • Task management with JoinSet, channels, and select! for racing futures
  • Error handling, cancellation tokens, and graceful shutdown patterns

Rust Async Patterns by the numbers

  • 16,257 all-time installs (skills.sh)
  • +329 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #1 of 129 Rust skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

rust-async-patterns capabilities & compatibility

Use cases
api development
Runs
Runs locally
Pricing
Free
From the docs

What rust-async-patterns says it does

Production patterns for async Rust programming with Tokio runtime, including tasks, channels, streams, and error handling.
SKILL.md
npx skills add https://github.com/wshobson/agents --skill rust-async-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs16.3k
repo stars38.3k
Security audit3 / 3 scanners passed
Last updatedJuly 22, 2026
Repositorywshobson/agents

How do you write production async Rust with Tokio?

Rust Async Patterns teaches production async/await programming with the Tokio runtime for building high-performance concurrent systems. It covers Tokio tasks, channels, streams, error propagation, Jo

Who is it for?

Rust developers shipping concurrent network services or CLIs on Tokio who need idiomatic async patterns and deadlock avoidance guidance.

Skip if: Synchronous Rust-only scripts, embedded no_std targets without async runtime, or teams standardized on non-Rust stacks.

When should I use this skill?

User implements async Rust, debugs Tokio deadlocks, needs async-trait services, or asks about channels and JoinSet patterns.

What you get

Tokio-based async Rust modules with channel coordination, select loops, traced tasks, and cancellation-safe error handling.

  • async service implementation
  • concurrent task handling
  • proper error propagation

By the numbers

  • Documents 5 recommended Cargo dependencies for async Rust
  • Lists 5 async anti-patterns in the Don'ts section
  • Includes 5 core async abstraction concepts in a reference table

Files

SKILL.mdMarkdownGitHub ↗

Rust Async Patterns

Production patterns for async Rust programming with Tokio runtime, including tasks, channels, streams, and error handling.

When to Use This Skill

  • Building async Rust applications
  • Implementing concurrent network services
  • Using Tokio for async I/O
  • Handling async errors properly
  • Debugging async code issues
  • Optimizing async performance

Core Concepts

1. Async Execution Model

Future (lazy) → poll() → Ready(value) | Pending
                ↑           ↓
              Waker ← Runtime schedules

2. Key Abstractions

ConceptPurpose
FutureLazy computation that may complete later
async fnFunction returning impl Future
awaitSuspend until future completes
TaskSpawned future running concurrently
RuntimeExecutor that polls futures

Quick Start

# Cargo.toml
[dependencies]
tokio = { version = "1", features = ["full"] }
futures = "0.3"
async-trait = "0.1"
anyhow = "1.0"
tracing = "0.1"
tracing-subscriber = "0.3"
use tokio::time::{sleep, Duration};
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize tracing
    tracing_subscriber::fmt::init();

    // Async operations
    let result = fetch_data("https://api.example.com").await?;
    println!("Got: {}", result);

    Ok(())
}

async fn fetch_data(url: &str) -> Result<String> {
    // Simulated async operation
    sleep(Duration::from_millis(100)).await;
    Ok(format!("Data from {}", url))
}

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

Do's

  • Use `tokio::select!` - For racing futures
  • Prefer channels - Over shared state when possible
  • Use `JoinSet` - For managing multiple tasks
  • Instrument with tracing - For debugging async code
  • Handle cancellation - Check CancellationToken

Don'ts

  • Don't block - Never use std::thread::sleep in async
  • Don't hold locks across awaits - Causes deadlocks
  • Don't spawn unboundedly - Use semaphores for limits
  • Don't ignore errors - Propagate with ? or log
  • Don't forget Send bounds - For spawned futures

Related skills

How it compares

Pick rust-async-patterns for Tokio service implementation; use general Rust skills when the task is sync CLI tooling without an async runtime.

FAQ

What should I use instead of sleep in async code?

Use tokio::time::sleep(Duration) which is async-aware and doesn't block the executor, unlike std::thread::sleep which blocks everything.

How do I manage multiple concurrent tasks?

Use JoinSet to spawn and manage multiple tasks, then iterate through results. Use select! to race futures and respond to the first completion.

Is Rust Async Patterns safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Rustbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.