CLI Workflow¶
This guide explains the typical Graphize workflow from initialization to visualization.
Basic Workflow¶
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ init │───▶│ add │───▶│ analyze │───▶│ query │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
│
▼
┌──────────┐
│ export │
└──────────┘
Step 1: Initialize¶
Creates the .graphize/ directory structure.
Step 2: Add Sources¶
Tracks the current directory as a source. You can add multiple repositories:
Step 3: Analyze¶
Extracts the AST-based graph. This is deterministic and fast.
Step 4: Query or Export¶
# Interactive queries
graphize query func_main --depth 3
# Generate report
graphize report
# Export visualization
graphize export html -o graph.html
Enhanced Workflow (with LLM)¶
┌──────────┐ ┌──────────┐ ┌──────────┐
│ analyze │───▶│ enhance │───▶│ merge │
└──────────┘ └──────────┘ └──────────┘
│
▼
┌─────────────┐
│ LLM Agent │
│ (external) │
└─────────────┘
Step 1: Analyze (AST)¶
Step 2: Enhance (Prepare for LLM)¶
This outputs a list of files that need semantic analysis.
Step 3: Run LLM Extraction¶
Using Claude Code with the /semantic-extract skill:
This:
- Reads the source files
- Analyzes for semantic relationships
- Outputs
agents/graph/semantic-edges.json
Step 4: Merge Results¶
Integrates the semantic edges into the graph with appropriate confidence levels.
Shortcut: Rebuild¶
If you've already done semantic extraction once:
This combines analyze + merge in one step.
Query Patterns¶
Graph Summary¶
Shows node/edge counts, types, and top connected nodes.
Node Exploration¶
# Show edges for a node
graphize query func_main
# BFS traversal
graphize query func_main --depth 3
# DFS traversal
graphize query func_main --depth 3 --dfs
# Direction filtering
graphize query func_main --dir out # What does it call?
graphize query func_main --dir in # What calls it?
Path Finding¶
Edge Type Filtering¶
Export Patterns¶
Interactive HTML¶
Opens a Cytoscape.js visualization with:
- Pan and zoom
- Node filtering by type
- Edge filtering by confidence
- Search functionality
TOON for Agents¶
JSON for Processing¶
Analysis Patterns¶
Full Report¶
Generates:
- Summary statistics
- God nodes (most connected)
- Community detection results
- Surprising connections
- Suggested questions
- Isolated nodes
- Package statistics
Quick Summary¶
Shorter output focused on key metrics.
Graph Comparison¶
# After making changes
graphize analyze
# Compare with previous snapshot
graphize diff --old .graphize.bak
Best Practices¶
1. Commit the Cache¶
The .graphize/cache/ directory stores per-file extraction results. Committing it speeds up re-analysis after minor changes.
2. Exclude Large Generated Files¶
Add patterns to your source tracking to exclude generated code:
3. Use TOON for AI Agents¶
TOON format is ~8x more token-efficient than JSON:
4. Incremental Updates¶
After code changes:
graphize status # Check what changed
graphize analyze # Re-extract (uses cache)
graphize report # Update analysis
5. MCP Server for Interactive Use¶
For ongoing queries during development:
Then use Claude Desktop/Code to query the graph conversationally.