Memory Router — Team Unified Knowledge Retrieval Skill - Author: Daniel Li - Copyright © Daniel Li. All rights reserved. Purpose All team agents (小a/ops/code/quant/data/finance/research/market/pm/content/law) MUST route knowledge retrieval through this standardized pipeline before answering questions about: - 系统配置、架构、部署 - 历史决策、TODO、进度 - Skill 用法与触发条件 - 项目状态与交付件 - 人物、日期、数字 QMD Feature Map (all features agents should use) | Feature | Command | When to Use | |---------|---------|-------------| | Hybrid search | | DEFAULT: combines BM25 + vector + rerank. Best for most queries | | Structured quer…

lex: keyword\\nvec: semantic'` | When you need precise keyword AND semantic results |\n| **BM25 keyword** | `qmd search \"\u003cexact term>\"` | Exact term/filename/config key lookup |\n| **Vector similarity** | `qmd vsearch \"\u003cconcept>\"` | Conceptual/fuzzy similarity (e.g., \"how to deploy\") |\n| **Get document** | `qmd get path/to/file.md:42 -l 30` | Read specific lines after search identifies a file |\n| **Multi-get** | `qmd multi-get \"reports/*.md\"` | Batch fetch multiple files (e.g., all reports) |\n| **Collection filter** | `qmd query -c skills \"\u003cquestion>\"` | Restrict search to one collection for precision |\n| **Full output** | `qmd query --full \"\u003cquestion>\"` | Get complete document content instead of snippets |\n| **JSON output** | `qmd query --json \"\u003cquestion>\"` | Machine-readable output for scripts |\n| **List files** | `qmd ls skills` | Browse what's indexed in a collection |\n| **Status** | `qmd status` | Health check: pending embeds, collection sizes |\n| **Update index** | `qmd update` | Re-index after file changes |\n| **Embed vectors** | `qmd embed` | Generate embeddings for new/changed files |\n| **Context notes** | `qmd context list` | View collection descriptions/usage hints |\n| **MCP server** | `qmd mcp` | Expose as MCP tool for IDE/agent integration |\n\n## Collections (current)\n\n| Collection | Content | Use For |\n|------------|---------|---------|\n| `clawd-memory` | `~/clawd/**/*.md` (1603 files) | Memory, docs, reports, runbooks |\n| `daily-memory` | `~/clawd/memory/*.md` (44 files) | Daily work logs |\n| `team` | `~/.openclaw/agents/**/*.json` (860 files) | Agent configs, models, auth |\n| `openclaw-config` | `~/.openclaw/**/*.json` (1031 files) | OpenClaw system config |\n| `projects` | `~/clawd/projects/**/*.md` (100 files) | Project PRDs, deliverables |\n| `skills` | `~/clawd/skills/**/SKILL.md` (468 files) | All skill documentation |\n| `reports` | `~/clawd/reports/*.md` (2 files) | Research & review reports |\n\n## Routing Algorithm\n\n```\nInput: user question Q\n\nStep 1 — CLASSIFY\n A = \"prior decisions / todos / people / dates / what happened\"\n B = \"system config / how-to / skill usage / architecture\"\n C = \"project status / deliverables / PRD\"\n D = \"external facts / live data\" (falls through to web)\n\nStep 2 — RETRIEVE (execute ALL applicable, not just one)\n\n if A:\n → qmd query -c daily-memory \"\u003cQ>\" -n 5\n → qmd query -c clawd-memory \"\u003cQ>\" -n 5\n → Also check ~/clawd/MEMORY.md directly for TODOs/decisions\n\n if B:\n → qmd query -c openclaw-config \"\u003cQ>\" -n 5\n → qmd query -c skills \"\u003cQ>\" -n 5\n → qmd query -c clawd-memory \"\u003cQ>\" -n 3 (for runbooks/docs)\n\n if C:\n → qmd query -c projects \"\u003cQ>\" -n 5\n → qmd query -c reports \"\u003cQ>\" -n 3\n\n if D:\n → qmd query \"\u003cQ>\" -n 5 (all collections, no filter)\n → If low recall → web_fetch / browser\n\nStep 3 — CITE\n Every answer MUST include 1-3 source citations:\n - File path: `~/clawd/docs/memory-router.md:15`\n - QMD URI: `qmd://skills/geo-agent/SKILL.md`\n - Or: \"Source: qmd query -c projects 'content factory status'\"\n```\n\n## Agent Integration (mandatory AGENTS.md section)\n\nEach agent's AGENTS.md must contain:\n\n```markdown\n## 知识库 / Memory Router(强制)\n\n- 你在回答任何「配置/流程/历史/怎么做」类问题前,**必须先检索本地知识库**:\n 1) 优先 QMD:`qmd query \"\u003c问题>\"`(必要时加 `--collection openclaw-config|projects|skills|reports|clawd-memory`)\n 2) 涉及待办/决策/人/日期 → 再查工作区记忆文件(`~/clawd/memory/YYYY-MM-DD.md` 与 `~/clawd/MEMORY.md`)\n- 输出时至少引用 1-3 个来源(文件路径或 `qmd://...` URI)。\n```\n\n## Health Monitoring\n\n### Daily Cron (recommended)\n```bash\n# qmd-health: run daily at 08:00\nqmd status | grep -E \"Total|Vectors|Pending|Updated\"\nqmd update\n```\n\n### Weekly Embed Refresh\n```bash\n# qmd-embed: run weekly Sunday 03:00\nqmd embed\nqmd status\n```\n\n### Health Metrics to Track\n- **覆盖率**: Vectors / Total (target: >90%)\n- **Pending**: should be \u003c100 after weekly embed\n- **Collection freshness**: Updated timestamps should be \u003c24h for active collections\n- **Query latency**: hybrid query should return \u003c2s\n\n## Troubleshooting\n\n| Problem | Solution |\n|---------|----------|\n| `qmd embed` hangs | Check if node-llama-cpp is compiling (first run). Wait ~10min. |\n| CUDA errors | Normal on CPU-only servers. QMD auto-falls back to CPU. |\n| Ollama not found | QMD uses node-llama-cpp, NOT Ollama. Ignore Ollama references. |\n| Low recall | Try `--full` flag, or use `qmd search` (BM25) for exact terms |\n| Missing files | Run `qmd update` to re-index, then `qmd embed` for new vectors |\n\n## Script: memory_router.sh\n\nFor automated context injection into agent prompts:\n\n```bash\n#!/bin/bash\n# Usage: ./memory_router.sh \"question\" [collection]\nQUERY=\"$1\"\nCOLLECTION=\"${2:-}\"\n\nif [ -n \"$COLLECTION\" ]; then\n qmd query -c \"$COLLECTION\" \"$QUERY\" -n 5 --line-numbers\nelse\n qmd query \"$QUERY\" -n 5 --line-numbers\nfi\n```\n\n---\n\nLast updated: 2026-03-03\nMaintainer: 小a (CEO)\n---","attachment_filenames":["memory_router.sh"],"attachments":[{"filename":"memory_router.sh","content":"#!/bin/bash\n# memory_router.sh — Quick QMD context retrieval for agents\n# Usage: ./memory_router.sh \"question\" [collection] [num_results]\nset -euo pipefail\n\nQUERY=\"${1:?Usage: memory_router.sh '\u003cquestion>' [collection] [num_results]}\"\nCOLLECTION=\"${2:-}\"\nNUM=\"${3:-5}\"\n\necho \"=== Memory Router ===\"\necho \"Query: $QUERY\"\necho \"\"\n\nif [ -n \"$COLLECTION\" ]; then\n echo \"--- Collection: $COLLECTION ---\"\n qmd query -c \"$COLLECTION\" \"$QUERY\" -n \"$NUM\" --line-numbers 2>&1\nelse\n echo \"--- Hybrid Search (all collections) ---\"\n qmd query \"$QUERY\" -n \"$NUM\" --line-numbers 2>&1\nfi\n\necho \"\"\necho \"--- Daily Memory (recent) ---\"\nTODAY=$(date +%Y-%m-%d)\nYESTERDAY=$(date -d \"yesterday\" +%Y-%m-%d 2>/dev/null || date -v-1d +%Y-%m-%d 2>/dev/null || echo \"\")\nfor f in ~/clawd/memory/${TODAY}.md ~/clawd/memory/${YESTERDAY}.md; do\n if [ -f \"$f\" ]; then\n echo \" File: $f\"\n grep -in \"$(echo \"$QUERY\" | cut -d' ' -f1-3)\" \"$f\" 2>/dev/null | head -5 || true\n fi\ndone\n\necho \"\"\necho \"=== End Router ===\"\n","content_type":"application/x-sh; charset=utf-8","language":"bash","size":996,"content_sha256":"cccb2ff8f59f1c003ca2bb11d34c0da6bb6953b4358469fba33644094423c4ec"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"Memory Router — Team Unified Knowledge Retrieval Skill","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Author: Daniel Li","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Copyright © Daniel Li. All rights reserved.","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Purpose","type":"text"}]},{"type":"paragraph","content":[{"text":"All team agents (小a/ops/code/quant/data/finance/research/market/pm/content/law) MUST route knowledge retrieval through this standardized pipeline before answering questions about:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"系统配置、架构、部署","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"历史决策、TODO、进度","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Skill 用法与触发条件","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"项目状态与交付件","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"人物、日期、数字","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"QMD Feature Map (all features agents should use)","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Feature","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Command","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"When to Use","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Hybrid search","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd query \"\u003cquestion>\"","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"DEFAULT: combines BM25 + vector + rerank. Best for most queries","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Structured query","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd query

