rust-concurrency
Skill1 starsChanged 41 days agoMITView on GitHub
Rust concurrency and async — threads vs async, Send/Sync, sharing with Arc/Mutex/RwLock, channels, tokio tasks, holding locks across await, and deadlocks. Use when parallelizing work, sharing state across threads, choosing threads vs async, or fixing Send/Sync errors and deadlocks. Triggers: tokio, Send/Sync, mpsc, deadlock, future is not Send, rayon, parking_lot.
10 other projects use a version of this.
Adopted by
Most recently taken up by
- rewrite-rs/skillstheir own version, first seen Nov 29, 2026
- sajaddp/sonjoo-seo-audittheir own version, first seen Nov 29, 2026
- inference-gateway/skillstheir own version, first seen Nov 23, 2026
- owenlamont/skillstheir own version, first seen Oct 20, 2026
- adxptived/Rust-Skillstheir own version, first seen Oct 17, 2026
- full-stack-skills/rust-skillstheir own version, first seen Oct 15, 2026
Used with
Projects with it also use rust-api-design.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
adxptivedSkillrust-api-design
Rust API Design guidelines, naming conventions, and best practices. Use when: - User is designing a library, crate, or public APIs - Implementing patterns like Builder, Typestate, or Extension traits - Designing public structures, enums, or traits - Working with common traits (From/Into, Default, AsRef, Debug, Clone) - Applying #[must_use] or #[non_exhaustive] attributes - Restricting trait implementation via Sealed Traits - Formatting naming structures and lifetime designs
Also in 3 projects that use this
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- huiali/rust-skills★ 47same name
- rewrite-rs/skills★ 32same name
- full-stack-skills/rust-skills★ 8same name
- botirkhaltaev/botir-skills★ 4same name
- inference-gateway/skills★ 3same name
- Lu1sDV/skillsmd★ 2same name
- adxptived/Rust-Skills★ 1same name
- owenlamont/skills★ 1same name
- sajaddp/sonjoo-seo-audit★ 1same name
- Dankosik/rust-cli-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- addressing-findingsSkill
- auditSkill
- codebase-onboardingSkill
- codex-reviewSkill
- compatibilitySkill
- debuggingSkill
- developSkill
- distributed-racesSkill
- memorySkill
- nix-dev-envSkill
- nix-flakesSkill
- nixosSkill
- nix-packagingSkill
- nix-reviewSkill
- refactoringSkill
- retroSkill
- review-initSkill
- review-rulesSkill
- rust-architecture-reviewSkill
- rust-architectureSkill
- rust-cliSkill
- rust-cloud-nativeSkill
- rust-ecosystemSkill
- rust-embeddedSkill
- rust-errorsSkill
- rust-fintechSkill
- rust-idiomsSkill
- rust-macrosSkill
- rust-mlSkill
- rust-navigationSkill
- rust-ownershipSkill
- rust-performanceSkill
- rust-pluginsSkill
- rust-reviewSkill
- rust-securitySkill
- rust-testingSkill
- rust-traitsSkill
- rust-unsafeSkill
- rust-webSkill
- specsSkill
- sql-reviewSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
Don't reach for async by default.
- Distinctive: line 41
Prefer message passing. "Share memory by communicating" — channels turn data races into ownership transfers the compiler already checks.
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Concurrency
Two questions decide everything: what kind of work (CPU vs I/O) and what's the sharing
model (messages vs shared memory). Get those right and the Send/Sync errors resolve
themselves. Mechanics in the sub-files.
When to Use
- Parallelizing work across threads, or running many I/O tasks concurrently
- Sharing state across threads (
Arc,Mutex,RwLock, channels) - Deciding between OS threads and async
- Fixing "cannot be sent between threads" / "future is not
Send" / deadlocks
Decision 1 — threads or async?
| Workload | Use | Why |
| CPU-bound (compute, parsing, hashing) | OS threads — std::thread, or rayon for data parallelism | real parallelism across cores; async gives you nothing here |
| I/O-bound (network, many sockets, DB) | async — tokio | thousands of cheap tasks, no thread-per-connection |
| Mixed | async runtime + spawn_blocking for the CPU/blocking parts | keep the executor unblocked |
Don't reach for async by default. If you have a handful of CPU tasks, threads are simpler and faster. Async earns its complexity at high I/O concurrency. Details: threads.md, async.md.
Decision 2 — how do threads share?
| Sharing | Use |
| Nothing — hand off ownership | channels (message passing) — the default, fewest footguns |
| Read-only shared data | Arc<T> |
| Shared mutable data | Arc<Mutex<T>> (or Arc<RwLock<T>> for read-heavy) |
| Simple counters/flags | atomics (AtomicUsize, AtomicBool) |
Prefer message passing. "Share memory by communicating" — channels turn data races into ownership transfers the compiler already checks.
Higher-level compositions — structured concurrency (JoinSet), cooperative cancellation
(CancellationToken), the actor pattern (own state in one task), graceful shutdown of a task
tree, and choosing watch/broadcast/DashMap — are in patterns.md.
Send and Sync
Two auto-traits the compiler derives; they're the whole basis of thread safety.
Send— a value can be moved to another thread. Almost everything is;Rcand raw pointers are not.Sync—&Tcan be shared across threads (equivalently:T: Sync⇔&T: Send).Mutex/RwLockareSync;RefCell/Cellare not.
The single-thread vs multi-thread pointer pairs:
Single thread (rust-ownership) | Across threads (here) |
Rc<T> (not Send/Sync) | Arc<T> (atomic count) |
RefCell<T> (not Sync) | Mutex<T> / RwLock<T> |
Error → fix
| Error | Cause | Fix |
E0277 Rc cannot be sent between threads | Rc/RefCell shared across threads | Rc→Arc, RefCell→Mutex; or pass via a channel |
E0277 future is not Send | a non-Send value (e.g. Rc, MutexGuard) is held across an .await | drop it before the await, or don't use a non-Send type (see async.md) |
| closure may outlive borrowed value (spawn) | thread closure borrows a local | move the data in, or use std::thread::scope (see threads.md) |
| deadlock (no error — it hangs) | locks acquired in inconsistent order, or a lock held across .await | consistent lock order; never hold a lock across .await |
Defects vs failures here
A poisoned Mutex (lock() returns Err because a holder panicked) is a defect, not a
domain failure — see the failures-vs-defects model in rust-errors. Don't model PoisonError
as a recoverable case; unwrap()/expect() the lock or propagate it as opaque.
Boundary
- Single-threaded sharing/mutation (
Rc,RefCell,Cell) →rust-ownership. - Timeouts and retry around concurrent I/O →
rust-errors(recovery).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

