# How the Claude Video Config File (~/.config/watch/.env) Is Loaded and Parsed

> Discover how Claude Video loads and parses the ~/.config/watch/.env configuration file line by line. Understand the WATCH_DETAIL variable resolution process.

- Repository: [bradautomates/claude-video](https://github.com/bradautomates/claude-video)
- Tags: internals
- Published: 2026-08-02

---

**The Claude Video skill loads user settings from `~/.config/watch/.env` by parsing it line-by-line in [`skills/watch/scripts/config.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/config.py), resolving the `WATCH_DETAIL` variable through a priority chain of environment variables, file values, and safe defaults.**

The `bradautomates/claude-video` repository externalizes user-specific settings to keep secrets out of source control while allowing control over video processing behavior. Understanding exactly how the Claude Video config file is loaded and parsed helps you debug invalid settings and securely manage API credentials.

## Where the Claude Video Config File Is Located

The configuration path is constructed using Python’s `pathlib` module. In [`skills/watch/scripts/config.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/config.py) (lines 9‑10), the code defines the expected location as:

```python
CONFIG_DIR = Path.home() / ".config" / "watch"
CONFIG_FILE = CONFIG_DIR / ".env"

```

This resolves to `$HOME/.config/watch/.env` on Unix-like systems and the equivalent user profile location on Windows. The skill expects this file to contain lowercase environment-style variables, though the parser is resilient to missing files or malformed entries.

## Parsing the .env File with `read_env_file`

The core parsing logic resides in the `read_env_file` function (lines 17‑45). This implementation reads the file line-by-line and performs the following sanitization:

- **Empty lines and comments** — Lines starting with `#` or containing only whitespace are skipped.
- **Key-value splitting** — Valid entries are split on the first `=` into `KEY` and `VALUE`.
- **Quote unwrapping** — Values wrapped in single or double quotes have the quotes removed.
- **Comment stripping** — Inline comments (e.g., `KEY=value # note`) are stripped only when the `#` follows whitespace and the value is **unquoted**, protecting secrets that legitimately contain `#` characters.

The function returns a flat dictionary of raw string key-value pairs.

## Resolving Configuration Values with `get_config`

After parsing, the `get_config` function (lines 48‑62) resolves the final configuration using a strict precedence order:

```python
file_values = read_env_file()
detail = (
    os.environ.get("WATCH_DETAIL")
    or file_values.get("WATCH_DETAIL")
    or DEFAULT_DETAIL
)
if detail not in DETAILS:
    detail = DEFAULT_DETAIL

```

The priority chain works as follows:

1. **Environment variable** — Checks `os.environ` for `WATCH_DETAIL` first, allowing temporary overrides.
2. **File value** — Falls back to the value loaded from `~/.config/watch/.env`.
3. **Default** — If neither is present or the value is invalid, defaults to `"balanced"`.

The function returns a dictionary containing the resolved `detail` mode and the absolute `config_file` path (lines 59‑62), which is then imported by [`watch.py`](https://github.com/bradautomates/claude-video/blob/main/watch.py) (line 71) and [`setup.py`](https://github.com/bradautomates/claude-video/blob/main/setup.py) (line 32) to drive frame-extraction behavior.

## Practical Usage Examples

To retrieve the current configuration programmatically:

```python
from skills.watch.scripts.config import get_config

cfg = get_config()
print("Detail mode:", cfg["detail"])
print("Config file path:", cfg["config_file"])

```

To override the detail mode for a single execution without modifying the `.env` file:

```bash
export WATCH_DETAIL=efficient
python -m skills.watch.scripts.watch <video-url>

```

A valid `~/.config/watch/.env` file looks like this:

```bash
WATCH_DETAIL="balanced"

# Lines starting with # are ignored

```

## Summary

- The Claude Video config file is expected at `~/.config/watch/.env` as defined in [`skills/watch/scripts/config.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/config.py) lines 9‑10.
- The `read_env_file` function (lines 17‑45) parses the file with safeguards for comments and quoted values containing `#`.
- `get_config` (lines 48‑62) resolves `WATCH_DETAIL` using the priority: environment variable → file value → default `"balanced"`.
- Downstream scripts like [`watch.py`](https://github.com/bradautomates/claude-video/blob/main/watch.py) and [`setup.py`](https://github.com/bradautomates/claude-video/blob/main/setup.py) import `get_config` to apply user settings without hardcoding secrets.

## Frequently Asked Questions

### What happens if `WATCH_DETAIL` is not set anywhere?

If the environment variable is unset and the `.env` file is missing or empty, `get_config` falls back to the `DEFAULT_DETAIL` constant (set to `"balanced"`). If the provided value is not in the allowed `DETAILS` list, it also defaults to `"balanced"`.

### How does the parser handle values containing `#` characters?

The `read_env_file` logic only strips inline comments when the `#` follows whitespace and the value is unquoted. This means `SECRET_KEY=abc#123` keeps the `#`, while `SECRET_KEY=abc #123` truncates at the space. Quoted values like `SECRET_KEY="abc#123"` preserve the `#` regardless of spacing.

### Where is the config file located on Windows?

Because the code uses `Path.home()`, the directory resolves to `%USERPROFILE%\.config\watch\.env` on Windows systems. The `pathlib` abstraction ensures cross-platform compatibility without manual path separators.

### Can I override settings temporarily without editing the `.env` file?

Yes. According to the implementation in `get_config`, setting the `WATCH_DETAIL` environment variable takes precedence over the file value. Export the variable in your shell session or prepend it to a single command to override the config file for that execution only.