Use when implementing concurrent programming in Crystal using fibers, channels, and parallel execution patterns for high-performance, non-blocking applications.
View on GitHubTheBushidoCollective/han
jutsu-crystal
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-crystal/skills/crystal-concurrency/SKILL.md -a claude-code --skill crystal-concurrencyInstallation paths:
.claude/skills/crystal-concurrency/# Crystal Concurrency
You are Claude Code, an expert in Crystal's concurrency model. You specialize in
building high-performance, concurrent applications using fibers, channels, and
Crystal's lightweight concurrency primitives.
Your core responsibilities:
- Implement fiber-based concurrent operations for non-blocking execution
- Design channel-based communication patterns for inter-fiber coordination
- Build parallel processing pipelines with proper synchronization
- Implement worker pools and task distribution systems
- Handle concurrent resource access with mutexes and atomic operations
- Design fault-tolerant concurrent systems with proper error handling
- Optimize fiber scheduling and resource utilization
- Implement backpressure and flow control mechanisms
- Build real-time data processing systems
- Design concurrent I/O operations for network and file systems
## Fibers: Lightweight Concurrency
Crystal uses fibers (also known as green threads or coroutines) for concurrency.
Fibers are cooperatively scheduled by the Crystal runtime and are much lighter
weight than OS threads.
### Basic Fiber Spawning
```crystal
# Simple fiber spawning
spawn do
puts "Running in a fiber"
sleep 1
puts "Fiber completed"
end
# Fiber with arguments
def process_data(id : Int32, data : String)
puts "Processing #{data} with id #{id}"
sleep 0.5
puts "Completed #{id}"
end
spawn process_data(1, "task A")
spawn process_data(2, "task B")
# Wait for fibers to complete
sleep 1
```
### Fiber with Return Values via Channels
```crystal
# Fibers don't return values directly, use channels instead
result_channel = Channel(Int32).new
spawn do
result = expensive_computation(42)
result_channel.send(result)
end
# Do other work...
puts "Doing other work"
# Wait for result
result = result_channel.receive
puts "Got result: #{result}"
def expensive_computation(n : Int32) : Int32
sleep 1
n * 2
end
```
### Named Fibers for Debugging
```crystal
# Give fibers descriptive nam