# Where Is the Global Configuration for no-mistakes Located?

> Discover the exact location of the no-mistakes global configuration. Learn how it's defined in the internal config package and loaded from .no-mistakes.yaml.

- Repository: [Kun Chen/no-mistakes](https://github.com/kunchenguid/no-mistakes)
- Tags: how-to-guide
- Published: 2026-07-14

---

**The global configuration for no-mistakes is defined in the `internal/config` package and loaded at runtime from [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) in the user's home directory (or `$NM_HOME`).**

The global configuration for no-mistakes controls CI timeouts, telemetry, and daemon settings through a centralized system that merges built-in defaults with user-defined values. According to the kunchenguid/no-mistakes source code, this configuration architecture lives in [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go) and persists in a YAML file that the CLI loads on startup.

## Core Configuration Files

### Source Code Location

The authoritative definition of the global configuration resides in **[`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go)**. This file contains the `Config` struct that defines all available settings, the `defaultConfigYAML` constant that stores built-in defaults, and the loading logic that merges user preferences.

When the application initializes, it calls `config.New()`, which internally invokes `config.Load()` to read and parse the configuration.

### User Configuration File

At runtime, no-mistakes searches for **[`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml)** in the configuration root directory. The loader determines this location through the following precedence:

1. `$NM_HOME` environment variable (if set)
2. `$HOME/.no-mistakes` (default directory)

The YAML file inside this directory contains the user's persistent global settings that override the compiled-in defaults.

## How Configuration Loading Works

The configuration system follows a hierarchical merge strategy implemented in [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go):

1. **Default values** are loaded from the `defaultConfigYAML` constant embedded in the binary.
2. **User overrides** are read from [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) in the configuration directory.
3. **CLI arguments** overwrite specific values after the file is loaded.

This three-layer approach ensures the application always has valid fallbacks while allowing granular user control.

## Configuring no-mistakes Globally

### Sample [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml)

Create this file in `$HOME/.no-mistakes/` (or `$NM_HOME`) to customize global behavior:

```yaml
ci_timeout: 15m
telemetry: true
daemon:
  lockfile: "${NM_HOME}/daemon.lock"

```

### Loading Configuration Programmatically

You can interact with the configuration directly using the Go API:

```go
cfg, err := config.Load()  // reads $NM_HOME/.no-mistakes.yaml
if err != nil {
    log.Fatalf("config load failed: %v", err)
}
fmt.Printf("CI timeout: %v\n", cfg.CITimeout)

```

## Runtime Overrides and Precedence

Command-line flags take final precedence over file-based configuration. The flag parsing logic in [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go) modifies the loaded configuration before the rest of the application accesses it.

To override a setting temporarily:

```bash
no-mistakes --ci-timeout=30m run

```

This bypasses the value defined in [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) without modifying the file.

## Testing and Validation

The configuration system includes comprehensive tests to ensure reliability:

- **[`internal/config/config_args_override_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config_args_override_test.go)** verifies that CLI arguments correctly override file and default values.
- **[`internal/config/config_agent_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config_agent_test.go)** validates agent-specific configuration handling.
- **[`internal/config/config_evidence_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config_evidence_test.go)** confirms that environment variables and evidence sources influence configuration as expected.

## Summary

- The **global configuration for no-mistakes** is defined in **[`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go)** and consumed via the `Config` struct.
- User settings are stored in **[`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml)** within `$NM_HOME` or `$HOME/.no-mistakes`.
- The `config.Load()` function merges **default values**, **file settings**, and **CLI flags** in that order of precedence.
- Use environment variables like `$NM_HOME` to relocate the configuration directory.

## Frequently Asked Questions

### Where does no-mistakes look for the global config file?

no-mistakes searches for [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) in the directory specified by the `$NM_HOME` environment variable. If `$NM_HOME` is unset, it defaults to `$HOME/.no-mistakes`. The `config.Load()` function in [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go) handles this resolution at startup.

### What format does the no-mistakes configuration file use?

The global configuration uses **YAML format** with keys matching the fields of the `Config` struct defined in [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go). Options include `ci_timeout`, `telemetry`, and nested objects like `daemon` with sub-properties such as `lockfile`.

### How are default values defined in no-mistakes?

Default values are stored in the **`defaultConfigYAML`** constant within [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go). These values are compiled into the binary and serve as fallbacks when the user configuration file is missing or when specific keys are omitted from [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml).

### Can environment variables override no-mistakes configuration?

While the configuration loader primarily respects the `$NM_HOME` variable for directory location, specific settings are typically controlled via **command-line flags** that override file values. The [`config_args_override_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/config_args_override_test.go) file confirms this behavior, showing that flags take precedence over both defaults and YAML settings.