Skip to main content
The onboard-builder module generates a self-contained markdown onboarding document from a KnowledgeGraph. The output is suitable for a README, wiki page, or documentation site and includes a project overview, architectural layers, key concepts, a guided tour, a file map, and complexity hotspots.

buildOnboardingGuide

Generates a structured onboarding guide from the knowledge graph.
export function buildOnboardingGuide(graph: KnowledgeGraph): string
graph
KnowledgeGraph
required
The full knowledge graph produced by the analysis pipeline. All fields are used: project, nodes, edges, layers, and tour.

Return value

Returns a string containing a complete markdown document. The document is self-contained and does not reference any external files.

Output structure

The guide is assembled from up to six sections. Sections are omitted when the relevant data is empty.

Project overview

Always present. Contains a summary table:
# My Project

> A short project description.

| | |
|---|---|
| **Languages** | TypeScript, Python |
| **Frameworks** | React, Express |
| **Components** | 42 nodes, 87 relationships |
| **Last Analyzed** | 2025-01-15T10:30:00Z |

Architecture

Present when graph.layers is non-empty. Each layer gets a ### heading with its description and a comma-separated list of key component names.

Key Concepts

Present when the graph contains nodes of type "concept". Each concept node gets a ### heading with its summary.

Getting Started

Present when graph.tour is non-empty. Renders the guided tour steps in order. Each step shows:
  • Step number and title
  • Description
  • File list with node summaries (node.filePath is required per entry)
  • Optional language tip in a blockquote (step.languageLesson)

File Map

Present when nodes of type "file" with a filePath exist. Renders a markdown table:
| File | Purpose | Complexity |
|------|---------|------------|
| `src/auth.ts` | Handles JWT auth | moderate |

Complexity Hotspots

Present when nodes with complexity === "complex" exist. Lists each complex node with its type and summary so new contributors know where to be careful.

Usage

import { buildOnboardingGuide, loadGraph } from "@understand-anything/core";
import { writeFileSync } from "node:fs";

// loadGraph takes the project root directory (not a file path)
// Returns null if no graph exists yet — run /understand first
const graph = loadGraph(process.cwd());
if (!graph) throw new Error("No knowledge graph found. Run /understand first.");

const guide = buildOnboardingGuide(graph);

// Write to a file
writeFileSync("ONBOARDING.md", guide, "utf-8");
The document ends with a footer crediting the Understand Anything tool and the graph version:
---

*Generated by [Understand Anything](https://github.com/Lum1104/Understand-Anything) from knowledge graph v1.0.0*

Build docs developers (and LLMs) love