Skip to main content
The moon project-graph [id] (or moon pg) command generates and serves a visual graph of all configured projects as nodes, with dependencies between them as edges. The graph can be viewed in a browser or exported to Graphviz DOT format or JSON.
$ moon project-graph
This command is invaluable for understanding project relationships, identifying circular dependencies, and visualizing your workspace architecture.

Synopsis

moon project-graph [id] [OPTIONS]

Arguments

  • [id] - Optional ID or alias of a project to focus the graph on, as defined in projects. When specified, only shows the focused project and its dependencies.

Options

OptionTypeDefaultDescription
--dependentsbooleanfalseInclude direct dependents of the focused project
--dotbooleanfalsePrint the graph in DOT format
--jsonbooleanfalsePrint the graph in JSON format
--hoststring127.0.0.1The host address for the web server
--portnumber0The port to bind to (0 = random available port)
--host and --port options

Example output

Interactive visualization

By default, the command starts a local web server that displays an interactive graph:
$ moon project-graph
Project graph server started at http://127.0.0.1:57823
Press Ctrl+C to stop the server
Open the URL in your browser to view the interactive graph with features like:
  • Zoom and pan
  • Click nodes to see project details
  • Hover to see dependency information
  • Filter and search functionality

DOT format output

Export the graph in Graphviz DOT format for external visualization:
$ moon project-graph --dot
digraph {
    0 [ label="(workspace)" style=filled, shape=circle, fillcolor=black, fontcolor=white]
    1 [ label="cli" style=filled, shape=circle, fillcolor=gray, fontcolor=black]
    2 [ label="runtime" style=filled, shape=circle, fillcolor=gray, fontcolor=black]
    3 [ label="types" style=filled, shape=circle, fillcolor=gray, fontcolor=black]
    4 [ label="website" style=filled, shape=circle, fillcolor=gray, fontcolor=black]
    0 -> 1 [ arrowhead=none]
    0 -> 2 [ arrowhead=none]
    0 -> 3 [ arrowhead=none]
    0 -> 4 [ arrowhead=none]
    2 -> 3 [ arrowhead=box]
    4 -> 2 [ arrowhead=box]
}

JSON format output

Export the graph structure as JSON:
$ moon project-graph --json
{
  "nodes": [
    {
      "id": "runtime",
      "label": "runtime",
      "source": "packages/runtime"
    },
    {
      "id": "types",
      "label": "types",
      "source": "packages/types"
    }
  ],
  "edges": [
    {
      "source": "runtime",
      "target": "types",
      "type": "production"
    }
  ]
}

Usage examples

View full project graph

$ moon project-graph

Focus on a specific project

Show only the dependencies of a specific project:
$ moon project-graph app

Include dependents

Show both dependencies and dependents of a project:
$ moon project-graph app --dependents

Export to DOT file

$ moon project-graph --dot > graph.dot
Then render with Graphviz:
$ dot -Tpng graph.dot -o graph.png

Export to JSON for analysis

$ moon project-graph --json | jq '.nodes | length'

Serve on custom host and port

$ moon project-graph --host 0.0.0.0 --port 8080
This makes the graph accessible from other machines on your network.

Understanding the graph

Node types

  • Workspace root - Black circle representing the workspace root
  • Projects - Gray circles representing individual projects

Edge types

  • Workspace membership - Lines from workspace to projects (no arrowhead)
  • Dependencies - Arrows between projects showing dependency relationships
    • Production - Solid line
    • Development - Dashed line (if applicable)
    • Peer - Dotted line (if applicable)

Focus mode

When focusing on a specific project:
  • The focused project is highlighted
  • Only its dependencies are shown by default
  • Use --dependents to also show projects that depend on it

Configuration

Build docs developers (and LLMs) love