rust-async-patterns — Claude Code skill: async Rust
A skill for building and debugging async Rust with Tokio, tasks, channels, streams, and error handling. Use it for concurrent services and async I/O.
/plugin marketplace add wshobson/agents
/plugin install systems-programming@claude-code-workflowsWhat rust-async-patterns does
rust-async-patterns gives guidance for async Rust with Tokio. It covers the Future model, async fn, await, spawned tasks, and the runtime, then applies those ideas to channels, streams, and concurrent operations. It fits async applications, network services, and debugging work.
The starter setup uses tokio, futures, async-trait, anyhow, tracing, and tracing-subscriber in Cargo.toml. The skill also discusses tokio::select!, JoinSet, CancellationToken, semaphore limits, error propagation, and avoiding locks across await points. More worked patterns are in references/details.md.
Install it when your project uses Tokio or you need a clear way to reason about concurrent Rust. It is a poor fit for a purely synchronous Rust codebase.
What it helps with
- set up a Tokio async application
- reason about futures, await, and spawned tasks
- coordinate work through channels
- handle errors in concurrent Rust code
- trace cancellation and blocking issues
Example prompts for the agent
- Review this async Rust service and find locks held across await points.
- Show how to replace shared state with channels and manage tasks with JoinSet.
- Check error propagation and cancellation in this Tokio code.
How to install rust-async-patterns
1Plugin marketplace
/plugin marketplace add wshobson/agents/plugin install systems-programming@claude-code-workflowsThis installs the whole systems-programming plugin with all its skills
2Skills CLI (Vercel)
npx skills add wshobson/agents --skill rust-async-patterns -a claude-code3Manually: put the files in place
~/.claude/skills/rust-async-patterns/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/rust-async-patterns/
1Skills CLI (Vercel)
npx skills add wshobson/agents --skill rust-async-patterns -a codex2Manually: put the files in place
.agents/skills/rust-async-patterns/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add wshobson/agents --skill rust-async-patterns -a cursor2Manually: put the files in place
.cursor/skills/rust-async-patterns/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install wshobson/agents rust-async-patterns2Manually: put the files in place
.github/skills/rust-async-patterns/SKILL.mdPlatform CLI
gemini skills install https://github.com/wshobson/agents --path plugins/systems-programming/skills/rust-async-patternsManually: put the files in place
.devin/skills/rust-async-patterns/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set213
The whole set →Similar
Questions about rust-async-patterns
How do I install rust-async-patterns in Claude Code?
Run npx skills add wshobson/agents --skill rust-async-patterns -a claude-code. The skill is placed at ~/.claude/skills/rust-async-patterns/SKILL.md.
What does rust-async-patterns do?
It guides async Rust development with Tokio, including tasks, channels, streams, error handling, cancellation, and debugging patterns.
What dependencies do the rust-async-patterns examples use?
The starter Cargo.toml includes tokio, futures, async-trait, anyhow, tracing, and tracing-subscriber.
Source text
SKILL.md · MIT
---
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
## 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
```toml
# 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"
```
```rust
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
© Seth Hobson · MIT · wshobson/agents