Skill: mupengi-bot/mupeng-skill-router (version 1.0.0)

--- name: skill-router description: "Context-based skill auto-routing + federated skill composition. Analyzes user input to auto-select single or multiple skills and execute in order. First gateway for all requests. Use on every request to determine optimal skill combination." author: 무펭이 🐧 --- # Skill 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 ```bash # Extract only frontmatter from all skills for skill in skills/*/SKILL.md; do yq eval '.name, .description, .trigger, .run' "$skill" done ``` ### Execution Example ```bash # 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: 1. **Detect complex intent**: "Analyze competitors and make card news" → competitor-watch + copywriting + cardnews + insta-post 2. **Context-based auto-hooks**: Auto-determine subsequent skills when a skill executes 3. **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](https://github.com/mupeng) ecosystem skill

path: chains.md
content: # Skill Chain Templates

Collection of frequently used skill combination pipelines. Templates for handling complex requests efficiently.

---

## 1. Content Full Pipeline

**Name**: content-full-pipeline  
**Trigger**: "create content", "make a post", "create for Instagram"

**Description**: Full content creation pipeline from idea to Instagram publish

**Steps**:
1. **seo-content-planner** — Keyword research + content topic selection
2. **copywriting** — SEO-optimized text creation
3. **cardnews** — Card news image generation (1:1 square)
4. **insta-post** — Instagram upload (requires approval)

**Output**: Instagram post URL + performance tracking start

---

## 2. Competitor Analysis Report

**Name**: competitor-research-report  
**Trigger**: "analyze competitors and report", "do market research"

**Description**: Monitor competitor trends, generate organized report and send email

**Steps**:
1. **competitor-watch** — Crawl competitor websites/SNS + detect changes
2. **daily-report** — Convert analysis results into structured report
3. **mail** — Send report email (requires approval)

**Output**: Report MD file + email sent confirmation

---

## 3. Video→Content Conversion

**Name**: video-to-content  
**Trigger**: "summarize this video into card news", "create content from YouTube video"

**Description**: Summarize YouTube video and repackage as card news

**Steps**:
1. **yt-digest** — YouTube video download + subtitle extraction + summary
2. **content-recycler** — Restructure summary into short sentences for card news
3. **cardnews** — Generate card news images
4. **insta-post** — Instagram upload (requires approval)

**Output**: Card news image set + Instagram post

---

## 4. Weekly Comprehensive Review

**Name**: weekly-review  
**Trigger**: "weekly review", "summarize this week", "week summary"

**Description**: Comprehensive weekly report with performance, costs, and reflections

**Steps** (parallel execution):
1. **self-eval** — Analyze last week's mistakes/improvements
2. **tokenmeter** — Weekly token usage + cost aggregation
3. **performance-tracker** — Content performance analysis (likes/comments/views)

**Steps** (sequential execution):
4. **daily-report** — Generate weekly report integrating above 3 results

**Output**: weekly-review-YYYY-MM-DD.md

---

## 5. Content Recycling

**Name**: content-recycle  
**Trigger**: "recycle content", "rewrite successful post"

**Description**: Find high-performing content and repackage in new format

**Steps**:
1. **performance-tracker** — Extract content with most likes/comments in last 30 days
2. **content-recycler** — Rewrite popular content from different angle/format
3. **cardnews** — Generate new card news

**Output**: Repackaged content + card news images

---

## 6. Idea→Action

**Name**: idea-to-action  
**Trigger**: "review idea and execute", "brainstorm and do it now"

**Description**: Review idea, establish execution plan, and execute immediately

**Steps**:
1. **think-tank** (brainstorm mode) — Idea generation + feasibility review
2. **decision-log** — Record decisions (why this direction was chosen)
3. **skill-composer** — Auto-compose skill combination matching execution plan

**Output**: Execution result + decision-log update

---

## 7. Market Research Full Analysis

**Name**: market-research  
**Trigger**: "market research", "industry trends"

**Description**: Integrated market research through competitors + trends + data collection

**Steps** (parallel execution):
1. **competitor-watch** — Monitor competitor websites
2. **trend-radar** — Google Trends + social trends analysis
3. **data-scraper** — Collect related statistical data

**Steps** (sequential execution):
4. **daily-report** — Organize all research results into integrated report

**Output**: market-research-YYYY-MM-DD.md

---

## 8. Safe Release

**Name**: safe-release  
**Trigger**: "release", "deploy", "push to production"

**Description**: Code review → Git commit → deployment checklist verification

**Steps**:
1. **code-review** — Review code changes + risk assessment
2. **git-auto** — Commit + push (only if code-review passes)
3. **release-discipline** — Verify pre-deployment checklist (DB migration, env vars, etc.)

**Safety Measures**:
- If code-review detects HIGH severity → block commit + notification-hub
- Final approval required

**Output**: Git commit hash + deployment checklist completion confirmation

---

## 9. Morning Routine

**Name**: morning-routine  
**Trigger**: "morning routine", "start today", cron (daily 09:00)

**Description**: Check system status + costs + notifications and summary report

**Steps** (parallel execution):
1. **health-monitor** — System health check (disk, memory, API status)
2. **tokenmeter** — Verify yesterday/this month token usage
3. **notification-hub** — Collect unread notifications

**Steps** (sequential execution):
4. **daily-report** — Generate morning summary report

**Output**: morning-brief-YYYY-MM-DD.md + Discord DM

---

## 10. Urgent Alert Chain

**Name**: urgent-alert  
**Trigger**: Auto-chain rules (when specific events detected)

**Description**: Immediate notification when important events occur

**Auto Trigger Conditions**:
- tokenmeter exceeds $500/month
- code-review detects HIGH severity
- health-monitor detects system anomaly
- mail detects important email

**Steps**:
1. **notification-hub** (urgent priority) — Send Discord DM immediately
2. **daily-report** — Record event log

**Output**: Immediate notification + log record

---

## Chain Execution Rules

### Parallel vs Sequential
- **Parallel execution**: Skills with no dependencies (use sessions_spawn)
- **Sequential execution**: When next skill needs previous skill's result

### Data Transfer
- Data between skills saved as JSON events in `events/` folder
- Each skill saves results in `events/latest-{skill-name}.json` format
- Next skill reads that file as input

### Error Handling
- Skill failure mid-chain → save partial results + notification-hub alert
- Timeout during approval wait (1 hour) → auto-cancel + notification
- Same chain executed 3 times detected → prevent infinite loop, stop

---

> 🐧 Built by **무펭이** — [Mupengism](https://github.com/mupeng) ecosystem skill


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: suspicious | SkillSpector: suspicious (CRITICAL)