# Environment Variables for Configuring code-review-graph: Why the Tool Uses CLI Flags Instead

> Discover why code-review-graph relies on CLI flags not environment variables for configuration. Understand the tool's design choices for controlling runtime behavior.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: best-practices
- Published: 2026-08-09

---

**code-review-graph does not support environment variables for configuration; all runtime behavior is controlled through explicit command-line options parsed in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py).**

When deploying the `tirth8205/code-review-graph` repository in development or production environments, you might expect to find environment variables for adjusting log levels, ports, or feature flags. However, the codebase is intentionally designed to reject implicit configuration through environment state in favor of transparent, traceable command-line arguments.

## How code-review-graph Handles Configuration

The project follows a strict explicit-configuration pattern that eliminates hidden state. A thorough review of the source code reveals no usage of `os.getenv` or `process.env`, meaning no environment variables affect execution.

### Command-Line Interface (cli.py)

All configurable behavior is driven by flags defined in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py). This module parses arguments such as `--daemon`, `--disable-forget`, and `--log-level`, passing them directly to the underlying application logic without consulting the system environment.

### Spring Configuration Helpers (config_keys.py)

The utility functions `is_spring_config_path` and `normalize_spring_config_key` reside in [`code_review_graph/config_keys.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/config_keys.py). These helpers operate exclusively on supplied string arguments and file path inputs; they contain no logic to read from environment variables.

## Available Configuration Methods

Since environment variables are not implemented, configure the tool using these CLI alternatives:

- **`--daemon`** – Activates the background daemon process implemented in [`code_review_graph/daemon.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/daemon.py)
- **`--disable-forget`** – Disables the automatic "forget" feature during graph processing
- **`--log-level`** – Sets logging verbosity (e.g., `DEBUG`, `INFO`, `WARNING`)
- **`--port`** – Specifies the network port for daemon mode (e.g., `8000`)

## Practical Configuration Examples

Instead of exporting environment variables, pass settings directly as command-line flags:

```bash

# Start the daemon on port 8000

code-review-graph daemon --port 8000

# Run with the forget feature disabled

code-review-graph run --disable-forget

# Enable debug logging explicitly

code-review-graph run --log-level DEBUG

```

For programmatic integration, import the Python APIs directly and instantiate configuration objects with explicit parameters rather than relying on global environment state.

## Summary

- **No environment variables** are defined or read by code-review-graph; the codebase contains no `os.getenv` or `process.env` references.
- **All configuration** is handled through explicit command-line flags parsed in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py).
- **Spring configuration utilities** in [`code_review_graph/config_keys.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/config_keys.py) process arguments directly without environment lookups.
- **Daemon behavior** is controlled by CLI options like `--daemon` and `--port`, not by background environment configuration.

## Frequently Asked Questions

### Can I use environment variables to configure code-review-graph?

No. The tool does not read any environment variables for configuration. According to the source code in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py), all settings must be passed as command-line arguments such as `--log-level` or `--disable-forget`.

### How do I set the log level without environment variables?

Use the `--log-level` CLI flag when invoking the tool. For example, run `code-review-graph run --log-level DEBUG` to enable debug output. This flag is processed directly by the argument parser in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py).

### Is there a way to configure the Spring configuration normalization via environment variables?

No. The helper functions `is_spring_config_path` and `normalize_spring_config_key` in [`code_review_graph/config_keys.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/config_keys.py) accept parameters as function arguments only. They do not check environment variables and must be called with explicit values.

### How do I configure code-review-graph when running in a container?

Pass configuration through command-line arguments in your container entrypoint or CMD instruction. Since no environment variables are supported, specify options like `--port` and `--daemon` directly in the execution command rather than using ENV instructions in your Dockerfile.