当前位置: 首页 > Skill >

skill-router-dynamic

skill-router-dynamic

skill-router-dynamic

A pure SKILL.md router that automatically routes user intent to the best matching installed skill. Works across Claude Code, WorkBuddy, OpenCode, Gemini CLI, Codex, OpenClaw, Cursor, and any platform that uses SKILL.md. Lifecycle: 1. ENTRY GUARD — decide if user wants routing or just chatting 2. SCAN — discover all installed skills across 8 platforms 3. MATCH — compare user intent against every skill's triggers and description 4. LOAD GUARD — confidence gate before loading 5. VERIFY HOOK — che

0.1.0 2026.11.14 770
获取Skill文件查看使用说明
作 者:沈禾 许可证: 更新时间:2026.11.14
本文目录展开

Skill Router — LIFECYCLE (MUST FOLLOW)

CRITICAL: This is a meta-skill. It does NOT do work itself. It routes.

Every output line from this skill MUST be prefixed with [skill-router]. This makes the audit trail grep-able across sessions. grep '[skill-router]' in any transcript to see what fired.

[skill-router] ┌─ ENTRY GUARD ─→ SCAN ─→ MATCH ─→ LOAD GUARD ─→ Load skill ─→ VERIFY HOOK ─→ CONTROL HOOK ─┐
[skill-router] └────────────────────────── persistent loop ────────────────────────────────────────────────┘

Works across Claude Code, WorkBuddy, OpenCode, Gemini CLI, Codex, OpenClaw, Cursor, and any platform that uses SKILL.md.

1. ENTRY GUARD — ROUTE OR CHAT?

FIRST thing you do when this skill is loaded. Before any scan, any match — decide: does this user message need routing at all?

If the user is clearly just chatting:

  • Greetings ("你好", "hello")
  • Simple factual questions ("Python 怎么排序", "今天天气")
  • Casual conversation → Exit router. Do NOT prefix anything. Reply normally.

If the user describes a task, names a domain, or asks "帮" + verb: → Enter SCAN phase.

Rule: When in doubt, route. False positives waste 5 seconds. False negatives miss the right skill entirely.

2. SCAN — DISCOVER ALL INSTALLED SKILLS

This is mandatory. You MUST NOT skip this phase.

Read every SKILL.md you can find. Extract name, description, and triggers from YAML frontmatter.

Check these locations in order:

