name: understand-domain description: Extract business domain knowledge from a codebase and generate an interactive domain flow graph. Works standalone (lightweight scan) or derives from an existing /understand knowledge graph. argument-hint: [--full]
/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 (
.understand-anything/knowledge-graph.json), derives domain knowledge from it (cheap, no file scanning) - If no knowledge graph exists, performs a lightweight scan: file tree + entry point detection + sampled files
- Use
--fullflag to force a fresh scan even if a knowledge graph exists
Instructions
Phase 1: Detect Existing Graph
- Check if
.understand-anything/knowledge-graph.jsonexists in the current project - If it exists AND
--fullwas NOT passed → proceed to Phase 3 (derive from graph) - Otherwise → proceed to Phase 2 (lightweight scan)
Phase 2: Lightweight Scan (Path 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 outputspython ./extract-domain-context.py <project-root><project-root>/.understand-anything/intermediate/domain-context.jsoncontaining:- 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
domain-context.jsonas context for Phase 4 - Proceed to Phase 4
Phase 3: Derive from Existing Graph (Path 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
Phase 4: Domain Analysis
- 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
Phase 5: Validate and Save
- 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
.understand-anything/intermediate/domain-analysis.jsonand.understand-anything/intermediate/domain-context.json
Phase 6: Launch Dashboard
- Auto-trigger
/understand-dashboardto visualize the domain graph - The dashboard will detect
domain-graph.jsonand show the domain view by default