# The Six Agents in the Understand-Anything Multi-Agent Pipeline and Their Roles

> Explore the six agents in the Understand-Anything multi-agent pipeline: project-scanner, file-analyzer, architecture-analyzer, tour-builder, graph-reviewer, and knowledge-graph-guide. Discover their roles in transforming codeba...

- Repository: [Yuxiang Lin/Understand-Anything](https://github.com/Lum1104/Understand-Anything)
- Tags: internals
- Published: 2026-06-02

---

**The `/understand` skill orchestrates six specialized agents—project-scanner, file-analyzer, architecture-analyzer, tour-builder, graph-reviewer, and knowledge-graph-guide—that deterministically transform any codebase into a structured knowledge graph, architectural layer map, and interactive learning tour.**

The Lum1104/Understand-Anything repository implements an intelligent code comprehension system through a multi-agent pipeline. This pipeline processes raw source code through six distinct stages, each handled by a specialized agent defined in the `understand-anything-plugin/agents/` directory. Each agent consumes specific JSON inputs and produces deterministic outputs that feed directly into the next stage.

## The Six Agents Explained

### 1. Project-Scanner

The **project-scanner** agent performs the initial repository inventory. According to [`agents/project-scanner.md`](https://github.com/Lum1104/Understand-Anything/blob/main/agents/project-scanner.md), it scans the entire repository to enumerate files, detect languages and frameworks, and build a comprehensive import map.

This agent executes `scan-project.mjs` and `extract-import-map.mjs` to synthesize the project name, description, and high-level statistics. It outputs [`scan-result.json`](https://github.com/Lum1104/Understand-Anything/blob/main/scan-result.json), which serves as the foundation for subsequent analysis.

### 2. File-Analyzer

The **file-analyzer** agent processes source files in batches to extract structural and semantic information. As defined in [`agents/file-analyzer.md`](https://github.com/Lum1104/Understand-Anything/blob/main/agents/file-analyzer.md), it runs the bundled `extract-structure.mjs` script against each file descriptor.

This agent augments raw structural data with LLM-generated summaries, tags, complexity ratings, and graph edges. It produces `batch-<index>.json` files containing nodes and edges that represent the file-level semantics of the codebase.

### 3. Architecture-Analyzer

The **architecture-analyzer** agent aggregates file-level nodes to discover high-level system organization. According to [`agents/architecture-analyzer.md`](https://github.com/Lum1104/Understand-Anything/blob/main/agents/architecture-analyzer.md), it consumes all file nodes and import edges from previous stages.

This agent runs deterministic analysis scripts to identify directory groups, cross-category relationships, and import densities. It assigns every file to exactly one logical layer (typically 3-10 layers) and outputs [`layers.json`](https://github.com/Lum1104/Understand-Anything/blob/main/layers.json), creating a stratified view of the system architecture.

### 4. Tour-Builder

The **tour-builder** agent generates a pedagogical guided tour through the codebase. As specified in [`agents/tour-builder.md`](https://github.com/Lum1104/Understand-Anything/blob/main/agents/tour-builder.md), it takes the full graph plus the architectural layers as input.

This agent constructs 5-15 ordered steps that walk newcomers through the most important nodes, respecting graph topology including fan-in/fan-out metrics, entry-point rankings, and cluster structures. It outputs [`tour.json`](https://github.com/Lum1104/Understand-Anything/blob/main/tour.json) containing the sequential learning path.

### 5. Graph-Reviewer

The **graph-reviewer** agent validates and cleans the assembled knowledge graph. According to [`agents/graph-reviewer.md`](https://github.com/Lum1104/Understand-Anything/blob/main/agents/graph-reviewer.md), it processes the merged node and edge fragments from all previous stages.

This agent removes dangling edges, deduplicates nodes, and enforces schema compliance before the graph reaches the dashboard. It produces the final vetted graph JSON that represents the complete, validated knowledge representation of the codebase.

### 6. Knowledge-Graph-Guide

The **knowledge-graph-guide** agent serves as a reusable helper that generates human-readable documentation. As defined in [`agents/knowledge-graph-guide.md`](https://github.com/Lum1104/Understand-Anything/blob/main/agents/knowledge-graph-guide.md), it produces a concise guide describing the overall shape of the knowledge graph.

This agent interprets the final graph to explain top-level sections, layer interpretation methods, and common edge types. Its output is a short guide JSON consumed by the UI to help users navigate the generated knowledge representation.

## How the Pipeline Executes

The multi-agent pipeline operates as a deterministic sequence where each stage feeds the next:

```bash

# Sequential execution flow in Understand-Anything

# Stage 1: Project scanning builds the raw inventory

node scan-project.mjs
node extract-import-map.mjs

# Generates: scan-result.json

# Stage 2: File analysis enriches source files

node extract-structure.mjs

# Generates: batch-<index>.json files

# Stages 3-6: Architecture analysis, tour building, review, and guide generation

# Consumes JSON outputs and produces layers.json, tour.json, and final graph

```

1. **Project scanning** builds the raw inventory via `scan-project.mjs` and produces [`scan-result.json`](https://github.com/Lum1104/Understand-Anything/blob/main/scan-result.json).
2. **File analysis** enriches source files with semantic metadata, generating `batch-<index>.json` files.
3. **Architecture analysis** groups files into 3-10 logical layers, outputting [`layers.json`](https://github.com/Lum1104/Understand-Anything/blob/main/layers.json).
4. **Tour building** creates an educational walkthrough referencing layers and graph topology, producing [`tour.json`](https://github.com/Lum1104/Understand-Anything/blob/main/tour.json).
5. **Graph reviewing** cleans and validates the assembled graph against the schema.
6. **Knowledge-graph guide** generates the narrative UI guide describing the graph structure.

This architecture ensures that complex codebases transform into structured knowledge representations without ad-hoc scripting during execution.

## Summary

- **Project-scanner**: Initializes the pipeline by scanning repositories and building import maps, outputting [`scan-result.json`](https://github.com/Lum1104/Understand-Anything/blob/main/scan-result.json).
- **File-analyzer**: Extracts semantic structure and generates graph nodes/edges in `batch-<index>.json` files.
- **Architecture-analyzer**: Organizes files into 3-10 logical layers via [`layers.json`](https://github.com/Lum1104/Understand-Anything/blob/main/layers.json).
- **Tour-builder**: Creates pedagogical 5-15 step learning paths output as [`tour.json`](https://github.com/Lum1104/Understand-Anything/blob/main/tour.json).
- **Graph-reviewer**: Validates graph integrity, removes dangling edges, and ensures schema compliance.
- **Knowledge-graph-guide**: Generates human-readable UI guides explaining the graph topology and layer semantics.

## Frequently Asked Questions

### What inputs does the project-scanner agent require?

The project-scanner agent requires direct access to the repository file tree. It executes `scan-project.mjs` and `extract-import-map.mjs` to read the raw file structure and dependency information, requiring no prior processed data since it initiates the pipeline.

### How does the architecture-analyzer determine logical layers?

The architecture-analyzer consumes all file nodes and import edges from previous stages, then runs deterministic analysis scripts to calculate directory groups, cross-category relationships, and import densities. According to the source code in [`agents/architecture-analyzer.md`](https://github.com/Lum1104/Understand-Anything/blob/main/agents/architecture-analyzer.md), it assigns each file to exactly one of 3-10 logical layers based on these structural relationships.

### What is the difference between the graph-reviewer and knowledge-graph-guide agents?

The **graph-reviewer** functions as a validation gate that cleans technical artifacts—removing dangling edges, deduplicating nodes, and enforcing schema compliance on the final graph JSON. The **knowledge-graph-guide** serves a documentation role, generating human-readable narratives that explain graph topology, layer interpretations, and edge types for UI consumption.

### Can the multi-agent pipeline process any programming language?

The pipeline is designed to be language-agnostic through the file-analyzer's `extract-structure.mjs` script and the project-scanner's framework detection capabilities. While specific extraction scripts may vary by language, the six-agent architecture itself handles any codebase that produces the expected node-edge JSON structure and import maps.