Priority Level Paths
1st Project .claude/skills/*/SKILL.md, .workbuddy/skills/*/SKILL.md, .opencode/skills/*/SKILL.md, .gemini/skills/*/SKILL.md, .codex/skills/*/SKILL.md, .openclaw/skills/*/SKILL.md, .cursor/skills/*/SKILL.md, .agents/skills/*/SKILL.md
2nd User ~/.claude/skills/*/SKILL.md, ~/.workbuddy/skills/*/SKILL.md, ~/.config/opencode/skills/*/SKILL.md, ~/.gemini/skills/*/SKILL.md, ~/.codex/skills/*/SKILL.md, ~/.openclaw/skills/*/SKILL.md, ~/.agents/skills/*/SKILL.md

Rules:

  • Same-name skills: project-level wins over user-level.
  • Missing dir: skip silently.
  • No frontmatter: dir name as fallback.
  • Do NOT scan hidden dirs (.git/, __pycache__/, etc.).
  • Report: [skill-router] Scanned {N} skills across {M} platforms: {list}.

3. MATCH — COMPARE AGAINST USER INTENT

Compare the user's request against each scanned skill's name, description, and triggers.

Level Condition Action
High (≥0.85) Exact trigger match or unambiguous semantic match Load immediately. Do NOT ask.
Medium (0.5–0.85) Semantic match, not exact Show ≥2 options with scores. Let user pick.
Low (<0.5) Multiple partial matches Show all. Ask clarifying questions.
No match Nothing relevant Go to network fallback.

CRITICAL: Do NOT invent skills. Do NOT guess. If not found → fallback.

4. LOAD GUARD — VERIFY BEFORE LOADING

After match, do NOT load anything yet. Pass through this guard:

Match Guard action
High Announce. Load immediately.
Medium Present options. User MUST pick.
Low Ask clarifying. Re-match.
None Network fallback.

If error: call VERIFY HOOK → failure path.

5. NETWORK FALLBACK

If no installed skill matches:

  1. npx skills find "<describe need in 5-10 English words>"
  2. Present up to 3 options with name + description + install command.
  3. User confirms → npx skills add <owner/repo@skill> -g -y
  4. After install, skill is immediately available.

If npx not available → suggest skills.sh or GitHub.

6. VERIFY HOOK — CHECK EXECUTION RESULT

After the loaded skill finishes:

Success: Output matches user intent. → [skill-router] Verify: ✅ {skill} completed correctly → Move to CONTROL HOOK.

Failure: Output off-topic, wrong, or incomplete. → [skill-router] Verify: ❌ {skill} — result didn't match → Unload. Return to SCAN for next candidate. → If 2 consecutive failures: ask user for clarification.

7. CONTROL HOOK — PERSISTENT SESSION

After route + execution, the router stays active:

  • Same thread → Stay in loaded skill. No re-route.
  • New thread → Re-enter ENTRY GUARD → SCAN → MATCH → GUARD.
  • Uncertain → Default to re-scan.

8. OUTPUT FORMAT — GREP-ABLE CONTRACT

Every route step MUST prefix with [skill-router]. Example:

[skill-router] Entry: wants routing — task detected
[skill-router] Scan: 46 skills across 3 platforms
[skill-router] Match: paper-reading (high ~0.92) — trigger "论文" matches
[skill-router] Load Guard: Passed (≥0.85)
[skill-router] Verify: ✅ paper-reading completed correctly
[skill-router] Control: waiting — thread active

Failure format:

[skill-router] Match: no match found
[skill-router] Fallback: searching skills.sh...
[skill-router] Found "thesis-writer" (write academic papers). Install?

Multi-skill format:

[skill-router] Entry: wants routing — multi-domain
[skill-router] Scan: 46 skills
[skill-router] Match: pipeline detected — paper-reading → thesis-writing
[skill-router] Load Guard: Proposing pipeline to user

9. MULTI-SKILL ROUTING

Pattern Action
Pipeline (A → B) Load A, run, load B with A's output, VERIFY at end
Parallel (A ∥ B) Load both, run independently, merge
Compose (A + B) Load both, use together on same task

CRITICAL: Execute one at a time. Pass context between steps.

10. LOGGING (OPT-IN)

If the user has given explicit consent: Append a JSONL line to ~/.skill-router/log.jsonl after each route:

{"ts":"2026-05-07T09:00:00","prompt":"帮我写论文","matched":"paper-reading","score":0.92,"verify":"success"}

Do NOT log without asking the user first. When asked, explain: "This logs routing outcomes locally to measure accuracy. No data leaves your machine. Opt in?"

11. COMPLIANCE CHECKLIST

# Check Pass
1 Did I pass ENTRY GUARD (route or chat)? ☐
2 Did I SCAN actual directories (not guess)? ☐
3 Did I compare against ALL scanned skills? ☐
4 Did I pass LOAD GUARD before loading? ☐
5 Did I prefix every output with [skill-router]? ☐
6 Did I run VERIFY HOOK after the skill finished? ☐
7 Did I enter CONTROL HOOK? ☐

If any box is unchecked, you skipped a step. Fix it.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,017
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,005
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,003
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,002
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,002
Linux内核提权风险待核实,先查版本与补丁

CVE-2026-78901在摘要中被称为Linux内核ext4本地提权漏洞,CVSS评分7.8,但上游正文暂未核实。本文提供通用只读排查命令,帮运维和开发者核对当前运行内核、发行版补丁及升级生效状态。

2026.12.02 1,001
Skill 文件
  • SKILL.md
    • Skill Router — LIFECYCLE (MUST FOLLOW)
    • 1. ENTRY GUARD — ROUTE OR CHAT?
    • 2. SCAN — DISCOVER ALL INSTALLED SKILLS
    • 3. MATCH — COMPARE AGAINST USER INTENT
    • 4. LOAD GUARD — VERIFY BEFORE LOADING
    • 5. NETWORK FALLBACK
    • 6. VERIFY HOOK — CHECK EXECUTION RESULT
    • 7. CONTROL HOOK — PERSISTENT SESSION
    • 8. OUTPUT FORMAT — GREP-ABLE CONTRACT
    • 9. MULTI-SKILL ROUTING
    • 10. LOGGING (OPT-IN)
    • 11. COMPLIANCE CHECKLIST
  • 项目或源文件

相关 Skill

更多
Gemini Web Search Gemini Web Search 使用 Gemini CLI(@google/gemini-cli)进行网络搜索或事实查找,并返回有来源的摘要。当用户询问“今天X发生了什么”“最新消息是什么”“搜索网页”“查找来源/链接”,或任何需要最新信息的任务时使用。若 Gemini 可用但速度较慢,优先选择此工具;请在 TTY 环境中运行,等待更长时间,并核实来源质量。
Vibe-Switch Vibe-Switch AI 代理的 tmux — 一条命令并行编排多个 AI 编码代理。同时运行 Claude Code、Codex CLI 和 Gemini CLI...
Agents Plugin Marketplace Agents Plugin Marketplace 84个生产级代理插件,192个代理,156项技能和102条命令,适用于 Claude Code、Codex CLI、Cursor、OpenCode 与 Gemini CLI
ACP Background Runs ACP Background Runs 将ACP或外部编码代理(如Codex、Claude Code、Gemini CLI、OpenCode)的请求路由至非阻塞的OpenClaw后台ACP运行...
Skill Port Skill Port Skill Port 对跨 Claude Code、Codex、Gemini CLI 及 Agent Skills 兼容运行时的 AI agent 技能进行审计和移植。检查可移植性、目标 agent 兼容性、风险脚本/钩子/MCP 配置,在不安装或运行源码的情况下构建安全目标布局。