skill-tree-generator
Generates, 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 disambiguation, (3) incrementally update an existing tree by adding new skills. Use when users need to restructure, merge, or extend skills into context-aware, load-on-demand hierarchies.
openBitFun · Static checks on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add openBitFun/skill_tree --skill skill-tree-generatorAbout this skill
name: skill-tree-generator description: Generates, 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 disambiguation, (3) incrementally update an existing tree by adding new skills. Use when users need to restructure, merge, or extend skills into context-aware, load-on-demand hierarchies.
Skill Tree Generator
Usage
/skill-tree-generator <skill-name-or-skill-path-or-description>
/skill-tree-generator --aggregate skill1,skill2,... [--domain domain-name] [--no-decompose]
/skill-tree-generator --update <tree-path> --add <skill>
| 输入特征 | Mode | 描述 |
|---|---|---|
| 单个 skill 路径/描述,无特殊 flag | Mode 1 | 将单体 skill 转为路由树 |
--aggregate skill1,skill2,... | Mode 2 | 聚合多个 skill 为统一跨域树 |
--update <tree-path> --add <skill> | Mode 3 | 增量更新已有 tree |
可选 flag:
| Flag | 适用 Mode | 作用 |
|---|---|---|
--domain <name> | Mode 2 | 声明同域聚合,ROOT.md 按域内能力差异路由 |
--no-decompose | Mode 2 | 跳过 Step A1 能力拆解,所有源 skill 一律按单叶处理。仅当源 skill 已预先拆到原子粒度时使用 |
Overview
Transform monolithic skills into modular, hierarchical skill-trees (ROOT.md → ROUTER.md → SKILL.md) with dynamic routing. Use when:
- A skill has grown too complex and needs modularization
- Multiple distinct workflows exist within a single skill
- Multiple related skills need to be unified under one routing tree
- Cross-domain workflows span multiple skills
- Overlapping capabilities across skills need deduplication
- An existing skill-tree needs new skills or capabilities added
Strict Conformance
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.
Mode 1: Single Skill Tree Generation
Generate a routing tree for a single skill.
Input: Skill path or description
Output: Complete tree structure in {skill-name}-tree/
Example:
/skill-tree-generator web-development
Mode 1 Step 1: Analyze Input Skill
First, analyze the input skill to identify:
- Core domains - What major functional areas does the skill cover?
- Sub-domains - Within each core domain, what sub-categories exist?
- Leaf capabilities - What specific tasks/endpoints are at the lowest level?
- Routing criteria - What signals distinguish one path from another?
Read the skill content:
$ARGUMENTS
If $ARGUMENTS is a file path, read that file. If it's a description, use it directly.
Mode 1 Step 2: Design Tree Structure
Based on analysis, design the hierarchy following these principles:
skill-tree/
├── ROOT.md # L1 routing protocol
├── {module1}/
│ ├── ROUTER.md # L2 routing logic
│ ├── {submodule}/
│ │ ├── ROUTER.md # L3 routing logic
│ │ └── {feature}/SKILL.md # Leaf node
└── {module2}/
└── ...
Design Guidelines:
- L1 modules: Major functional domains (2-5 modules typical)
- L2 submodules: Sub-categories within each domain
- Leaf nodes: Specific, atomic tasks/capabilities
- Depth limit: 3-4 levels maximum for efficiency
Mode 1 Step 3: Generate ROOT.md
Read references/root_template.md and generate ROOT.md following the Single-Skill section template.
Mode 1 Step 4: Generate ROUTER.md Files
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.
Mode 1 Step 5: Generate Leaf SKILL.md Files
前置检查: 执行 references/error_handling.md 中的 Error Severity & Handling Strategy — 源技能不可用(Fatal)则报错终止,局部缺失(Degraded)则生成回退内容。
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.
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.
引用处理: 执行 references/error_handling.md 中的 Reference File Processing Flow Step R1-R4(盘点 → 决策 → 清理 → 即时验证)。
自包含: 遵循 references/error_handling.md 中的 Self-Containment Rule,生成结果必须作为 skill tree 整体自包含;短引用内联到叶节点,大文件集必须拷贝到 tree 内并通过 tree 内部相对路径引用。
嵌套 skill 检测: 执行 references/error_handling.md 中的 Nested Skill Detection。生成前用 Glob 扫描源 skill 目录 src/<skill>/*/SKILL.md;若命中 ≥2 个,判定为嵌套(index 型)skill,在 GENERATION-REPORT.md 记录,并按两种承载方式之一处理:方式 A(路由分离型,{skill}/ROUTER.md + 入口 {skill}/SKILL.md,上游指向 ROUTER.md)或方式 B(路由内嵌型,路由表+全局约束直接承载在 {skill}/SKILL.md 标 [Ln ROUTING NODE] [NESTED SKILL SUBTREE],不另设 ROUTER.md,上游指向 SKILL.md)。禁止方式 A 下只留 ROUTER.md 无入口 SKILL.md;禁止方式 B 下额外建只含指针的 ROUTER.md(与 SKILL.md 重复);两种方式不得混用。
【强制】Pre-Write Content Completeness Check: 在 Write 每个叶节点之前,重新读取源 skill 文件。按叶节点类型分别执行:
- 独立叶节点(源 skill 不拆分,1 源 → 1 叶):除 YAML frontmatter 外,源 skill 的全部内容必须逐字迁入叶节点;不接受内容损失;禁止"简化"、"概括"、"保留框架"。若因标题替换、tree 内部路径替换、引用文件拷贝等自包含处理导致行数不同,必须在
GENERATION-REPORT.md中逐项解释差异,并确认无执行级内容丢失。 - 拆分型叶节点(1 源 → 多个子叶):先建立 source section → leaf mapping;每个子叶包含对应章节/能力的完整内容;所有子叶合计覆盖源 skill 全部章节;若某子叶比映射到它的源段落短 >30%,必须逐段排查并修复或解释。
Mode 1 Step 6: Create Output Structure
Create all files in the target directory. **
Read the complete source ↗