--- 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) ```rust pub struct Agent { inner: AgentInner, _state: PhantomData } impl Agent { fn initialize(self) -> Agent { ... } } impl Agent { fn execute(&self, task: Task) -> Result { ... } } ``` ### Channel-Based (replace Arc) ```rust let (tx, rx) = tokio::sync::mpsc::channel(100); // No shared mutable state between agents ``` ### Actor Model (independent actors) ```rust struct AgentActor { mailbox: mpsc::Receiver, state: AgentState } impl AgentActor { async fn run(mut self) { while let Some(msg) = self.mailbox.recv().await { self.handle(msg).await; } } } ``` ## Identify & Apply ```bash grep -r "Arc