router-first-architecture
npx machina-cli add skill parcadei/Continuous-Claude-v3/router-first-architecture --openclawRouter-First Architecture
Route through domain routers before using individual tools. Routers abstract tool selection.
Pattern
Domain routers (like math-router) provide deterministic mapping from user intent to exact CLI commands. Always use the router first; only bypass for edge cases.
DO
- Call
math-router route "<intent>"before any math operation - Let domain skills co-activate with their router (via
coActivatein skill-rules.json) - Trust the router's confidence score; only fall back if
command: null - Keep trigger keywords/patterns in skill-rules.json broader than routing patterns
DON'T
- Call individual scripts directly when a router exists
- Duplicate routing logic in individual skills
- Let domain skills bypass their router
Co-Activation Pattern
Domain skills should co-activate with their router:
{
"math/abstract-algebra/groups": {
"coActivate": ["math-router"],
"coActivateMode": "always"
}
}
This ensures the router is always available when domain knowledge is activated.
Two-Layer Architecture
- Skill-rules trigger layer: Nudges Claude to use the router (keywords, intent patterns)
- Router routing layer: Deterministic mapping to scripts via regex patterns
Keep the trigger layer broader than routing - the router should handle "not found" gracefully.
Source Sessions
- 2bbc8d6e: "Trigger layer was narrower than routing layer" - expanded triggers
- This session: Wired 8 domain math skills to co-activate with math-router
Source
git clone https://github.com/parcadei/Continuous-Claude-v3/blob/main/.claude/skills/router-first-architecture/SKILL.mdView on GitHub Overview
Router-First Architecture routes user intent through domain routers before invoking individual tools. Routers provide deterministic mappings from intent to exact CLI commands, ensuring consistent, explainable tool selection. The pattern uses a two-layer setup: a trigger layer to nudge routing and a router layer to perform the mapping, with co-activation to keep routers available.
How This Skill Works
Before any math operation, call the domain router (e.g., math-router) with the intent via route. The router returns a command and a confidence score; if a command is provided, execute it. If command is null, fall back to edge-case handling. Domain skills co-activate with their router (via coActivate in skill-rules.json), ensuring the router is always available.
When to Use It
- You have a clear intent that maps to a specific CLI command via a domain router (e.g., math-router).
- Starting a math operation in a session where multiple tools could be applicable and you want deterministic routing.
- Coordinating routing across several domain skills in a multi-skill workflow.
- Avoiding duplication of routing logic by delegating to the router instead of in-skill routing.
- When the router has a valid command returned (not null) and should govern execution; edge cases require bypass.
Quick Start
- Step 1: Call the router before any math operation using math-router route \"<intent>\"
- Step 2: Ensure domain skills co-activate with their router via coActivate in skill-rules.json
- Step 3: If a command is returned, execute it; if command is null, apply the edge-case fallback
Best Practices
- Always call the router first with the intent: e.g., math-router route \"<intent>\" before any tool invocation.
- Keep trigger keywords broader than routing patterns to improve router coverage.
- Enable co-activation of domain skills with their router using the coActivate pattern so the router is always available.
- Trust the router's confidence score and only bypass when command is null.
- Avoid duplicating routing logic in individual skills; let routers handle the mapping.
Example Use Cases
- A user requests to simplify a polynomial; the router maps the intent to the exact CLI command via math-router and returns a concrete script to run.
- In a session with abstract algebra tasks, the router directs to the appropriate domain tool (e.g., mapping 'groups' related intents to a specific script).
- Edge-case handling where the router cannot map the intent (command: null) triggers a fallback path to a manual script or guidance.
- Two-domain coordination where math-router and another domain router co-activate to ensure routing is available during multi-skill tasks.
- A sequence like 'solve differential equation' is routed to the precise command by the router, then executed deterministically.