Expert knowledge for building event-driven systems with Composable Rust framework.
Use when implementing reducers, designing state machines, working with effects, creating environment traits for dependency injection, building stores, or answering questions about core architectural patterns and the unidirectional data flow model.
Similar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Claude CodeNot declared
CursorNot declared
CodexNot declared
GitHub CopilotNot declared
WindsurfNot declared
Gemini CLINot declared
ClineNot declared
OpenCodeNot declared
Package contents
Files included with this skill beyond the listing page.
skill mdSKILL.md21,133 B
docsSUMMARY.md366 B
History
First seen on skills.sh
First recorded snapshot · 1 installs
SKILL.md
Composable Rust Architecture Expert
Expert knowledge for building event-driven systems using the Composable Rust framework - core architectural patterns, reducer design, effect composition, and the unidirectional data flow model.
When to Use This Skill
Automatically apply when:
Implementing reducers or state machines
Designing action types or state transitions
Working with effects or the effect system
Creating environment traits for dependency injection
Building stores or runtime components
Questions about architecture or design patterns
Core Architecture Fundamentals
The Five Types
Every Composable Rust application is built on these five fundamental types:
State: Domain state for a feature (Clone-able, owned data)
Action: Unified type for all inputs (commands, events, cross-aggregate events)
Reducer: Pure function (State, Action, Environment) → (State, Effects)
Effect: Side effect descriptions (values, not execution)
Environment: Injected dependencies via traits
These compose together to create a complete system.
The Feedback Loop (Critical Concept)
Actions flow through the system in a self-sustaining cycle:
External Input → Action
↓
Reducer: (State, Action, Env) → (New State, Effects)
↓
Store executes Effects
↓
Effects produce new Actions:
- Effect::Future returns 0 or 1 action
- Effect::Stream yields 0..N actions over time
↓
Loop back to Reducer
Key Insight: Everything is an Action. Commands are Actions. Events are Actions. External events are Actions. This creates a unified data flow where the reducer is the single source of state transitions.
// Merge multiple effects into one
let effects = vec![effect1, effect2, effect3];
let merged = Effect::merge(effects); // Returns Effect::Parallel
// Chain effects sequentially
let chained = effect1.then(effect2); // Returns Effect::Sequential
Developer Experience: Macros & Helpers
Derive Macros (Reduce Boilerplate)
#[derive(State)] - Version Tracking
Auto-generates version tracking methods for event-sourced state:
use composable_rust_macros::State;
use composable_rust_core::stream::Version;
#[derive(State, Clone, Debug)]
pub struct OrderState {
pub order_id: Option<String>,
pub items: Vec<Item>,
#[version] // Mark version field
pub version: Option<Version>,
}
// Auto-generated methods:
state.version(); // Get version
state.set_version(v); // Set version
Use when: Implementing event-sourced aggregates with optimistic concurrency.
#[derive(Action)] - Command/Event Helpers
Auto-generates type-safe helpers for distinguishing commands vs events:
pub struct LoggingDatabase<D> { inner: D }
pub struct MetricsDatabase<D> { inner: D }
Pattern: Use static dispatch (generics), not dynamic dispatch (trait objects), for zero-cost abstractions.
Store Pattern (Runtime Coordination)
Store Responsibilities
Hold current state
Execute reducer on incoming actions
Execute effects returned by reducer
Feed effect results back as new actions (feedback loop)
Store Usage Pattern
// Create store
let environment = OrderEnvironment {
database: PostgresDatabase::new(pool),
clock: SystemClock,
http_client: ReqwestClient::new(),
};
let store = Store::new(
OrderState::default(),
OrderReducer,
environment,
);
// Send action
let action = OrderAction::PlaceOrder {
customer_id: "cust-123".to_string(),
items: vec![item1, item2],
};
store.send(action).await;
// Get current state
let state = store.state().await;
Request-Response Pattern
For actions that need to wait for a result:
// Send action and wait for specific response
let result = store
.send_and_wait_for(
OrderAction::PlaceOrder { ... },
|action| matches!(action, OrderAction::OrderPlaced { .. }),
Duration::from_secs(5),
)
.await?;
Critical Architectural Patterns
Pattern 1: Effect-as-Value (NEVER Execute in Reducers)
❌ Anti-Pattern 2: Complex Logic in Effect Execution
// Effect execution should be simple dispatch
Effect::Database(op) => {
// ❌ Don't put business logic here
if should_retry && attempt < 3 {
// Complex retry logic in executor
}
}
Solution: Encode retry logic as actions/effects in the reducer.
❌ Anti-Pattern 3: Nested State Machines Without Composition
// ❌ Giant monolithic reducer
fn reduce(...) {
match (state.order_status, state.payment_status, state.shipping_status) {
// 100s of match arms
}
}
Solution: Use reducer composition (see saga patterns skill).
❌ Anti-Pattern 4: Ignoring the Feedback Loop
use composable_rust_core::async_effect;
// ❌ Not returning actions from effects
async_effect! {
database.save(&data).await?;
None // ❌ Missing feedback!
}
Solution: Return actions from futures to feed back into the system.
Composition Patterns
Combining Reducers
// Combine two reducers that operate on the same state
let combined = combine_reducers(reducer1, reducer2);
// Scope a reducer to a sub-state
let scoped = scope_reducer(
child_reducer,
|parent_state| &mut parent_state.child,
|child_action| ParentAction::Child(child_action),
);
Effect Composition
// Parallel execution
let parallel = Effect::Parallel(vec![
effect1,
effect2,
effect3,
]);
// Sequential execution
let sequential = Effect::Sequential(vec![
effect1, // Executes first
effect2, // Then this
effect3, // Finally this
]);
// Nested composition
let complex = Effect::Parallel(vec![
Effect::Sequential(vec![step1, step2]),
Effect::Sequential(vec![step3, step4]),
]);
Remember: The architecture is simple but powerful. State + Action + Reducer → (New State, Effects). The Store coordinates the feedback loop. Everything else builds on this foundation.