# Complete Environment Variable Reference for Configuring code-review-graph

> Find the complete environment variable reference for code-review-graph configuration in constants.py and USAGE.md. Learn about storage paths, embedding, parsing, and resource limits.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: api-reference
- Published: 2026-08-14

---

**The complete environment variable reference for code-review-graph is defined in [`code_review_graph/constants.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/constants.py) and documented in [`docs/USAGE.md`](https://github.com/tirth8205/code-review-graph/blob/main/docs/USAGE.md), covering storage paths, embedding providers, parser settings, and resource limits.**

The `code-review-graph` ecosystem is designed to be configured entirely through environment variables, allowing you to customize data storage, embedding providers, and processing behavior without modifying source code. All configuration options use the `CRG_` prefix and are read at startup via `os.getenv` with sensible defaults defined in the constants module. This article provides a comprehensive reference for every available variable based on the source code implementation in the `tirth8205/code-review-graph` repository.

## Central Configuration in constants.py

### How Environment Variables Are Loaded

According to the `tirth8205/code-review-graph` source code, the canonical definitions for all configuration variables live in [`code_review_graph/constants.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/constants.py). Each variable name is declared alongside its default fallback value. When a variable is unset or empty, the implementation normalizes the string and applies the default (for example, `CRG_DATA_DIR` defaults to `<repo>/.code-review-graph` when unspecified).

## Repository and Storage Variables

Control where the tool stores its graph database and registry files:

- **CRG_HOME**: Overrides the location of the central registry directory.
- **CRG_DATA_DIR**: Specifies the path for the graph database files; defaults to a `.code-review-graph` subdirectory within the repository.
- **CRG_REPO_ROOT**: Forces a custom Git root path when the autodetection logic needs to be overridden.

## Parser Control and Parallelism

Configure how the codebase parser executes and utilizes system resources:

- **CRG_SERIAL_PARSE**: Set to `1` to force serial parsing instead of parallel execution (useful for debugging).
- **CRG_PARSE_EXECUTOR**: Chooses the execution backend, accepting either `process` or `thread`.
- **CRG_PARSE_WORKERS**: Sets the number of parallel workers for parsing operations.

## Embedding Provider Configuration

