| name | code-analyzer |
| description | Analyze code structure - functions, classes, imports, call relationships, community detection. Pure code analysis, no LLM needed. |
| trigger | /code-analyzer |
/code-analyzer
Analyze a codebase and extract structural information: files, functions, classes, imports, call relationships, and community clusters.
Usage
/code-analyzer <path> # Full analysis → JSON output
/code-analyzer <path> -o json # Output JSON to stdout
/code-analyzer <path> -o file # Write to code_graph.json
/code-analyzer <path> -o both # Both stdout and file (default)
/code-analyzer <path> -t calls # Only call relationships
/code-analyzer <path> -t definitions # Only function/class definitions
/code-analyzer <path> -t all # All output types (default)
/code-analyzer <path> -u # Incremental update (only changed files)
/code-analyzer <path> --langs python,js # Filter by languages
/code-analyzer <path> -v # Verbose output
What code-analyzer provides
- structure: Project file tree with line counts
- definitions: All functions and classes with file:line locations
- calls: Function call relationships (who calls whom)
- imports: Import/export relationships between files
- clusters: Community detection grouping related files
- stats: Statistics (files, functions, classes, lines of code)
When to use
- Understanding a new codebase quickly
- Finding which functions call which other functions
- Identifying the main classes and their relationships
- Finding circular dependencies or tightly coupled modules
- When you need code structure without reading every file
Output format
JSON with the following structure:
{
"meta": {
"path": "/path/to/project",
"timestamp": "1234567890",
"languages": ["python", "javascript"],
"incremental": false
},
"structure": {
"files": [{"path": "src/main.py", "size": 1234, "lines": 100, "language": "python"}],
"directories": ["src", "tests"]
},
"definitions": {
"functions": [{"name": "main", "file": "src/main.py", "line": 10, "params": ["arg1"]}],
"classes": [{"name": "Config", "file": "src/config.py", "line": 5, "methods": ["load", "save"]}]
},
"calls": {
"edges": [{"from": "src/main.py:main", "to": "src/utils.py:helper", "type": "direct"}]
},
"imports": {
"edges": [{"from": "src/main.py", "to": "src/config.py", "symbol": "Config"}]
},
"clusters": [
{"id": 0, "members": ["src/main.py", "src/utils.py"], "cohesion": 0.85}
],
"stats": {
"total_files": 50,
"total_functions": 120,
"total_classes": 30,
"lines_of_code": 5000
}
}
Supported languages
Python, JavaScript, TypeScript, Java, C, C++, Go, Rust
Examples
Quick overview
/code-analyzer ./myproject
Get only call relationships
/code-analyzer ./myproject -t calls -o json
Find all classes and methods
/code-analyzer ./myproject -t definitions
Incremental update (after code changes)
/code-analyzer ./myproject -u
Notes
- This tool does pure code analysis using regex/parsing - no LLM involved
- It's fast and suitable for large codebases
- For semantic understanding (why this code exists, design rationale), use the AI Agent directly
- The JSON output can be passed to an AI Agent for further analysis or to build a knowledge graph