Visualize Python control flow directly inside Visual Studio Code.
GUY parses Python code, builds an interactive control-flow graph (CFG), and connects the graph back to your source code. Use it to understand branching logic, inspect complexity, and explore independent execution paths without leaving VS Code.
- Generate a CFG from an entire Python file, a selected code range, or the function under the cursor.
- Explore the graph in an interactive preview with zoom, fit, center, and layout controls.
- Switch between simplified and detailed graph views.
- Navigate between graph nodes, edges, functions, independent paths, and source code.
- Inspect cyclomatic complexity, nodes, edges, decisions, and connected components.
- Highlight source code when selecting graph items.
- Get lightweight complexity suggestions and visual warnings for large graphs.
- Understand common Python constructs including
if/elif/else,for,while,return,break, andcontinue.
Clone the repository, install dependencies, and open it in VS Code:
git clone https://github.com/gm64x/guy-vscode.git
cd guy-vscode
npm install
npm run compilePress F5 in VS Code to launch an Extension Development Host with GUY enabled.
- Open a Python file.
- Open the Command Palette (
Ctrl+Shift+P/Cmd+Shift+P). - Run GUY: Generate CFG from File.
For a focused view, select Python code and run GUY: Generate CFG from Selection, or place the cursor inside a function and run GUY: Generate CFG from Current Function.
| Command | Description |
|---|---|
GUY: Generate CFG from File |
Builds a graph for the active Python file. |
GUY: Generate CFG from Selection |
Builds a graph for the selected Python code. |
GUY: Generate CFG from Current Function |
Builds a graph for the function containing the cursor. |
GUY: Toggle Simplified/Detailed CFG View |
Switches the current graph between simplified and detailed mode. |
The file command is also available in the Python editor title bar. Selection and current-function commands are available in the Python editor context menu.
The CFG preview provides:
- an interactive graph canvas with pan, zoom, fit, center, and reset controls;
- a sidebar for nodes, edges, functions, and independent paths;
- a metrics panel with the cyclomatic complexity formula;
- source navigation and highlighting from graph selections;
- a simplified/detailed view toggle.
Configure GUY through Settings or settings.json:
| Setting | Default | Description |
|---|---|---|
guy.autoOpenPreview |
true |
Open the CFG preview automatically after generation. |
guy.graphLayout |
top-bottom |
Default graph direction: top-bottom or left-right. |
guy.showMetricsPanel |
true |
Show the metrics panel in the preview. |
guy.highlightCodeOnNodeClick |
true |
Highlight source code when nodes or edges are selected. |
guy.maxNodesBeforeWarning |
100 |
Warn when a graph exceeds this number of nodes. |
guy.highComplexityThreshold |
10 |
Complexity threshold for lightweight suggestions. |
- Visual Studio Code
^1.120.0. - Python source files (
.pyorpythonlanguage mode).
npm install
npm run compile
npm testCreate a production bundle with:
npm run packageExample Python inputs are available in src/examples.
- CFG generation currently supports Python only.
- Source with syntax errors may produce incomplete graphs because of parser recovery.
- Independent paths are hidden for very large graphs to keep the preview responsive.