The [`code_review_graph/embeddings.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/embeddings.py) module selects embedding providers based on the following variables. Cloud providers emit a warning unless explicitly acknowledged.

**Local Models:**
- **CRG_EMBEDDING_MODEL**: Specifies a local sentence-transformer model name (e.g., `sentence-transformers/all-MiniLM-L6-v2`).

**OpenAI-Compatible Endpoints:**
- **CRG_OPENAI_BASE_URL**: The API endpoint URL (e.g., `https://api.openai.com/v1`).
- **CRG_OPENAI_API_KEY**: Authentication key for the API.
- **CRG_OPENAI_MODEL**: Model identifier (e.g., `text-embedding-3-small`).
- **CRG_OPENAI_DIMENSION**: Vector dimensionality (e.g., `1536`).
- **CRG_OPENAI_BATCH_SIZE**: Number of embeddings to request per batch.

**Voyage AI Specific:**
- **CRG_VOYAGE_MODEL**: Model name for Voyage embeddings.
- **CRG_VOYAGE_BASE_URL**: Custom base URL for Voyage API.
- **CRG_VOYAGE_OUTPUT_DIMENSION**: Desired output dimension for Voyage embeddings.

**Cloud Provider Safety:**
- **CRG_ACCEPT_CLOUD_EMBEDDINGS**: Set to `1` to silence warnings when using cloud-based embedding providers like OpenAI, Gemini, or MiniMax.

## Tool Filtering and Execution Limits

Control which MCP tools are exposed and their runtime constraints:

- **CRG_TOOLS**: Comma-separated list limiting which tools are loaded (e.g., `query_graph_tool`).
- **CRG_TOOL_TIMEOUT**: Hard timeout in seconds for each tool call invocation.

## Change Analysis and Git Settings

Configure analysis depth and Git interaction parameters:

- **CRG_MAX_CHANGED_FUNCS**: Caps the number of functions examined in large diffs.
- **CRG_MAX_TRANSITIVE_FRONTIER**: Limits the size of the transitive frontier for change analysis.
- **CRG_GIT_TIMEOUT**: Timeout in seconds for Git commands to prevent hanging operations.
- **CRG_RECURSE_SUBMODULES**: Boolean flag to enable or disable traversal of Git submodules.

## Reproducibility and Safety Settings

Ensure deterministic results and control security policies:

- **CRG_LEIDEN_SEED**: Seed value for deterministic Leiden community detection, ensuring reproducible graphs across different machines as detailed in [`docs/REPRODUCING.md`](https://github.com/tirth8205/code-review-graph/blob/main/docs/REPRODUCING.md).
- **CRG_ALLOW_REMOTE_CODE**: Permit HuggingFace models that require `trust_remote_code=True`.

## Testing and Debug Variables

Internal variables for development and testing scenarios:

- **CRG_TEST_IMPACT_FLOAT**: Overrides the impact-float value used in test suites.

## Configuration Examples

Configure a local embedding model with cloud provider acceptance:

```bash
export CRG_EMBEDDING_MODEL="sentence-transformers/all-MiniLM-L6-v2"
export CRG_ACCEPT_CLOUD_EMBEDDINGS=1
crg build

```

Use OpenAI's embedding endpoint with custom dimensions:

```bash
export CRG_OPENAI_BASE_URL="https://api.openai.com/v1"
export CRG_OPENAI_API_KEY="sk-xxxx"
export CRG_OPENAI_MODEL="text-embedding-3-small"
export CRG_OPENAI_DIMENSION=1536
crg serve

```

Force serial parsing with limited workers and custom tool timeout:

```bash
export CRG_SERIAL_PARSE=1
export CRG_PARSE_WORKERS=2
export CRG_TOOL_TIMEOUT=30
crg serve --tools query_graph_tool

```

Override default storage locations:

```bash
export CRG_DATA_DIR="/tmp/crg-data"
export CRG_HOME="/tmp/crg-registry"
crg update

```

## Summary

- The definitive environment variable reference lives in [`code_review_graph/constants.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/constants.py) with documentation in [`docs/USAGE.md`](https://github.com/tirth8205/code-review-graph/blob/main/docs/USAGE.md).
- All variables use the `CRG_` prefix and are read via `os.getenv` with empty-string normalization.
- **Storage variables** (`CRG_HOME`, `CRG_DATA_DIR`) control where data persists.
- **Embedding variables** support local sentence-transformers, OpenAI-compatible APIs, and Voyage AI, with `CRG_ACCEPT_CLOUD_EMBEDDINGS=1` required to bypass warnings.
- **Parser variables** (`CRG_SERIAL_PARSE`, `CRG_PARSE_WORKERS`) tune parallel processing behavior.
- **Safety variables** (`CRG_ALLOW_REMOTE_CODE`, `CRG_LEIDEN_SEED`) manage security and reproducibility.

## Frequently Asked Questions

### Where are the environment variables defined in the codebase?

All environment variable names and their default values are centrally defined in [`code_review_graph/constants.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/constants.py). The implementation reads these using Python's `os.getenv` function and normalizes empty strings to ensure robust fallback behavior when variables are unset.

### What is the default data directory if CRG_DATA_DIR is not set?

When `CRG_DATA_DIR` is not configured, the code falls back to a `.code-review-graph` subdirectory within the repository root. This default is hardcoded in [`constants.py`](https://github.com/tirth8205/code-review-graph/blob/main/constants.py) and ensures the tool works out-of-the-box without manual configuration.

### How do I enable cloud embedding providers without security warnings?

Set `CRG_ACCEPT_CLOUD_EMBEDDINGS=1` before invoking any `crg` command. This variable silences the egress warning that appears when using OpenAI, Gemini, MiniMax, or Voyage endpoints, confirming that you accept the transmission of code snippets to external APIs.

### Can I force serial parsing instead of parallel processing?

Yes. Export `CRG_SERIAL_PARSE=1` to disable parallel parsing and use a single thread. This is particularly useful for debugging parsing issues or when running in resource-constrained environments. You can also fine-tune parallelism using `CRG_PARSE_EXECUTOR` (choosing between `process` or `thread`) and `CRG_PARSE_WORKERS` to set the exact worker count.