graph-export-mermaid
Installation
SKILL.md
Export Graph as Mermaid Diagram
Export a single file's internal graph structure from .code-graph/graph.db as a Mermaid flowchart in a markdown file.
Prerequisites
- Graph must be built first: run
/graph-buildif.code-graph/graph.dbdoesn't exist - Requires Python 3.10+ with tree-sitter, tree-sitter-language-pack, networkx
Steps
-
Export file graph as Mermaid — Run via Bash (positional or
--fileflag both work):python .claude/scripts/code_graph export-mermaid <relative-path> --json # OR python .claude/scripts/code_graph export-mermaid --file <relative-path> --jsonDefault output:
.code-graph/<path-based-unique-name>-graph.md(e.g.,docs--project-config-graph.md) -
Custom output path (optional):
python .claude/scripts/code_graph export-mermaid <relative-path> -o custom-path.md --json -
Report results: File path, node count, edge count.
Output Format
# Graph: src/auth.py
```mermaid
flowchart TD
subgraph auth_py["auth.py"]
login["login()"]
validate["validate()"]
hash_password["hash_password()"]
subgraph AuthService["AuthService"]
authenticate["authenticate()"]
end
end
login -->|calls| validate
login -->|calls| hash_password
authenticate -->|calls| validate
```
What's Included
- Functions, classes, and test functions within the file
- Internal call relationships (both caller and callee in the file)
- Class membership shown via nested subgraphs
- Edge types: calls, imports, inherits, implements, tests, depends
- Non-code files (markdown, JSON): renders outgoing and incoming
IMPORTS_FROMedges as a reference graph
What's Excluded
- External/stdlib function calls (e.g.,
parseInt,trim) - Cross-file relationships for code files (callers from other files)
- CONTAINS edges (shown structurally via subgraphs instead)
Implicit Edge Types
Mermaid diagrams include implicit edges when present in the graph:
MESSAGE_BUSedges show cross-service message flowTRIGGERS_EVENTedges show entity-to-event-handler relationshipsAPI_ENDPOINTedges show frontend-to-backend API connections
These edges are rendered alongside structural edges (CALLS, IMPORTS_FROM, INHERITS).
Use Cases
- Visualize a file's internal function call graph
- Understand code structure before refactoring
- Document architecture in markdown-compatible format
- Review file complexity and coupling
Weekly Installs
2
Repository
duc01226/easyplatformGitHub Stars
6
First Seen
11 days ago
Security Audits
Installed on
amp2
cline2
opencode2
cursor2
kimi-cli2
warp2