moon task-graph [target] (or moon tg) command generates and serves a visual graph of all configured tasks as nodes, with dependencies between them as edges. The graph can be viewed in a browser or exported to Graphviz DOT format or JSON.
Synopsis
Arguments
[target]- Optional task target to focus the graph on (e.g.,app:build). When specified, only shows the focused task and its dependencies.
Options
| Option | Type | Default | Description |
|---|---|---|---|
--dependents | boolean | false | Include direct dependents of the focused task |
--dot | boolean | false | Print the graph in DOT format |
--json | boolean | false | Print the graph in JSON format |
--host | string | 127.0.0.1 | The host address for the web server |
--port | number | 0 | The 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:- Zoom and pan
- Click nodes to see task details
- Hover to see dependency information
- Color coding by task type
- Critical path highlighting
- Execution time estimates
DOT format output
Export the graph in Graphviz DOT format for external visualization:JSON format output
Export the graph structure as JSON:Usage examples
View full task graph
Show all tasks and their dependencies:Focus on a specific task
Show only the dependencies of a specific task:Include dependents
Show both dependencies and dependents (tasks that depend on it):Export to DOT file
Export and render with Graphviz:Export to JSON for analysis
Analyze the graph structure programmatically:Serve on custom host and port
Understanding the graph
Node types
Nodes represent tasks and are color-coded by type:- Build tasks - Blue (compilation, bundling)
- Test tasks - Green (unit tests, integration tests)
- Run tasks - Yellow (general execution)
- Setup tasks - Purple (initialization)
Edge types
Edges represent dependencies between tasks:- required - Task must complete before dependent can start
- optional - Dependency runs if available but isn’t blocking
Execution order
The graph visualization shows:- Serial execution - Tasks connected in a chain
- Parallel execution - Tasks at the same depth without dependencies
- Critical path - Longest chain determining total execution time
Focus mode
When focusing on a specific task:- The focused task is highlighted
- Only its dependencies are shown by default
- Use
--dependentsto also show tasks that depend on it - Useful for debugging “why does this task run?”
Common use cases
Debug task execution order
Understand why a task runs or doesn’t run:Identify bottlenecks
Find tasks that block parallel execution:Optimize CI pipelines
Visualize which tasks can run in parallel:Verify task dependencies
Ensure tasks have the correct dependencies configured:Find circular dependencies
Circular dependencies will cause the command to fail with an error:Performance insights
The interactive visualization provides:- Execution time estimates - Based on historical runs
- Critical path analysis - Longest chain of dependent tasks
- Parallelization opportunities - Tasks that could run concurrently
- Cache hit rates - For tasks that have run before
Related commands
moon task- Display information about a specific taskmoon tasks- List all tasksmoon project-graph- Visualize project dependenciesmoon run- Execute tasks following the dependency graph