understand-domain
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/understand-domain
/understand-domain
Extracts business domain knowledge — domains, business flows, and process steps — from a codebase and produces an interactive horizontal flow graph in the dashboard.
从代码库中提取业务领域知识——包括领域、业务流程和处理步骤——并在仪表板中生成交互式水平流程图。
How It Works
工作原理
- If a knowledge graph already exists (), derives domain knowledge from it (cheap, no file scanning)
.understand-anything/knowledge-graph.json - If no knowledge graph exists, performs a lightweight scan: file tree + entry point detection + sampled files
- Use flag to force a fresh scan even if a knowledge graph exists
--full
- 如果已存在知识图谱(),则基于该图谱推导领域知识(成本低,无需扫描文件)
.understand-anything/knowledge-graph.json - 如果不存在知识图谱,则执行轻量扫描:文件树+入口点检测+抽样文件
- 使用flag可强制执行全新扫描,即便已有知识图谱也不例外
--full
Instructions
使用说明
Phase 1: Detect Existing Graph
阶段1:检测已有图谱
- Check if exists in the current project
.understand-anything/knowledge-graph.json - If it exists AND was NOT passed → proceed to Phase 3 (derive from graph)
--full - Otherwise → proceed to Phase 2 (lightweight scan)
- 检查当前项目中是否存在
.understand-anything/knowledge-graph.json - 如果文件存在且未传入参数 → 进入阶段3(基于图谱推导)
--full - 否则 → 进入阶段2(轻量扫描)
Phase 2: Lightweight Scan (Path 1)
阶段2:轻量扫描(路径1)
The preprocessing script does NOT produce a domain graph — it produces raw material (file tree, entry points, exports/imports) so the domain-analyzer agent can focus on the actual domain analysis instead of spending dozens of tool calls exploring the codebase. Think of it as a cheat sheet: cheap Python preprocessing → expensive LLM gets a clean, small input → better results for less cost.
- Run the preprocessing script bundled with this skill:
This outputs
python ./extract-domain-context.py <project-root>containing:<project-root>/.understand-anything/intermediate/domain-context.json- File tree (respecting )
.gitignore - Detected entry points (HTTP routes, CLI commands, event handlers, cron jobs, exported handlers)
- File signatures (exports, imports per file)
- Code snippets for each entry point (signature + first few lines)
- Project metadata (package.json, README, etc.)
- File tree (respecting
- Read the generated as context for Phase 4
domain-context.json - Proceed to Phase 4
预处理脚本不会生成领域图谱,它会生成原始素材(文件树、入口点、导出/导入项),这样domain-analyzer agent就能聚焦于实际的领域分析,而不需要花费几十次工具调用探索代码库。你可以把它看作一份备忘录:低成本的Python预处理 → 昂贵的LLM获得干净、体量小的输入 → 成本更低,效果更好。
- 运行该skill内置的预处理脚本:
命令会输出
python ./extract-domain-context.py <project-root>,包含以下内容:<project-root>/.understand-anything/intermediate/domain-context.json- 文件树(遵循规则)
.gitignore - 检测到的入口点(HTTP路由、CLI命令、事件处理器、定时任务、导出的处理器)
- 文件特征(每个文件的导出、导入项)
- 每个入口点的代码片段(特征定义+前几行代码)
- 项目元数据(package.json、README等)
- 文件树(遵循
- 读取生成的作为阶段4的上下文
domain-context.json - 进入阶段4
Phase 3: Derive from Existing Graph (Path 2)
阶段3:基于已有图谱推导(路径2)
- Read
.understand-anything/knowledge-graph.json - Format the graph data as structured context:
- All nodes with their types, names, summaries, and tags
- All edges with their types (especially ,
calls,imports)contains - All layers with their descriptions
- Tour steps if available
- This is the context for the domain analyzer — no file reading needed
- Proceed to Phase 4
- 读取
.understand-anything/knowledge-graph.json - 将图谱数据格式化为结构化上下文:
- 所有节点及其类型、名称、摘要和标签
- 所有边及其类型(尤其是、
calls、imports)contains - 所有分层及其描述
- 导览步骤(如果有)
- 以上内容就是领域分析器的上下文,无需读取任何文件
- 进入阶段4
Phase 4: Domain Analysis
阶段4:领域分析
- Read the domain-analyzer agent prompt from
agents/domain-analyzer.md - Dispatch a subagent with the domain-analyzer prompt + the context from Phase 2 or 3
- The agent writes its output to
.understand-anything/intermediate/domain-analysis.json
- 从读取domain-analyzer agent的提示词
agents/domain-analyzer.md - 分配子agent,传入domain-analyzer提示词+阶段2或阶段3生成的上下文
- Agent会将输出写入
.understand-anything/intermediate/domain-analysis.json
Phase 5: Validate and Save
阶段5:验证与保存
- Read the domain analysis output
- Validate using the standard graph validation pipeline (the schema now supports domain/flow/step types)
- If validation fails, log warnings but save what's valid (error tolerance)
- Save to
.understand-anything/domain-graph.json - Clean up and
.understand-anything/intermediate/domain-analysis.json.understand-anything/intermediate/domain-context.json
- 读取领域分析输出
- 使用标准图谱验证管道进行验证(当前schema已支持domain/flow/step类型)
- 如果验证失败,记录警告但保存所有有效内容(容错机制)
- 保存到
.understand-anything/domain-graph.json - 清理和
.understand-anything/intermediate/domain-analysis.json.understand-anything/intermediate/domain-context.json
Phase 6: Launch Dashboard
阶段6:启动仪表板
- Auto-trigger to visualize the domain graph
/understand-dashboard - The dashboard will detect and show the domain view by default
domain-graph.json
- 自动触发可视化领域图谱
/understand-dashboard - 仪表板会检测,默认展示领域视图
domain-graph.json