Memory Router — Team Unified Knowledge Retrieval Skill - Author: Daniel Li - Copyright © Daniel Li. All rights reserved. Purpose All team agents (小a/ops/code/quant/data/finance/research/market/pm/content/law) MUST route knowledge retrieval through this standardized pipeline before answering questions about: - 系统配置、架构、部署 - 历史决策、TODO、进度 - Skill 用法与触发条件 - 项目状态与交付件 - 人物、日期、数字 QMD Feature Map (all features agents should use) | Feature | Command | When to Use | |---------|---------|-------------| | Hybrid search | | DEFAULT: combines BM25 + vector + rerank. Best for most queries | | Structured quer…

lex: keyword\\nvec: semantic'","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"When you need precise keyword AND semantic results","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"BM25 keyword","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd search \"\u003cexact term>\"","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Exact term/filename/config key lookup","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Vector similarity","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd vsearch \"\u003cconcept>\"","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Conceptual/fuzzy similarity (e.g., \"how to deploy\")","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Get document","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd get path/to/file.md:42 -l 30","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Read specific lines after search identifies a file","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Multi-get","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd multi-get \"reports/*.md\"","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Batch fetch multiple files (e.g., all reports)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Collection filter","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd query -c skills \"\u003cquestion>\"","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Restrict search to one collection for precision","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Full output","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd query --full \"\u003cquestion>\"","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Get complete document content instead of snippets","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"JSON output","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd query --json \"\u003cquestion>\"","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Machine-readable output for scripts","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"List files","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd ls skills","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Browse what's indexed in a collection","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Status","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd status","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Health check: pending embeds, collection sizes","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Update index","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd update","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Re-index after file changes","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Embed vectors","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd embed","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Generate embeddings for new/changed files","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Context notes","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd context list","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"View collection descriptions/usage hints","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"MCP server","type":"text","marks":[{"type":"strong"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd mcp","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Expose as MCP tool for IDE/agent integration","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Collections (current)","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Collection","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Content","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Use For","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"clawd-memory","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"~/clawd/**/*.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" (1603 files)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Memory, docs, reports, runbooks","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"daily-memory","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"~/clawd/memory/*.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" (44 files)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Daily work logs","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"team","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"~/.openclaw/agents/**/*.json","type":"text","marks":[{"type":"code_inline"}]},{"text":" (860 files)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Agent configs, models, auth","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"openclaw-config","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"~/.openclaw/**/*.json","type":"text","marks":[{"type":"code_inline"}]},{"text":" (1031 files)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"OpenClaw system config","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"projects","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"~/clawd/projects/**/*.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" (100 files)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Project PRDs, deliverables","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"skills","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"~/clawd/skills/**/SKILL.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" (468 files)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"All skill documentation","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"reports","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"~/clawd/reports/*.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" (2 files)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Research & review reports","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Routing Algorithm","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":""},"content":[{"text":"Input: user question Q\n\nStep 1 — CLASSIFY\n A = \"prior decisions / todos / people / dates / what happened\"\n B = \"system config / how-to / skill usage / architecture\"\n C = \"project status / deliverables / PRD\"\n D = \"external facts / live data\" (falls through to web)\n\nStep 2 — RETRIEVE (execute ALL applicable, not just one)\n\n if A:\n → qmd query -c daily-memory \"\u003cQ>\" -n 5\n → qmd query -c clawd-memory \"\u003cQ>\" -n 5\n → Also check ~/clawd/MEMORY.md directly for TODOs/decisions\n\n if B:\n → qmd query -c openclaw-config \"\u003cQ>\" -n 5\n → qmd query -c skills \"\u003cQ>\" -n 5\n → qmd query -c clawd-memory \"\u003cQ>\" -n 3 (for runbooks/docs)\n\n if C:\n → qmd query -c projects \"\u003cQ>\" -n 5\n → qmd query -c reports \"\u003cQ>\" -n 3\n\n if D:\n → qmd query \"\u003cQ>\" -n 5 (all collections, no filter)\n → If low recall → web_fetch / browser\n\nStep 3 — CITE\n Every answer MUST include 1-3 source citations:\n - File path: `~/clawd/docs/memory-router.md:15`\n - QMD URI: `qmd://skills/geo-agent/SKILL.md`\n - Or: \"Source: qmd query -c projects 'content factory status'\"","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Agent Integration (mandatory AGENTS.md section)","type":"text"}]},{"type":"paragraph","content":[{"text":"Each agent's AGENTS.md must contain:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"markdown"},"content":[{"text":"## 知识库 / Memory Router(强制)\n\n- 你在回答任何「配置/流程/历史/怎么做」类问题前,**必须先检索本地知识库**:\n 1) 优先 QMD:`qmd query \"\u003c问题>\"`(必要时加 `--collection openclaw-config|projects|skills|reports|clawd-memory`)\n 2) 涉及待办/决策/人/日期 → 再查工作区记忆文件(`~/clawd/memory/YYYY-MM-DD.md` 与 `~/clawd/MEMORY.md`)\n- 输出时至少引用 1-3 个来源(文件路径或 `qmd://...` URI)。","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Health Monitoring","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Daily Cron (recommended)","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# qmd-health: run daily at 08:00\nqmd status | grep -E \"Total|Vectors|Pending|Updated\"\nqmd update","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Weekly Embed Refresh","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# qmd-embed: run weekly Sunday 03:00\nqmd embed\nqmd status","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Health Metrics to Track","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"覆盖率","type":"text","marks":[{"type":"strong"}]},{"text":": Vectors / Total (target: >90%)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Pending","type":"text","marks":[{"type":"strong"}]},{"text":": should be \u003c100 after weekly embed","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Collection freshness","type":"text","marks":[{"type":"strong"}]},{"text":": Updated timestamps should be \u003c24h for active collections","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Query latency","type":"text","marks":[{"type":"strong"}]},{"text":": hybrid query should return \u003c2s","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Troubleshooting","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Problem","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Solution","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"qmd embed","type":"text","marks":[{"type":"code_inline"}]},{"text":" hangs","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Check if node-llama-cpp is compiling (first run). Wait ~10min.","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"CUDA errors","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Normal on CPU-only servers. QMD auto-falls back to CPU.","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Ollama not found","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"QMD uses node-llama-cpp, NOT Ollama. Ignore Ollama references.","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Low recall","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Try ","type":"text"},{"text":"--full","type":"text","marks":[{"type":"code_inline"}]},{"text":" flag, or use ","type":"text"},{"text":"qmd search","type":"text","marks":[{"type":"code_inline"}]},{"text":" (BM25) for exact terms","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Missing files","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Run ","type":"text"},{"text":"qmd update","type":"text","marks":[{"type":"code_inline"}]},{"text":" to re-index, then ","type":"text"},{"text":"qmd embed","type":"text","marks":[{"type":"code_inline"}]},{"text":" for new vectors","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Script: memory_router.sh","type":"text"}]},{"type":"paragraph","content":[{"text":"For automated context injection into agent prompts:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"#!/bin/bash\n# Usage: ./memory_router.sh \"question\" [collection]\nQUERY=\"$1\"\nCOLLECTION=\"${2:-}\"\n\nif [ -n \"$COLLECTION\" ]; then\n qmd query -c \"$COLLECTION\" \"$QUERY\" -n 5 --line-numbers\nelse\n qmd query \"$QUERY\" -n 5 --line-numbers\nfi","type":"text"}]},{"type":"hr","attrs":{"markup":"---"}},{"type":"heading","attrs":{"level":2},"content":[{"text":"Last updated: 2026-03-03 Maintainer: 小a (CEO)","type":"text"}]}]},"metadata":{"date":"2026-06-05","name":"memory-router","author":"@skillopedia","source":{"stars":65,"repo_name":"claude-code-skills","origin_url":"https://github.com/aaaaqwq/claude-code-skills/blob/HEAD/skills/memory-router/SKILL.md","repo_owner":"aaaaqwq","body_sha256":"75d9e391df6aab0e284ff1ea047699c6ff863a7645b3c07230238e9da005f5b7","cluster_key":"6e5301c68ee3efe66df89c8d48c9f1ee9367f4ddbab4f4266e98225c5913b599","clean_bundle":{"format":"clean-skill-bundle-v1","source":"aaaaqwq/claude-code-skills/skills/memory-router/SKILL.md","attachments":[{"id":"ab8d5bb9-e625-55be-a012-9fe3893359fb","key":"uploads/10433ee7-ad12-4ae0-b34e-97553e46c6c8/ab8d5bb9-e625-55be-a012-9fe3893359fb/attachment.sh","path":"memory_router.sh","size":996,"sha256":"cccb2ff8f59f1c003ca2bb11d34c0da6bb6953b4358469fba33644094423c4ec","contentType":"application/x-sh; charset=utf-8"}],"bundle_sha256":"ad390d625d0e1953dba7deabcff887cb94772b4e2336b6fc96b251bf06f1da74","attachment_count":1,"text_attachments":1,"attachment_storage":"skillopedia-attachments-v1","binary_attachments":0,"excluded_attachments":[]},"cluster_size":1,"skill_md_path":"skills/memory-router/SKILL.md","import_metadata":{"date":"2026-06-05","author":"@skillopedia","version":"v1","category":"general","category_label":"General"},"exact_dupes_collapsed_into_this":0},"version":"v1","category":"general","import_tag":"clean-skills-v1","description":"Team-wide memory routing skill — routes agent queries to the optimal knowledge source (QMD hybrid search, daily memory, MEMORY.md) and enforces citation. Use when any agent needs to retrieve prior work, system config, skill docs, project status, or decisions. Triggers on \"查知识库\", \"memory router\", \"qmd query\", \"find in docs\", \"what was decided\", \"how does X work\", \"项目状态\", \"之前的决策\"."}},"renderedAt":1782979900188}

Memory Router — Team Unified Knowledge Retrieval Skill - Author: Daniel Li - Copyright © Daniel Li. All rights reserved. Purpose All team agents (小a/ops/code/quant/data/finance/research/market/pm/content/law) MUST route knowledge retrieval through this standardized pipeline before answering questions about: - 系统配置、架构、部署 - 历史决策、TODO、进度 - Skill 用法与触发条件 - 项目状态与交付件 - 人物、日期、数字 QMD Feature Map (all features agents should use) | Feature | Command | When to Use | |---------|---------|-------------| | Hybrid search | | DEFAULT: combines BM25 + vector + rerank. Best for most queries | | Structured quer…