Part of the Guard8.ai ecosystem, FlowGuard provides comprehensive code structure analysis for 19 programming languages using tree-sitter parsing with a modern modular architecture.
- Git
- Node.js and npm (for tree-sitter CLI)
- Bash shell
# 1. Clone the repository
git clone https://github.com/Guard8-ai/FlowGuard.git
cd FlowGuard
# 2. Run the installer (interactive mode)
./install.sh
# 3. Analyze your first file
./flowguard.sh src/main.rs # Local installation# Install FlowGuard globally (requires sudo)
sudo ./install.sh --system
# Now use from anywhere without path
flowguard app.py # Works from any directory
flowguard script.js # No ./flowguard.sh needed
flowguard --list-languages # Show all 19 supported languages# Interactive language selection (recommended)
./install.sh
# System-wide installation (requires sudo)
sudo ./install.sh --system
# Install all 19 languages at once
./install.sh --all
# Install specific languages only
./install.sh rust python javascript
# Install global Claude Code slash command (uses system flowguard if available)
./install.sh --claude-command
# Check what's already installed
./install.sh --installed| Category | Languages | Syntax Elements |
|---|---|---|
| Systems | Rust, C, C++, Go | functions, structs, impls, namespaces |
| High-level | Python, JavaScript, TypeScript, Java, C# | functions, classes, methods, interfaces |
| Other Languages | PHP, Ruby, Swift, Scala, Haskell | functions, classes, modules |
| Web | HTML, CSS | elements, rules |
| Config/Data | JSON, TOML | objects, arrays, tables |
| Scripting | Bash | functions, statements |
Total: 19 languages with embedded configuration
- Enhanced Flow Diagrams: Language-specific diagrams with complexity ratings
- Advanced Metrics: Cyclomatic/cognitive complexity with ratings (Simple/Moderate/Complex/Very Complex)
- Call Graph Analysis: Function hierarchy with parameter types and dependencies
- Parameter/Type Analysis: Function signatures with type information
- Async/Await Detection: Cross-language async operation analysis
- Memory Pattern Analysis: Smart pointer usage (Rust), allocation tracking (C/C++)
- Error Handling Paths: Visual representation of exception handling flows
FlowGuard/
├── flowguard.sh # ✅ NEW: Modular multi-language analyzer (19 languages)
├── install.sh # ✅ NEW: Automated installation script
├── lib/ # ✅ ENHANCED: Modular components directory
│ ├── flowguard_config.sh # Language configuration and constants
│ ├── flowguard_utils.sh # Utility functions (logging, detection)
│ ├── flowguard_parser.sh # Enhanced parsing with async/memory analysis
│ ├── flowguard_extractors.sh # Enhanced extraction with parameters/types
│ ├── flowguard_diagrams.sh # Enhanced diagrams with complexity metrics
│ ├── flowguard_metrics.sh # ✅ NEW: Complexity calculations
│ └── flowguard_callgraph.sh # ✅ NEW: Call graph generation
├── language_config.yaml # External language configuration
├── tree-sitter-*/ # 19 installed language grammar directories
├── analyze_code_structure.sh # Legacy: Rust-only analyzer
├── CLAUDE.md # Claude Code guidance
├── README.md # This file
└── flowguard_analysis/ # Analysis output (created next to analyzed file)
✅ Successfully Tested - The script has been thoroughly tested by analyzing itself:
- Language Detection: Correctly identified bash from file extension
- Parse Tree Generation: 2065-line parse tree generated successfully
- Function Detection: Found 16 function definitions accurately
- Control Flow: Detected 6 for-statement loops
- Complexity Analysis: 83 statements, 38 comments, 24 nesting levels
- Output Generation: All 4 analysis files created with proper timestamps
Test Command: ./flowguard.sh flowguard.sh (modular version)
- Automatically detects programming language from file extension
- Supports manual language override
- Handles special files (Dockerfile, Makefile, etc.)
- Extracts functions, classes, interfaces, structs
- Identifies control flow patterns
- Analyzes complexity metrics
- Generates comprehensive reports
For each analysis, generates 11 comprehensive report files in flowguard_analysis/ directory (created next to the analyzed file):
Core Analysis:
full_parse_tree_[filename]_[lang]_[timestamp].txt- Complete syntax treeconstructs_[filename]_[lang]_[timestamp].txt- Language-specific elementscontrol_flow_[filename]_[lang]_[timestamp].txt- Control flow analysissummary_[filename]_[lang]_[timestamp].txt- Enhanced metrics and counts
Enhanced Phase 1 Features:
flow_diagram_[filename]_[lang]_[timestamp].txt- Enhanced execution flow with complexitymetrics_[filename]_[lang]_[timestamp].txt- ✅ NEW: Comprehensive complexity metricscallgraph_[filename]_[lang]_[timestamp].txt- ✅ NEW: Call graph analysis with dependenciescomprehensive_diagram_[filename]_[lang]_[timestamp].txt- ✅ NEW: All-in-one enhanced diagram
Detailed Analysis:
parameters_[filename]_[lang]_[timestamp].txt- ✅ NEW: Function parameter analysisreturn_types_[filename]_[lang]_[timestamp].txt- ✅ NEW: Return type analysisasync_patterns_[filename]_[lang]_[timestamp].txt- ✅ NEW: Async/await pattern detection
# Check if you have the required tools
git --version # Need: Git
node --version # Need: Node.js v12+
npm --version # Need: npm (comes with Node.js)If missing any prerequisites:
- Git: Install from https://git-scm.com/
- Node.js: Install from https://nodejs.org/ (includes npm)
# Clone and enter directory
git clone https://github.com/Guard8-ai/FlowGuard.git
cd FlowGuard
# Run interactive installer
./install.sh
# Follow the menu to select languages# Install everything at once
./install.sh --all# Install globally for all users
sudo ./install.sh --system
# Verify installation
flowguard --version
flowguard --list-languages# Install only specific languages you need
./install.sh rust python javascript go
# Add more languages later
./install.sh java typescript cpp# Install Claude Code slash command
./install.sh --claude-command
# Check what's already installed
./install.sh --installed
# Get help
./install.sh --helpThe installation script automatically:
- ✅ Checks and installs tree-sitter CLI via npm
- ✅ Downloads only requested language grammars from GitHub
- ✅ Provides interactive language selection menu
- ✅ Optionally installs system-wide at
/usr/local/bin/flowguard - ✅ Sets up Claude Code integration with automatic fallback
- ✅ Validates existing installations
- ✅ Handles all dependencies and setup
# 1. Install tree-sitter CLI
npm install -g tree-sitter-cli
# 2. Clone specific grammar repositories
git clone https://github.com/tree-sitter/tree-sitter-rust tree-sitter-rust
git clone https://github.com/tree-sitter/tree-sitter-python tree-sitter-python
# ... repeat for each language needed
# 3. Verify installation
./flowguard.sh --list-languagesNote: Manual installation requires cloning each grammar repository individually. The install.sh script automates this process.
# After installation, analyze your first file
./flowguard.sh examples/hello.py # Local installation
flowguard examples/hello.py # System-wide installation
# View the generated analysis
ls flowguard_analysis/ # See all output files
cat flowguard_analysis/summary_*.txt # View summary# Auto-detect language from file extension
flowguard src/main.py # Python
flowguard app.js # JavaScript
flowguard main.go # Go
flowguard Main.java # Java
# Or use local installation
./flowguard.sh src/main.py
# Example output:
# [LANGUAGE] Auto-detected language: python
# [SUCCESS] Enhanced analysis complete for python! Generated files:
# CORE ANALYSIS:
# - Parse tree: src/flowguard_analysis/full_parse_tree_main_python_20250915_163000.txt
# - Language constructs: src/flowguard_analysis/constructs_main_python_20250915_163000.txt
# - Control flow: src/flowguard_analysis/control_flow_main_python_20250915_163000.txt
# - Summary: src/flowguard_analysis/summary_main_python_20250915_163000.txt
# ENHANCED PHASE 1 FEATURES:
# - Enhanced flow diagram: src/flowguard_analysis/flow_diagram_main_python_20250915_163000.txt
# - Complexity metrics: src/flowguard_analysis/metrics_main_python_20250915_163000.txt
# - Call graph analysis: src/flowguard_analysis/callgraph_main_python_20250915_163000.txt
# - Comprehensive diagram: src/flowguard_analysis/comprehensive_diagram_main_python_20250915_163000.txt
# And 3 additional detailed analysis files...# Analyze file with specific language (system-wide)
flowguard config.txt yaml
flowguard script typescript
# Or local installation
./flowguard.sh config.txt yaml
./flowguard.sh script typescript# Show supported languages and extensions (system-wide)
flowguard --list-languages
# Show help
flowguard --help
# Or local installation
./flowguard.sh --list-languages
./flowguard.sh --help# After installing with ./install.sh --claude-command
# Use in any Claude Code conversation
/flowguard src/app.js- ✅ Understand codebase structure (modular architecture with lib/ components)
- ✅ Identify complexity hotspots (function analysis across 19 languages)
- ✅ Extract API signatures (function definitions, classes, interfaces)
- ✅ Generate documentation (comprehensive reports with metrics)
- ✅ Supports HalluciGuard development (modular script architecture)
- ✅ Analyzes Guard8.ai tool projects (19 languages supported)
- ✅ Provides cross-language insights (unified analysis approach)
- ✅ Enables comprehensive auditing (detailed parse trees and summaries)
- ✅ Easy installation (automated install.sh script)
- ✅ Pre-commit analysis (fast analysis with timestamped output)
- ✅ Code review assistance (constructs and control flow extraction)
- ✅ Refactoring planning (complexity indicators and nesting depth)
- ✅ Architecture documentation (automated reporting)
- HalluciGuard - AI hallucination detection system
- Guard8.ai Ecosystem - Security and AI monitoring tools
This tool is part of the Guard8.ai ecosystem. For contributions or issues, please follow the Guard8.ai development guidelines.
Proprietary - Guard8.ai
Guard8.ai FlowGuard - Comprehensive multi-language code structure analysis powered by tree-sitter.