install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/rust-system-event-driven" ~/.claude/skills/comeonoliver-skillshub-rust-system-event-driven && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/rust-system-event-driven/SKILL.mdsource content
Rust System Event-Driven Best Practices
Comprehensive best practices guide for event-driven system programming in Rust. Contains 42 rules across 8 categories, prioritized by impact to guide async runtime usage, channel communication, threading, networking, and terminal handling.
When to Apply
Reference these guidelines when:
- Building async applications with Tokio or async-std
- Implementing network servers or clients
- Writing terminal user interfaces (TUIs)
- Managing concurrent tasks and shared state
- Handling Unix signals and graceful shutdown
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Async Runtime Patterns | CRITICAL | |
| 2 | Channel Communication | CRITICAL | |
| 3 | Threading & Synchronization | HIGH | |
| 4 | Socket & Network I/O | HIGH | |
| 5 | Terminal & TTY Handling | MEDIUM-HIGH | |
| 6 | Signal & Process Control | MEDIUM | |
| 7 | File I/O Streaming | MEDIUM | |
| 8 | Event Loop Architecture | LOW-MEDIUM | |
Quick Reference
1. Async Runtime Patterns (CRITICAL)
- Use spawn_blocking for CPU-bound workasync-spawn-blocking
- Use biased select for priority handlingasync-select-biased
- Avoid std blocking calls in async contextasync-no-std-block
- Design cancellation-safe async operationsasync-cancellation-safe
- Use task-local storage for request contextasync-task-local
- Use JoinSet for structured concurrencyasync-structured-concurrency
2. Channel Communication (CRITICAL)
- Use bounded channels for backpressurechan-bounded-backpressure
- Use oneshot channels for request-responsechan-oneshot-response
- Use broadcast channels for fan-outchan-broadcast-fanout
- Use watch channels for shared statechan-watch-state
- Use channel closure for graceful shutdownchan-graceful-shutdown
3. Threading & Synchronization (HIGH)
- Use Arc<Mutex> for shared mutable statesync-arc-mutex-shared
- Use RwLock for read-heavy workloadssync-rwlock-read-heavy
- Use atomics for simple counters and flagssync-atomic-counters
- Avoid holding std Mutex across awaitsync-avoid-lock-await
- Use Semaphore to limit concurrencysync-semaphore-limit
- Use parking_lot for high-contention lockssync-parking-lot
4. Socket & Network I/O (HIGH)
- Split sockets into reader and writer halvesnet-split-reader-writer
- Use framing for message-based protocolsnet-framing-codec
- Use connection pools for repeated connectionsnet-connection-pool
- Add timeouts to all network operationsnet-timeout-all-io
- Set TCP_NODELAY for low-latency protocolsnet-tcp-nodelay
- Implement graceful connection shutdownnet-graceful-disconnect
5. Terminal & TTY Handling (MEDIUM-HIGH)
- Always restore terminal state on exitterm-raw-mode-restore
- Use alternate screen for full-screen appsterm-alternate-screen
- Use async event stream for terminal inputterm-async-event-stream
- Buffer terminal output for performanceterm-buffered-output
- Handle terminal resize eventsterm-handle-resize
6. Signal & Process Control (MEDIUM)
- Handle Ctrl-C for graceful shutdownsig-ctrl-c-graceful
- Handle Unix signals asynchronouslysig-unix-signals
- Reap child processes to avoid zombiessig-child-reap
- Set shutdown timeout to force exitsig-timeout-shutdown
7. File I/O Streaming (MEDIUM)
- Use async file operations in async contextio-async-file-ops
- Stream large files instead of loading entirelyio-stream-large-files
- Use copy_bidirectional for proxyingio-copy-bidirectional
- Use pipes for process communicationio-pipe-communication
- Flush writes before expecting responsesio-flush-before-read
8. Event Loop Architecture (LOW-MEDIUM)
- Use actor pattern for stateful componentsloop-actor-model
- Use typed events over dynamic dispatchloop-event-types
- Model protocol state as type-safe state machineloop-state-machine
- Separate I/O from business logicloop-layered-architecture
- Use CancellationToken for coordinated shutdownloop-cancellation-token
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |