rust-async-concurrency
БесплатноБез исполняемых скриптовНе проверенUse when writing async Rust — spawning tasks, sharing state across tasks/threads, choosing channels vs mutexes, or hitting Send-bound errors with async…
от Fusengine★ 36 звёзд на GitHubОб этом скилле
It also covers the async-fn-in-traits Send problem — why async fn in traits does not give
Send futures by default and how to work around it.
Out of scope: HTTP service structure (routing, extractors, middleware) is owned by rust-web-backend; sync-only ownership and borrowing questions belong to rust-core-language.
Rust Async & Concurrency
Agent Workflow (MANDATORY)
Before writing async code, spawn in parallel:
- fuse-ai-pilot:explore-codebase — find the existing runtime, channel, and lock patterns already in use
- fuse-ai-pilot:research-expert — verify current tokio/crate APIs via Context7/Exa (async APIs churn)
- mcp__context7__query-docs — pull exact signatures for the primitives you touch
After writing, run fuse-ai-pilot:sniper.
Runtime Landscape
| Runtime | Reality |
|---|---|
| tokio | The de-facto standard. Almost every async crate (axum, sqlx, reqwest, tonic) targets it. Default choice. |
| async-std | Niche, effectively in maintenance mode. Do not pick for new work. |
| smol | Niche, small/embeddable. Only for constrained or embedded contexts. |
Default to tokio unless a hard constraint says otherwise.
Critical Rules
std::sync::Mutexfirst — it is faster. Reach fortokio::sync::MutexONLY when the guard must be held across an.await. Otherwise scope the guard so its destructor runs before the await.Arc<Mutex<T>>is not the default — analyze contention first. Read-dominated →RwLock; a simple counter → atomics; work that is itself async → a task + message passing.- Never drop a
JoinHandleyou care about — a droppedtokio::spawnhandle silently swallows the task's panic/error..awaitit, or useJoinSet/tracingto surface failures. spawn_blockingfor heavy sync work — CPU-bound loops or blocking I/O (std file, blocking DB driver) starve the runtime if run on an async worker. Offload them.Sendacross.await— everything held across an await point must beSendfortokio::spawn. Astd::sync::MutexGuardis NOTSend; holding one across an await is a compile error (and async-mutex guards that areSenddeadlock instead).
Reference Guide
Concepts
| Topic | Reference | When to Consult |
|---|---|---|
| Runtime & tasks | runtime-and-tasks.md | spawn, JoinHandle, JoinSet, spawn_blocking, 'static bound |
| Shared state | shared-state.md | Choosing Mutex vs RwLock vs atomics vs actor task |
| Channels | channels.md | Picking mpsc / oneshot / broadcast / watch |
| Async traits | async-traits.md | async fn in traits + the Send-bound problem |
Templates
| Template | When to Use |
|---|---|
| task-patterns.md | Concurrent tasks, JoinSet, actor pattern, spawn_blocking |
| graceful-shutdown.md | Cancellation, shutdown signal, draining tasks |
Quick Reference
Scope the guard, don't hold it across .await
// GOOD: lock released before the await
{
let mut db = state.lock().unwrap();
db.insert(key, value);
} // guard dropped here
do_async_work().await;
→ See shared-state.md
Pick the channel by shape
// one value back to a caller → oneshot
// many producers, one consumer → mpsc
// fan-out same value to all → broadcast
// latest-value-only state → watch
→ See channels.md
Best Practices
DO
- Measure contention before choosing a lock; prefer the cheapest primitive that fits.
- Surface task failures:
.awaithandles, or collect them withJoinSet. - Move heavy synchronous work to
spawn_blocking.
DON'T
- Reach for
tokio::sync::Mutexby reflex — it wraps a sync mutex internally and rarely helps throughput. - Fire-and-forget a
tokio::spawnwhose result or panic matters. - Assume
async fnin traits gives youSendfutures — it does not (see async-traits.md).
Sources (verified)
- tokio.rs/tokio/tutorial — shared-state, spawning, channels (fetched 2026-07-05)
- rust-lang.github.io/async-fundamentals-initiative/roadmap.html — AFIT status
- crates.io — tokio 1.54.1 (current at fetch 2026-11-08)
Установить rust-async-concurrency в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл rust-async-concurrency?
Use when writing async Rust — spawning tasks, sharing state across tasks/threads, choosing channels vs mutexes, or hitting Send-bound errors with async traits. Not for HTTP service structure (rust-web-backend) or sync-only ownership (rust-core-language).
Как установить скилл rust-async-concurrency?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rust-async-concurrency запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic