Understand Anything

repository·main·Indexed 13 days ago

https://github.com/egonex-ai/understand-anything

An open-source AI-powered analysis tool that combines LLM intelligence with Tree-sitter static analysis to convert codebases and documentation into interactive, searchable knowledge graphs. It provides visual architecture maps, business logic flows, and semantic search capabilities via an interactive web dashboard. The tool is available as a plugin for Claude Code, GitHub Copilot, and other AI CLI/IDE platforms, and includes a standalone read-only viewer for generated graphs.

Tokens
192.9K
Snippets
441
Records
762
Agent score
100%

What's inside Understand Anything

  1. Overview of Understand Anything

    main

    Understand Anything is a tool that transforms codebases, knowledge bases, or documentation into interactive knowledge graphs. It uses a multi-agent pipeline to analyze projects, building a graph of files, functions, classes, and dependencies. This allows developers to visually explore code, search semantically, and understand business logic through different representations.

    Key capabilities include:

    • Structural Graph Exploration: Navigate code as a graph where nodes (files, functions, classes) provide descriptions and connections.
    • Business Logic Mapping: View code mapped to real-world business processes (domains, flows, and steps).
    • Knowledge Base Analysis: Use /understand-knowledge on LLM-style wikis to generate force-directed graphs with community clustering.
    • Guided Overviews: Automatically generated architectural tours ordered by dependencies.
    • Semantic Search: Find code by name or meaning (e.g., "what parts handle authorization?").
    • Impact Analysis: Visualize how changes might affect the system before committing.
    • Layer Visualization: Automatic grouping by architectural layers (API, Service, Data, UI, Utility).

    It is compatible with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and others.

  2. Understand the core features of Understand Anything

    main

    Understand Anything provides a suite of tools for visualizing and analyzing codebases and complex projects. The core feature set includes:

    • Interactive Knowledge Graph: Visualize files, functions, and dependencies as an explorable graph with hierarchical drill-down and smart layout.
    • Beyond Code Analysis: Analyze entire projects including Dockerfiles, Terraform, SQL, Markdown, and 26+ other file types mapped into a unified graph.
    • Smart Filtering & Search: Filter by node type, complexity, layer, or edge category. Supports fuzzy and semantic search.
    • Export & Share: Export knowledge graphs as high-quality PNG, SVG, or filtered JSON for documentation or presentations.
    • Dependency Path Finder: Find the shortest path between any two components to understand system connections.
    • Guided Tours & Onboarding: AI-generated walkthroughs and onboarding guides for new team members.
  3. Understand Anything Core Features

    main

    Understand Anything transforms codebases, knowledge bases, or documentation into interactive, searchable, and conversational knowledge graphs. Key capabilities include:

    • Code Structure Exploration: Visualizes files, functions, and classes as interactive nodes with summaries and dependency paths.
    • Business Logic Mapping: A domain view that maps code to real-world business processes using horizontal diagrams (domains, flows, and steps).
    • Knowledge Base Analysis: Analyzes 'Karpathy-style' LLM Wikis (using index.md with wikilinks) to create interconnected thought maps.
    • Guided Learning: Automatically generates architectural learning paths based on dependency order.
    • Semantic Search: Supports fuzzy and semantic queries (e.g., "Which parts handle authentication?").
    • Change Impact Analysis: Visualizes how code changes affect the rest of the system.
    • Hierarchical Visualization: Automatically groups components into layers like API, Service, Data, UI, and System Tools.
    • Adaptive UI: Adjusts detail levels based on user roles (Junior Developer, Project Manager, or Advanced User).
  4. Understand Anything Overview

    main
    Understand Anything is a Claude Code plugin that transforms codebases, knowledge bases, and documentation into interactive knowledge graphs. It uses a multi-agent pipeline to analyze projects, mapping files, functions, classes, and dependencies. This allows developers to visually explore structural graphs, understand business logic via domain views, and perform semantic searches. It is designed to support various platforms including Claude Code, Codex, Cursor, Copilot, and Gemini CLI.
  5. Project structure and package overview

    main

    The project is organized as a monorepo using pnpm workspaces with the following key packages:

    • @understand-anything/core: The analysis engine containing shared types, persistence logic, tree-sitter plugins, and LLM prompt templates.
    • @understand-anything/dashboard: A React + TypeScript web dashboard for visualizing the knowledge graph using React Flow and Monaco Editor.
    • @understand-anything/skill: A Claude Code skill (implementation pending).
  6. Overview of the /understand-figma skill

    main

    The /understand-figma skill is an extension for the Understand Anything plugin that transforms Figma files into an interactive knowledge graph. It creates a structural model consisting of pages, screens, components, component sets, instances, and design tokens. This graph is visualized in the dashboard using a kind: "design" layout.

    Key features include:

    • Shallow Structural Graph: Focuses on high-level hierarchy (page → screen → component / componentSet / instance) rather than every individual Figma layer.
    • Design System Modeling: Represents colors, typography, spacing, and effects as token nodes connected via uses_token edges.
    • LLM Enrichment: Uses a design-analyzer agent to add semantic meaning like summaries, tags, and screen purposes.
    • Hybrid Rendering: Uses lightweight text nodes for the graph and on-demand thumbnails in the sidebar.
  7. How the GenericTreeSitterPlugin works

    main

    The GenericTreeSitterPlugin provides language-agnostic structural analysis. Instead of hardcoded logic, it uses the LanguageRegistry to fetch a LanguageConfig and then extracts nodes (functions, classes, imports, etc.) based on the nodeTypes defined in that config.

    If a customAnalyzer is provided in the LanguageConfig, the plugin will bypass generic extraction and use that custom function to analyze the AST instead.

    // Example of how the plugin uses the config
    async analyzeFile(filePath: string, content: string): Promise<FileAnalysis> {
      const config = this.registry.getByExtension(path.extname(filePath));
    
      if (config.customAnalyzer) {
        return config.customAnalyzer(tree.rootNode);
      }
    
      const functions = this.extractNodes(tree, config.treeSitter.nodeTypes.function);
      const classes = this.extractNodes(tree, config.treeSitter.nodeTypes.class);
      // ...
    }
  8. Identify Ruby language patterns and concepts

    main

    When using Understand Anything to analyze Ruby codebases, the system leverages specific language concepts to build its structural graph. Key concepts to look for in Ruby code include:

    • Blocks/Procs/Lambdas: Callable objects (blocks are implicit, procs/lambdas are explicit).
    • Mixins (include/extend): Modules used to share behavior across classes without inheritance.
    • Metaprogramming: Dynamic method definition (define_method) and interception (method_missing).
    • Duck Typing: Behavior-based object definition rather than class-based.
    • DSLs: Domain-specific languages built via blocks and metaprogramming.
    • Monkey Patching/Open Classes: Reopening existing classes to modify methods at runtime.
    • Symbols: Immutable identifiers (e.g., :name).
    • Enumerable Module: Mixin providing collection methods like map, select, and reduce (requires each).
  9. Analyze Knowledge Bases with /understand-knowledge

    main

    You can transform an LLM-style wiki (like a Karpathy-style LLM wiki) into a navigable knowledge graph. The process uses a deterministic parser to extract wikilinks and categories from index.md, while LLM agents identify implicit connections, extract entities, and identify assertions. This results in a force-directed graph with community clustering.

    To use this feature, target your knowledge base with the command: /understand-knowledge

    `/understand-knowledge`
  10. Map Django architectural layers

    main

    Assign detected Django components to these specific architectural layers to maintain a consistent structural model:

    • layer:api: API Layer (views.py, serializers.py, urls.py, DRF ViewSets/APIViews)
    • layer:data: Data Layer (models.py, migrations/, database utilities)
    • layer:service: Service Layer (signals.py, tasks.py, custom managers, service modules)
    • layer:ui: UI Layer (templates/, forms.py, templatetags/)
    • layer:middleware: Middleware Layer (middleware.py, permissions.py, authentication backends)
    • layer:config: Config Layer (settings.py, urls.py (root), wsgi.py, asgi.py, apps.py, manage.py)
    • layer:test: Test Layer (tests.py, tests/ directory, conftest.py)
  11. How /understand-domain handles existing knowledge graphs

    main

    When running /understand-domain without the --full flag, the skill checks the freshness of the existing knowledge graph before deciding whether to derive knowledge from it or perform a new scan.

    Freshness Check Logic

    1. It retrieves the project.gitCommitHash from the existing graph metadata.
    2. It compares this hash against the current git rev-parse HEAD.
    3. It inspects the project for:
      • Committed changes since the graph was created.
      • Uncommitted (working-tree) changes.
      • Untracked files.

    Note: If the project has changed (e.g., new files or modified code) but the graph is technically 'fresh' based on the commit hash, the skill may warn that domain extraction might omit those uncommitted changes. In such cases, it is recommended to run /understand first to refresh the primary knowledge graph.

  12. Understand the LanguageConfig schema

    main

    The LanguageConfig object is the core definition for making the system language-agnostic. It defines how a specific language is parsed using Tree-sitter and what high-level concepts it contains.

    Key fields include:

    • id: Unique identifier for the language (e.g., python).
    • displayName: Human-readable name.
    • extensions: Array of file extensions associated with the language (e.g., ['.py', '.pyi']).
    • treeSitter: Configuration for the Tree-sitter parser:
      • grammarPackage: The name of the grammar package.
      • wasmFile: The path to the .wasm file.
      • nodeTypes: Mapping of language constructs to Tree-sitter node names (e.g., function, class, import, export, typeAnnotation).
    • concepts: An array of domain-specific terms used for prompting (e.g., ['decorators', 'generators']).
    • filePatterns: (Optional) A record mapping configuration types to filenames (e.g., { config: 'pyproject.toml' }).
    const config = {
      id: "python",
      displayName: "Python",
      extensions: [".py", ".pyi"],
      treeSitter: {
        grammarPackage: "tree-sitter-python",
        wasmFile: "tree-sitter-python.wasm",
        nodeTypes: {
          function: ["function_definition"],
          class: ["class_definition"],
          import: ["import_statement", "import_from_statement"],
          export: [],
          typeAnnotation: ["type"],
        },
      },
      concepts: ["decorators", "list comprehensions", "generators"],
    };