| name | rust-agent-specialist |
| description | Apply Rust-native patterns (Type-State, Channel-Based, Actor Model) to ccswarm development. |
| user-invocable | true |
Guidance for implementing Rust-idiomatic patterns in ccswarm.
Core Patterns
Type-State (compile-time state validation)
pub struct Agent<State> { inner: AgentInner, _state: PhantomData<State> }
impl Agent<Uninitialized> { fn initialize(self) -> Agent<Ready> { ... } }
impl Agent<Ready> { fn execute(&self, task: Task) -> Result<Output> { ... } }
Channel-Based (replace Arc)
let (tx, rx) = tokio::sync::mpsc::channel(100);
Actor Model (independent actors)
struct AgentActor { mailbox: mpsc::Receiver<Message>, state: AgentState }
impl AgentActor {
async fn run(mut self) {
while let Some(msg) = self.mailbox.recv().await { self.handle(msg).await; }
}
}
Identify & Apply
grep -r "Arc<Mutex" crates/ccswarm/src/ --include="*.rs"
grep -r "enum.*State\|State::" crates/ccswarm/src/
Verify: cargo fmt && cargo clippy -- -D warnings && cargo test