Master Rust async programming with Tokio, async traits

Rust async patterns

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

Rust async patterns cover

Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code.

---
name: rust-async-patterns
description: Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code.
---

# 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

Overview

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

Manual install (npx, ZIP)
Claude Codenpx skills add wshobson/agents --skill rust-async-patterns -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \ | tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/systems-programming/skills/rust-async-patterns
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/e8017f5ed5fe4554e65b/rust-async-patterns.zip" -OutFile "$env:TEMP\rust-async-patterns.zip"; Expand-Archive "$env:TEMP\rust-async-patterns.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md2.6 KB
  • references/1 file · 9.7 KB
Read the files here
wshobson/4236bb92 files
SKILL.md
Show the full text96 lines

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
Concept Purpose
Future Lazy computation that may complete later
async fn Function returning impl Future
await Suspend until future completes
Task Spawned future running concurrently
Runtime Executor 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
1---
2name: rust-async-patterns
3description: Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code.
4---
5 
6# Rust Async Patterns
7 
8Production patterns for async Rust programming with Tokio runtime, including tasks, channels, streams, and error handling.
9 
10## When to Use This Skill
11 
12- Building async Rust applications
13- Implementing concurrent network services
14- Using Tokio for async I/O
15- Handling async errors properly
16- Debugging async code issues
17- Optimizing async performance
18 
19## Core Concepts
20 
21### 1. Async Execution Model
22 
23```
24Future (lazy) → poll() → Ready(value) | Pending
25 ↑ ↓
26 Waker ← Runtime schedules
27```
28 
29### 2. Key Abstractions
30 
31| Concept | Purpose |
32| ---------- | ---------------------------------------- |
33| `Future` | Lazy computation that may complete later |
34| `async fn` | Function returning impl Future |
35| `await` | Suspend until future completes |
36| `Task` | Spawned future running concurrently |
37| `Runtime` | Executor that polls futures |
38 
39## Quick Start
40 
41```toml
42# Cargo.toml
43[dependencies]
44tokio = { version = "1", features = ["full"] }
45futures = "0.3"
46async-trait = "0.1"
47anyhow = "1.0"
48tracing = "0.1"
49tracing-subscriber = "0.3"
50```
51 
52```rust
53use tokio::time::{sleep, Duration};
54use anyhow::Result;
55 
56#[tokio::main]
57async fn main() -> Result<()> {
58 // Initialize tracing
59 tracing_subscriber::fmt::init();
60 
61 // Async operations
62 let result = fetch_data("https://api.example.com").await?;
63 println!("Got: {}", result);
64 
65 Ok(())
66}
67 
68async fn fetch_data(url: &str) -> Result<String> {
69 // Simulated async operation
70 sleep(Duration::from_millis(100)).await;
71 Ok(format!("Data from {}", url))
72}
73```
74 
75## Detailed patterns and worked examples
76 
77Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
78 
79## Best Practices
80 
81### Do's
82 
83- **Use `tokio::select!`** - For racing futures
84- **Prefer channels** - Over shared state when possible
85- **Use `JoinSet`** - For managing multiple tasks
86- **Instrument with tracing** - For debugging async code
87- **Handle cancellation** - Check `CancellationToken`
88 
89### Don'ts
90 
91- **Don't block** - Never use `std::thread::sleep` in async
92- **Don't hold locks across awaits** - Causes deadlocks
93- **Don't spawn unboundedly** - Use semaphores for limits
94- **Don't ignore errors** - Propagate with `?` or log
95- **Don't forget Send bounds** - For spawned futures
96 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
SkillA task is too large for one model passAdvisor orchestrator workerShubhamsaboo/awesome-llm-apps · by ShubhamsabooUse when a task is too large for one model pass, needs parallel research or generation across many subtasks (like researching a dozen competitors at once), or the user asks to orchestrate multiple models, split work across a model team, run an advisor-worker loop, have a stronger model review the plan while cheap workers execute, or says "too big for one model" or "fan this out". Not for single-file edits or tasks one model handles in one pass.★ 139k GitHub starsSkillRun the CCS Align seat's hourly breathing cycleCCS Align — Worker Watch seat (Phases 0–2 shipped; Phase 3 = verify / sign-off)thedotmack/claude-mem · by thedotmackRun the CCS Align seat's hourly breathing cycle — prove the local claude-mem worker is healthy, pull needle observations through search → timeline → get_observations, land them in a seat-owned middle cache via atomic grab → append → filter exclude-marks → replace, manage exclude marks, and walk house → project → seat rules to detect conflicts (SHADOW_HOUSE, DENY_ALLOW, DRIFT, CLOCK_HEADER) with an append-only rules-report.md. Use when asked to run CCS Align, breathe the alignment seat, refresh the middle cache, exclude or restore an observation, walk rules, check rules conflicts, or check the Worker Watch board.★ 95.6k GitHub starsSkillSummarize and review what changed while you were awayCatchup — Async-Team Return Briefingoliver-kriska/claude-elixir-phoenix · by oliver-kriskaSummarize and review what changed while you were away. Use after a weekend, vacation, or flight to check missed PRs, git commits, Linear tickets, and meetings — one prioritized brief, not a firehose.★ 560 GitHub starsSkillMaster Python asyncio, concurrent programmingAsync python patternswshobson/agents · by wshobsonMaster Python asyncio, concurrent programming, and async/await patterns for high-performance applications. Use when building async APIs, concurrent systems, or I/O-bound applications requiring non-blocking operations.★ 39.9k GitHub starsSkillMaster Go concurrency with goroutines, channelsGo concurrency patternswshobson/agents · by wshobsonMaster Go concurrency with goroutines, channels, sync primitives, and context. Use when building concurrent Go applications, implementing worker pools, or debugging race conditions.★ 39.9k GitHub starsSkillDesign microservices architectures with service boundariesMicroservices patternswshobson/agents · by wshobsonDesign microservices architectures with service boundaries, event-driven communication, and resilience patterns. Use when building distributed systems, decomposing monoliths, or implementing microservices.★ 39.9k GitHub stars

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patternswshobson/agents · by wshobsonBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.★ 39.9k GitHub stars