understand-domain
Skill1 starsChanged 6 days agoMITView on GitHub
Extract business domain knowledge (business domains, flows and process steps) from a codebase into a domain graph for the Domain view of the claude-dashboard Understand page. Works standalone (lightweight scan) or derives from an existing /understand map. Use when the user types /understand-domain, or asks to extract or map the business domains or flows of a codebase.
5 other projects use a version of this, 5 of them edited.
Adopted by
Most recently taken up by
- zhengyanxiong/skillsedited, first seen Nov 29, 2026
- pwizzang/claude-skillsedited, first seen Nov 16, 2026
- Pdbjork/hermosskills-siteedited, first seen Jul 8, 2026
- MovGP0/Skillsedited, first seen Jun 30, 2026
- karanmrn/claude-skillsedited, first seen Jun 28, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 5
- MovGP0/Skills★ 141% same
- zhengyanxiong/skills★ 141% same
- karanmrn/claude-skills★ 041% same
- Pdbjork/hermosskills-site★ 041% same
- pwizzang/claude-skills★ 041% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- godeyeSkill
- understand-chatSkill
- understand-dashboardSkill
- understand-diffSkill
- understand-explainSkill
- understand-figmaSkill
- understand-knowledgeSkill
- understand-onboardSkill
- understandSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 1 is common, 3 are distinctive, and 11 are very specific to this project.
1
Common
Most of the 5 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
If a knowledge graph already exists ($DATA/knowledge-graph.json, made by /understand), derives domain knowledge from it (cheap, no file …
- Common: line 16
If no knowledge graph exists, performs a lightweight scan: file tree + entry point detection + sampled files
- Very specific: line 17
Use --full flag to force a fresh scan even if a knowledge graph exists
- Very specific: line 49
If it does not print pipeline ok, tell the user: "The Understand pipeline is missing from claude-dashboard …
- Very specific: line 51
If KIND is knowledge or design, this folder holds a wiki or Figma map, not a code map: tell the user that /understand-domain works on code …
- Very specific: line 55
Check GRAPH from Phase 0 (whether $DATA/knowledge-graph.json exists and parses).
- Very specific: line 56
If it is present AND --full was NOT passed, check freshness before deriving from it:
- Very specific: line 70
If the committed diff or any working-tree command reports project files, warn that domain extraction may omit those changes.
- Very specific: line 71
Run the commit diff only when GRAPH_COMMIT_RAW resolves successfully.
- Distinctive: line 72
After that preflight, proceed to Phase 3 (derive from graph).
- Very specific: line 79
Run the preprocessing script, passing $PROJECT_ROOT from Phase 0:
- Distinctive: line 90
If it exits non-zero, report its stderr and STOP.
- Very specific: line 169
If it exits non-zero (Domain graph not saved: <reason>, or a read or JSON error when the agent wrote no valid file), report the reason and …
- Very specific: line 177
Make sure claude-dashboard runs (this replaces Understand Anything's own dashboard launch):
- Distinctive: line 181
If it says the dashboard is not running, start it in the background without opening a browser.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/understand-domain
Extracts business domain knowledge — domains, business flows, and process steps — from a codebase and saves a domain flow graph, $DATA/domain-graph.json, in the project's data folder (~/.claude/understand/<key>/, resolved in Phase 0). The Understand page of claude-dashboard (http://127.0.0.1:3737/understand) shows it as its Domain view.
Nothing is ever written inside the project. The deterministic scripts live in {{CLAUDE_DASHBOARD}}/src/understand/scripts/; the agent prompt is ~/.claude/skills/understand/agents/domain-analyzer.md. Adapted from Understand Anything's /understand-domain skill (MIT, see {{CLAUDE_DASHBOARD}}/src/understand/LICENSE-understand-anything).
How It Works
- If a knowledge graph already exists (
$DATA/knowledge-graph.json, made by/understand), 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 0: Resolve PROJECT_ROOT and $DATA
Set
PROJECT_ROOTto the current working directory. Worktree redirect: ifPROJECT_ROOTis inside a git worktree (not the main checkout), redirect to the main repository root. Worktrees managed by Claude Code are ephemeral, and the data folder is keyed byPROJECT_ROOT, so without the redirect every short-lived worktree would get its own orphan graph instead of sharing the main checkout's (upstream issue #133). Detect a worktree by comparinggit rev-parse --git-diragainstgit rev-parse --git-common-dir; in a normal checkout or submodule they resolve to the same path, in a worktree they differ and the parent of--git-common-diris the main repo root. The same command then resolves the data folder:PROJECT_ROOT=$(pwd -P) COMMON_DIR=$(git -C "$PROJECT_ROOT" rev-parse --git-common-dir 2>/dev/null) OWN_GIT_DIR=$(git -C "$PROJECT_ROOT" rev-parse --git-dir 2>/dev/null) if [ -n "$COMMON_DIR" ] && [ -n "$OWN_GIT_DIR" ]; then COMMON_ABS=$(cd "$PROJECT_ROOT" && cd "$COMMON_DIR" 2>/dev/null && pwd -P) OWN_ABS=$(cd "$PROJECT_ROOT" && cd "$OWN_GIT_DIR" 2>/dev/null && pwd -P) if [ -n "$COMMON_ABS" ] && [ "$COMMON_ABS" != "$OWN_ABS" ]; then MAIN_ROOT=$(dirname "$COMMON_ABS") if [ -d "$MAIN_ROOT" ] && [ "${UNDERSTAND_NO_WORKTREE_REDIRECT:-0}" != "1" ]; then echo "[understand-domain] Detected git worktree at $PROJECT_ROOT" echo "[understand-domain] Redirecting output to main repo root: $MAIN_ROOT" echo "[understand-domain] (Set UNDERSTAND_NO_WORKTREE_REDIRECT=1 to keep PROJECT_ROOT as the worktree.)" PROJECT_ROOT="$MAIN_ROOT" fi fi fi test -f {{CLAUDE_DASHBOARD}}/src/understand/scripts/extract-domain-context.mjs \ && test -d {{CLAUDE_DASHBOARD}}/node_modules/zod && echo "pipeline ok" echo "HEAD_COMMIT=$(git -C "$PROJECT_ROOT" rev-parse --verify -q HEAD 2>/dev/null)" node {{CLAUDE_DASHBOARD}}/src/understand/scripts/data-dir.mjs "$PROJECT_ROOT" \ | node -e 'const fs=require("fs"),j=JSON.parse(fs.readFileSync(0,"utf8")),f=j.dataDir+"/knowledge-graph.json";let g=null;try{g=JSON.parse(fs.readFileSync(f,"utf8"))}catch{}console.log("DATA="+j.dataDir);console.log("KEY="+j.key);console.log("PROJECT_ROOT="+j.projectRoot);console.log("GRAPH="+(g?"present":fs.existsSync(f)?"unreadable":"missing"));if(g){console.log("KIND="+(g.kind||"code"));console.log("GRAPH_COMMIT_RAW="+((g.project||{}).gitCommitHash||""))}'- If it does not print
pipeline ok, tell the user: "The Understand pipeline is missing from claude-dashboard ({{CLAUDE_DASHBOARD}}/src/understand/), or its packages are not installed (runnpm installin{{CLAUDE_DASHBOARD}})." and STOP. Ifdata-dir.mjsfails, report its stderr and STOP. - Carry the printed values forward and substitute them in later commands, which may run in a fresh shell:
$DATA(the data folder),$KEY(for the page link),PROJECT_ROOT(the real path the folder is keyed by),HEAD_COMMIT(empty when the project has no commit),GRAPH,KINDandGRAPH_COMMIT_RAW. - If
KINDisknowledgeordesign, this folder holds a wiki or Figma map, not a code map: tell the user that/understand-domainworks on code projects and STOP.
Phase 1: Detect Existing Graph
- Check
GRAPHfrom Phase 0 (whether$DATA/knowledge-graph.jsonexists and parses). - If it is
presentAND--fullwas NOT passed, check freshness before deriving from it:GRAPH_COMMIT_RAWisproject.gitCommitHashfrom the graph metadata. Resolve it as a commit before using it in any Git diff, compare the resolved commit withgit rev-parse HEAD, and inspect project-scoped committed and working-tree changes:PROJECT_ROOT="<PROJECT_ROOT>"; GRAPH_COMMIT_RAW="<GRAPH_COMMIT_RAW>" GRAPH_COMMIT=$(git -C "$PROJECT_ROOT" rev-parse --verify --end-of-options "${GRAPH_COMMIT_RAW}^{commit}" 2>/dev/null) echo "GRAPH_COMMIT=$GRAPH_COMMIT" git -C "$PROJECT_ROOT" rev-parse HEAD [ -n "$GRAPH_COMMIT" ] && git -C "$PROJECT_ROOT" diff --name-only "$GRAPH_COMMIT" HEAD -- . git -C "$PROJECT_ROOT" diff --cached --name-only -- . git -C "$PROJECT_ROOT" diff --name-only -- . git -C "$PROJECT_ROOT" ls-files --others --exclude-standard -- .- The
-- .pathspec is required: commits that only touch a sibling monorepo project must not make this graph stale. A hash mismatch alone is not stale when the project diff is empty. - The data folder lives outside the project, so no output line is a generated graph artifact: every listed path is project source drift.
- If the committed diff or any working-tree command reports project files, warn that domain extraction may omit those changes. Suggest: Run
/understandto refresh the knowledge graph. - Run the commit diff only when
GRAPH_COMMIT_RAWresolves successfully. If the graph commit or Git metadata is missing, invalid, or unavailable, give a brief best-effort warning and continue instead of blocking.
- After that preflight, proceed to Phase 3 (derive from graph).
- Otherwise (
GRAPHismissingorunreadable, or--fullwas passed), proceed to Phase 2 (lightweight scan). When--fullis used, skip this preflight because the command performs a fresh scan instead of consuming the existing graph.
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 Node preprocessing → expensive LLM gets a clean, small input → better results for less cost.
Run the preprocessing script, passing
$PROJECT_ROOTfrom Phase 0:node {{CLAUDE_DASHBOARD}}/src/understand/scripts/extract-domain-context.mjs "<PROJECT_ROOT>"This outputs
$DATA/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.)
If it exits non-zero, report its stderr and STOP.
- File tree (respecting
$DATA/intermediate/domain-context.jsonis the context for Phase 4 (Option A). Do not read it yourself: the agent reads it.- Proceed to Phase 4
Phase 3: Derive from Existing Graph (Path 2)
- Format the graph data as structured context, one record per line: 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:DATA="<DATA>"; mkdir -p "$DATA/intermediate" node - "$DATA" <<'NODE' const fs = require('fs'); const data = process.argv[2]; const g = JSON.parse(fs.readFileSync(`${data}/knowledge-graph.json`, 'utf8')); const pick = (o, keys) => Object.fromEntries(keys.filter((k) => o[k] !== undefined).map((k) => [k, o[k]])); const block = (name, items) => `"${name}": [\n${items.map((x) => JSON.stringify(x)).join(',\n')}\n]`; const parts = [ block('layers', (g.layers || []).map((l) => pick(l, ['id', 'name', 'description', 'nodeIds']))), block('tour', (g.tour || []).map((t) => pick(t, ['order', 'title', 'description', 'nodeIds']))), block('nodes', (g.nodes || []).map((n) => pick(n, ['id', 'type', 'name', 'filePath', 'summary', 'tags']))), block('edges', (g.edges || []).map((e) => pick(e, ['source', 'target', 'type']))), ]; fs.writeFileSync(`${data}/intermediate/domain-graph-context.json`, `{"project": ${JSON.stringify(g.project || {})},\n${parts.join(',\n')}\n}\n`); console.log(`Graph digest: ${(g.nodes || []).length} nodes, ${(g.edges || []).length} edges, ${(g.layers || []).length} layers, ${(g.tour || []).length} tour steps`); NODE $DATA/intermediate/domain-graph-context.jsonis the context for the domain analyzer (Option B) — no file reading needed. Do not read it yourself: the agent reads it.- Proceed to Phase 4
Phase 4: Domain Analysis
- Dispatch a subagent with the Agent tool:
subagent_type: "general-purpose",description: "understand-domain: domain-analyzer", nomodel, and thisprompt(substitute every<placeholder>; never read the agent file yourself or paste its text):Read ~/.claude/skills/understand/agents/domain-analyzer.md completely and follow it as your instructions. Context: <"Option A — Preprocessed domain context" after Phase 2, or "Option B — Existing knowledge graph" after Phase 3> Context file: <$DATA/intermediate/domain-context.json after Phase 2, or $DATA/intermediate/domain-graph-context.json after Phase 3> Project root: <PROJECT_ROOT> Git commit: <SOURCE_COMMIT, or "none" when empty> Output path: <DATA>/intermediate/domain-analysis.jsonSOURCE_COMMITis the commit the context reflects:HEAD_COMMITafter Phase 2,GRAPH_COMMIT_RAWafter Phase 3 (a domain graph derived from the map is only as fresh as the map, so the page's freshness banner stays truthful). - The agent writes its output to
$DATA/intermediate/domain-analysis.jsonand replies with a short summary.
Phase 5: Validate and Save
- Read the domain analysis output, validate it with the standard graph validation pipeline (core
validateGraph; the schema supports domain/flow/step types), and save it to$DATA/domain-graph.json. If validation finds problems, log warnings but save what's valid (error tolerance). The save also setsproject.gitCommitHashtoSOURCE_COMMITandproject.analyzedAtto now, makes absolute stepfilePaths relative to the project root, and gives everyflow_stepedge an integerorder(1, 2, 3, ... per flow: the agent'sorderfirst, then UA's weight, then file order), because the validator keeps neitherordernor anything outside its schema:
If it exits non-zero (node --input-type=module - "<DATA>" "<PROJECT_ROOT>" "<SOURCE_COMMIT>" <<'NODE' import { readFileSync, renameSync, writeFileSync } from 'node:fs'; import { basename, isAbsolute, join, relative } from 'node:path'; import { pathToFileURL } from 'node:url'; const [data, root, commit] = process.argv.slice(2); const { validateGraph } = await import(pathToFileURL('{{CLAUDE_DASHBOARD}}/src/understand/core/schema.js').href); const raw = JSON.parse(readFileSync(join(data, 'intermediate/domain-analysis.json'), 'utf8')); if (raw && raw.project && typeof raw.project === 'object') raw.project = { ...raw.project, gitCommitHash: commit || '', analyzedAt: new Date().toISOString() }; const result = validateGraph(raw); for (const issue of result.issues || []) console.log(`warning [${issue.level}] ${issue.message}`); if (!result.success) { console.error(`Domain graph not saved: ${result.fatal}`); process.exit(1); } const graph = result.data; for (const n of graph.nodes) if (typeof n.filePath === 'string' && isAbsolute(n.filePath)) n.filePath = n.filePath.startsWith(`${root}/`) ? relative(root, n.filePath) : basename(n.filePath); const asked = new Map(); for (const e of Array.isArray(raw.edges) ? raw.edges : []) if (e && Number.isInteger(e.order) && e.order > 0) asked.set(`${e.source}\n${e.target}`, e.order); const flows = new Map(); graph.edges.forEach((e, i) => { if (e.type !== 'flow_step') return; if (!flows.has(e.source)) flows.set(e.source, []); flows.get(e.source).push([asked.get(`${e.source}\n${e.target}`) ?? Infinity, e.weight, i, e]); }); for (const steps of flows.values()) steps.sort((a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2]).forEach((s, k) => { s[3].order = k + 1; }); const out = join(data, 'domain-graph.json'); writeFileSync(`${out}.tmp`, `${JSON.stringify(graph, null, 2)}\n`); renameSync(`${out}.tmp`, out); const count = (t) => graph.nodes.filter((n) => n.type === t).length; console.log(`Saved ${out}: ${count('domain')} domains, ${count('flow')} flows, ${count('step')} steps, ${graph.edges.length} edges`); NODEDomain graph not saved: <reason>, or a read or JSON error when the agent wrote no valid file), report the reason and the warnings, keep$DATA/intermediate/domain-analysis.jsonfor inspection, and STOP. - Clean up the intermediate files:
rm -f "<DATA>/intermediate/domain-analysis.json" "<DATA>/intermediate/domain-context.json" "<DATA>/intermediate/domain-graph-context.json"
Phase 6: Open the Dashboard
- Make sure claude-dashboard runs (this replaces Understand Anything's own dashboard launch):
If it says the dashboard is not running, start it in the background without opening a browser. Run this with the Bash tool'snode {{CLAUDE_DASHBOARD}}/bin/claude-dashboard.js statusrun_in_background: true: the command waits for the dashboard's transcript scan before it exits, while the server itself runs detached:
Then runnode {{CLAUDE_DASHBOARD}}/bin/claude-dashboard.js start --no-openstatusagain until it reportsRunning at .... Ifstatusreports another port (3737 was taken), use that port in the link. If the dashboard does not come up, say so, give the log pathstatusorstartprinted, and still print the link. - Report the domain, flow and step counts with the key domain names, then print the link
http://127.0.0.1:3737/understand?project=<KEY>and tell the user to switch the page to its Domain view.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

