Overview
Theget_env_graph tool analyzes relationships between environment variables and returns a dependency graph. It shows:
- Which variables cluster together (used in the same files)
- Load-bearing variables (used across most of the codebase)
- Isolated variables (not related to others)
- Connection strength between variables
Parameters
Path to the project directory. Defaults to current working directory.
Response
The environment variable dependency graph
Array of detected variable clusters
Array of load-bearing variable names (used in many files)
Array of isolated variable names (not connected to others)
Graph statistics
Scan metadata
Example Response
Usage Example
Get the dependency graph:Graph Concepts
Nodes
Each node represents an environment variable with:- usageCount: How many times it appears in code
- fileCount: How many files use it
- cluster: The functional group it belongs to
- isLoadBearing: Whether it’s used across many files
- connections: Number of related variables
Edges
Edges represent relationships between variables:- weight: Number of files where both variables are used together
- sharedFiles: Specific files creating the connection
Load-Bearing Variables
Variables used across a significant portion of the codebase. These are:- Critical to application functionality
- High-impact if misconfigured
- Should be carefully documented and validated
- Database connection strings
- API keys used throughout the app
- Environment indicators (NODE_ENV)
- Base URLs and core configuration
Isolated Variables
Variables with no connections to others. They:- Are used in isolation (single file or feature)
- May be feature flags or legacy code
- Could be candidates for removal if unused
Clusters
Groups of related variables detected by:- Co-occurrence: Used in the same files
- Naming patterns: Similar prefixes (DB_, AWS_, etc.)
- Functional grouping: Related purpose
- Database: DB_, DATABASE_, POSTGRES_, MYSQL_
- Authentication: JWT_, SESSION_, AUTH_*
- API: API_*, *_API_KEY, *_API_SECRET
- Caching: REDIS_, MEMCACHED_
- Email: SMTP_, SENDGRID_, MAILGUN_*
- Monitoring: SENTRY_, DATADOG_
- Cloud: AWS_, GCP_, AZURE_*
Use Cases
- Architecture Understanding: Visualize how configuration is organized
- Impact Analysis: Understand which variables are related before making changes
- Refactoring: Identify clusters that should be migrated together
- Documentation: Group related variables in documentation
- Dependency Tracking: See which variables depend on each other
- Migration Planning: Plan environment migrations by cluster
- Code Organization: Understand configuration structure
Visualization
The graph data can be visualized using:- Force-directed graph layouts (D3.js, Cytoscape)
- Network diagrams
- Cluster maps
- Adjacency matrices
usageCount and colored by cluster.