skill-router
Scanned@mupengi-bot
npx machina-cli add skill @mupengi-bot/mupeng-skill-router --openclawSkill Router
Meta system that analyzes natural language input to auto-select appropriate skill(s), determine order, and chain execution.
π v2 Architecture: Low-level Call Protocol
Execution Flow
1. Scan only skills/*/SKILL.md frontmatter (trigger matching)
- Quick match with description + trigger fields
- No full body reading β 83% token savings
2. Check run field of matched skill for script path
- run: "./run.sh" β skills/{name}/run.sh
- run: "./run.js" β skills/{name}/run.js
3. Direct script execution with exec
WORKSPACE=$HOME/.openclaw/workspace \
EVENTS_DIR=$WORKSPACE/events \
MEMORY_DIR=$WORKSPACE/memory \
bash $WORKSPACE/skills/{name}/run.sh [args]
4. Agent processes stdout result
- Parse if JSON
- Pass through if text
- Check stderr on error
5. Generate events based on events_out
- Create events/{type}-{date}.json file
- Subsequent skills consume via events_in
6. Check hooks β trigger subsequent skills
- post: ["skill-a", "skill-b"] β auto-execute
- on_error: ["notification-hub"] β notify on error
Skill Metadata Scan
# Extract only frontmatter from all skills
for skill in skills/*/SKILL.md; do
yq eval '.name, .description, .trigger, .run' "$skill"
done
Execution Example
# User: "daily report"
# β trigger match: daily-report
# β Execute:
cd $HOME/.openclaw/workspace
WORKSPACE=$PWD \
EVENTS_DIR=$PWD/events \
MEMORY_DIR=$PWD/memory \
bash skills/daily-report/run.sh today
# Agent formats stdout result and delivers to user
Token Savings Effect
- Before: SKILL.md 3000 chars Γ 40 = 120KB (~30K tokens)
- v2: SKILL.md 500 chars Γ 40 = 20KB (~5K tokens)
- Savings: 83% token reduction
Core Concept
OpenClaw already selects 1 skill via description matching, but this skill:
- Detect complex intent: "Analyze competitors and make card news" β competitor-watch + copywriting + cardnews + insta-post
- Context-based auto-hooks: Auto-determine subsequent skills when a skill executes
- Skill chain templates: Pre-define frequently used combinations
Intent Classification Matrix
Single Skill Mapping (1:1)
- "commit/push/git" β git-auto
- "DM/instagram message" β auto-reply
- "cost/tokens/how much" β tokenmeter
- "translate/to English" β translate
- "invoice/quote" β invoice-gen
- "code review/PR" β code-review
- "system status/health" β health-monitor
- "trends" β trend-radar
- "performance/reactions/likes" β performance-tracker
- "daily report" β daily-report
- "SEO audit" β seo-audit
- "brand tone" β brand-voice
Complex Skill Chains (1:N) β Core Pipelines
| Trigger Pattern | Skill Chain | Description |
|---|---|---|
| "create content/post" | seo-content-planner β copywriting β cardnews β insta-post | Full content pipeline |
| "analyze competitors and report" | competitor-watch β daily-report β mail | Researchβreport |
| "summarize this video as card news" | yt-digest β content-recycler β cardnews β insta-post | Videoβcontent conversion |
| "weekly review" | self-eval + tokenmeter + performance-tracker β daily-report | Comprehensive review |
| "recycle content" | performance-tracker β content-recycler β cardnews | Repackage successful content |
| "review idea and execute" | think-tank(brainstorm) β decision-log β skill-composer | Ideationβdecisionβexecution |
| "market research" | competitor-watch + trend-radar + data-scraper β daily-report | Full research |
| "release" | code-review β git-auto β release-discipline | Safe deployment |
| "morning routine" | health-monitor β tokenmeter β notification-hub β daily-report | Morning auto-check |
Context-based Auto-chain Rules
Skill A execution complete β analyze results β auto-determine next skill:
Auto-chain Rules (if β then)
- IF competitor-watch detects important change β THEN notification-hub(urgent) + include in daily-report
- IF tokenmeter exceeds $500/month β THEN notification-hub(urgent)
- IF code-review detects HIGH severity β THEN block commit + notification-hub
- IF think-tank conclusion has "immediate execution" action β THEN auto-record in decision-log
- IF cardnews generation complete β THEN confirm "post with insta-post?" (approval required)
- IF self-eval detects repeated mistake β THEN trigger learning-engine
- IF performance-tracker finds successful content β THEN suggest content-recycler
- IF trend-radar detects hot trend β THEN auto-suggest seo-content-planner
- IF mail detects important email β THEN notification-hub(important)
- IF health-monitor detects anomaly β THEN attempt auto-recovery + notification-hub(urgent)
Execution Engine Protocol
1. Receive user input
2. Classify intent (single vs complex)
3. If single β execute skill immediately
4. If complex β compose skill chain
a. Skills without dependencies execute in parallel (sessions_spawn)
b. Skills with dependencies execute sequentially (pass previous results via events/)
5. Check auto-chain rules on each skill completion
6. Auto-trigger additional skills if needed (or request approval)
7. Synthesize final results and respond
Auto-hook Registration
When skill-router activates, for all skills:
- pre-hook: Input validation + security check
- post-hook: Generate events/ event + check chain rules
- on-error: Error log + notification-hub
Skill Dependency Graph
[User Input]
β
[skill-router] β Intent classification
β
βββββββββββββββββββββββββββββββββββββββββββ
β TIER 1: Data Collection β
β competitor-watch, data-scraper, β
β trend-radar, tokenmeter, yt-digest β
βββββββββββββββ¬ββββββββββββββββββββββββββββ
β events/
βββββββββββββββββββββββββββββββββββββββββββ
β TIER 2: Analysis/Thinking β
β think-tank, self-eval, seo-audit, β
β code-review, performance-tracker β
βββββββββββββββ¬ββββββββββββββββββββββββββββ
β events/
βββββββββββββββββββββββββββββββββββββββββββ
β TIER 3: Production β
β copywriting, cardnews, content-recycler,β
β translate, invoice-gen β
βββββββββββββββ¬ββββββββββββββββββββββββββββ
β events/
βββββββββββββββββββββββββββββββββββββββββββ
β TIER 4: Deployment/Execution β
β insta-post, mail, git-auto, β
β release-discipline β
βββββββββββββββ¬ββββββββββββββββββββββββββββ
β events/
βββββββββββββββββββββββββββββββββββββββββββ
β TIER 5: Tracking/Learning β
β daily-report, decision-log, β
β learning-engine, notification-hub β
βββββββββββββββββββββββββββββββββββββββββββ
Safety Mechanisms
- Always require approval before external actions (email send, SNS post, payment)
- Prevent infinite loops: Stop after same skill chain repeats 3 times
- Cost limit: Max 5 subagents per chain
- Graceful stop on error + save partial results
π§ Built by 무νμ΄ β Mupengism ecosystem skill
Overview
Skill Router is a meta system that analyzes user input to auto-select appropriate skill(s), determine their execution order, and chain them. It serves as the first gateway for all requests, using a v2 low-level protocol to efficiently route and compose federated skills. It scans only the frontmatter of skills to match triggers and then executes the matched scripts, emitting events for downstream skills.
How This Skill Works
On each request, it scans skills/*/SKILL.md frontmatter to quickly match name, description, trigger, and run fields. It then locates the script path (run.sh or run.js) and executes it in a standardized workspace, capturing stdout and stderr. It generates events based on the output and triggers subsequent skills via post hooks or error notifications via on_error, enabling federated skill composition.
When to Use It
- When a user intent requires multiple skills executed in a specific order (e.g., analyze competitors β daily report β mail).
- When you want a single gateway routing all requests to the optimal skill combination without manual routing.
- When building a repeatable content pipeline (e.g., seo-content-planner β copywriting β cardnews β insta-post).
- When you need token-efficient matching by scanning only frontmatter to reduce input size.
- When you want automated error alerts and chained execution using on_error hooks.
Quick Start
- Step 1: Ensure each skill's SKILL.md frontmatter includes name, description, trigger, and run (./run.sh or ./run.js).
- Step 2: Place the skill directories under skills/ and implement run.sh/run.js with expected inputs.
- Step 3: Send user input; Skill Router auto-selects, executes in order, processes stdout, emits events, and triggers any post hooks.
Best Practices
- Keep SKILL.md frontmatter concise to speed up trigger matching.
- Always specify a run path (run.sh or run.js) in each skill for predictable execution.
- Define post hooks with explicit skill names to ensure reliable chaining.
- Use the events mechanism to pass context between skills rather than ad-hoc data sharing.
- Test complex chains with realistic inputs (e.g., 'daily report', 'analyze competitors') to validate ordering.
Example Use Cases
- daily report: single trigger maps to daily-report and runs a defined execution flow.
- seo-content-pipeline: seo-content-planner β copywriting β cardnews β insta-post for full content creation.
- market research: competitor-watch + trend-radar + data-scraper β daily-report to consolidate findings.
- recycle content: performance-tracker β content-recycler β cardnews to repurpose successful assets.
- morning routine: health-monitor β tokenmeter β notification-hub β daily-report for automated start-of-day checks.