$npx -y skills add maipianworni/SkillTree --skill skill-tree-generatorGenerates, aggregates, and extends modular skill-trees with hierarchical routing. Supports three modes — (1) convert a monolithic skill into a tree with ROOT.md/ROUTER.md/SKILL.md, (2) aggregate multiple skills into a unified cross-domain tree with shared leaves and disambiguatio
| 1 | # Skill Tree Generator |
| 2 | |
| 3 | ## Usage |
| 4 | |
| 5 | ``` |
| 6 | /skill-tree-generator <skill-name-or-skill-path-or-description> |
| 7 | /skill-tree-generator --aggregate skill1,skill2,... [--domain domain-name] |
| 8 | /skill-tree-generator --update <tree-path> --add <skill> |
| 9 | ``` |
| 10 | |
| 11 | | 输入特征 | Mode | 描述 | |
| 12 | |---------|------|------| |
| 13 | | 单个 skill 路径/描述,无特殊 flag | **Mode 1** | 将单体 skill 转为路由树 | |
| 14 | | `--aggregate skill1,skill2,...` | **Mode 2** | 聚合多个 skill 为统一跨域树 | |
| 15 | | `--update <tree-path> --add <skill>` | **Mode 3** | 增量更新已有 tree | |
| 16 | |
| 17 | ## Overview |
| 18 | |
| 19 | Transform monolithic skills into modular, hierarchical skill-trees (ROOT.md → ROUTER.md → SKILL.md) with dynamic routing. Use when: |
| 20 | - A skill has grown too complex and needs modularization |
| 21 | - Multiple distinct workflows exist within a single skill |
| 22 | - Multiple related skills need to be unified under one routing tree |
| 23 | - Cross-domain workflows span multiple skills |
| 24 | - Overlapping capabilities across skills need deduplication |
| 25 | - An existing skill-tree needs new skills or capabilities added |
| 26 | |
| 27 | ## Strict Conformance |
| 28 | |
| 29 | Before creating or modifying tree output, read and follow `references/strict_conformance.md`. Do not use substitute workflows, fast versions, heuristic-only splitting, or partial validation. If full conformance is impractical, stop and report the blocker before continuing. |
| 30 | |
| 31 | --- |
| 32 | |
| 33 | ## Mode 1: Single Skill Tree Generation |
| 34 | |
| 35 | Generate a routing tree for a single skill. |
| 36 | |
| 37 | **Input**: Skill path or description |
| 38 | **Output**: Complete tree structure in `{skill-name}-tree/` |
| 39 | |
| 40 | Example: |
| 41 | ``` |
| 42 | /skill-tree-generator web-development |
| 43 | ``` |
| 44 | |
| 45 | ### Mode 1 Step 1: Analyze Input Skill |
| 46 | |
| 47 | First, analyze the input skill to identify: |
| 48 | |
| 49 | 1. **Core domains** - What major functional areas does the skill cover? |
| 50 | 2. **Sub-domains** - Within each core domain, what sub-categories exist? |
| 51 | 3. **Leaf capabilities** - What specific tasks/endpoints are at the lowest level? |
| 52 | 4. **Routing criteria** - What signals distinguish one path from another? |
| 53 | |
| 54 | Read the skill content: |
| 55 | ``` |
| 56 | $ARGUMENTS |
| 57 | ``` |
| 58 | |
| 59 | If `$ARGUMENTS` is a file path, read that file. If it's a description, use it directly. |
| 60 | |
| 61 | ### Mode 1 Step 2: Design Tree Structure |
| 62 | |
| 63 | Based on analysis, design the hierarchy following these principles: |
| 64 | |
| 65 | ``` |
| 66 | skill-tree/ |
| 67 | ├── ROOT.md # L1 routing protocol |
| 68 | ├── {module1}/ |
| 69 | │ ├── ROUTER.md # L2 routing logic |
| 70 | │ ├── {submodule}/ |
| 71 | │ │ ├── ROUTER.md # L3 routing logic |
| 72 | │ │ └── {feature}/SKILL.md # Leaf node |
| 73 | └── {module2}/ |
| 74 | └── ... |
| 75 | ``` |
| 76 | |
| 77 | **Design Guidelines:** |
| 78 | - **L1 modules**: Major functional domains (2-5 modules typical) |
| 79 | - **L2 submodules**: Sub-categories within each domain |
| 80 | - **Leaf nodes**: Specific, atomic tasks/capabilities |
| 81 | - **Depth limit**: 3-4 levels maximum for efficiency |
| 82 | |
| 83 | ### Mode 1 Step 3: Generate ROOT.md |
| 84 | |
| 85 | Read `references/root_template.md` and generate `ROOT.md` following the Single-Skill section template. |
| 86 | |
| 87 | ### Mode 1 Step 4: Generate ROUTER.md Files |
| 88 | |
| 89 | For each non-leaf level, read `references/router_template.md` and generate `ROUTER.md` following that template. The template's `[MANDATORY]` routing requirements and pre-write checklist are acceptance criteria; do not duplicate, weaken, or replace them in this workflow. |
| 90 | |
| 91 | ### Mode 1 Step 5: Generate Leaf SKILL.md Files |
| 92 | |
| 93 | **前置检查**: 执行 `references/error_handling.md` 中的 **Error Severity & Handling Strategy** — 源技能不可用(Fatal)则报错终止,局部缺失(Degraded)则生成回退内容。 |
| 94 | |
| 95 | For each leaf node, read `references/leaf_template.md` for the structure template. Extract the complete content from the original skill and fill it into the template. Do NOT replace any content with a file path reference or external link. Every instruction, code example, API reference, and constraint from the original skill must be inlined directly. |
| 96 | |
| 97 | Source skill paths are generation-time inputs only. They may be recorded in `GENERATION-REPORT.md` for auditability, but leaf `SKILL.md` files must not tell the runtime agent to read the source skill path for full instructions. After generation, the tree must remain usable if the source skill directory is deleted or inaccessible. |
| 98 | |
| 99 | **引用处理**: 执行 `references/error_handling.md` 中的 **Reference File Processing Flow** Step R1-R4(盘点 → 决策 → 清理 → 即时验证)。 |
| 100 | |
| 101 | **自包含**: 遵循 `references/error_handling.md` 中的 **Self-Containment Rule**,生成结果必须作为 skill tree 整体自包含;短引用内联到叶节点,大文件集**必须**拷贝到 tree 内并通过 tree 内部相对路径引用。 |
| 102 | |
| 103 | **【强制】Pre-Write Content Completeness Check**: 在 Write 每个叶节点之前,**重新读取源 skill 文件**。按叶节点类型分别执行: |
| 104 | |
| 105 | - **独立叶节点(源 skill 不拆分,1 源 → 1 叶)**:除 YAML frontmatter 外,源 skill 的全部内容必须逐字迁入叶节点;不接受内容损失;禁止"简化"、"概括"、"保留框架"。若因标题替换、tree 内部路径替换、引用 |