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

> Find the no-mistakes global configuration file easily. Learn its default location in your home directory or via the NM_HOME environment variable for quick setup.

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

---

**The global configuration file for no-mistakes is [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml), located in your home directory (or the directory specified by the `$NM_HOME` environment variable), with the schema and loading logic defined in the `internal/config` package.**

The no-mistakes CLI tool centralizes user-wide settings—such as CI timeouts, telemetry flags, and daemon paths—through a single global configuration file. Understanding where this file lives, how the application discovers it, and which source files govern its behavior is critical for troubleshooting and customization.

## Location of the no-mistakes Global Configuration File

### Default Path and Filename

By default, the no-mistakes binary searches for a file named **[`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml)** (note the leading dot) in the user’s home directory. The tool resolves the home directory using standard environment variables, ensuring cross-platform compatibility for Linux, macOS, and Windows systems.

If the file exists, no-mistakes parses it at startup; if absent, the application proceeds using only the built-in defaults defined in the source code.

### Environment-Based Override with $NM_HOME

You can override the default location by setting the **`$NM_HOME`** environment variable. When `$NM_HOME` is defined, no-mistakes treats that directory as the configuration root and expects to find [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) there instead of in `$HOME`.

The resolution hierarchy is:
1. Check for `$NM_HOME/.no-mistakes.yaml`
2. Fall back to `$HOME/.no-mistakes.yaml`
3. Use embedded defaults if neither file exists

## Source Code Architecture

### The Config Struct in internal/config/config.go

The authoritative definition of global settings resides in **[`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go)**. This file contains:
- The `Config` struct defining all valid configuration keys
- The `Load()` function that reads and parses the YAML file
- The `New()` constructor that initializes the configuration with defaults

According to the kunchenguid/no-mistakes source code, this package is the single source of truth for how settings are structured and validated.

### Embedded Defaults via defaultConfigYAML

Within [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go), the **`defaultConfigYAML`** constant stores the global default values as a YAML-formatted string. These defaults are injected at compile time and serve as the baseline that user-specific settings override at runtime.

For example, if the user does not specify a `ci_timeout` value in their [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml), the application uses the value from `defaultConfigYAML` automatically.

## How Configuration Loading Works

When the CLI initializes, it executes the loading sequence defined in the `internal/config` package:

1. **Determine root directory**: The code checks for `$NM_HOME`; if unset, it uses the standard user home directory.
2. **Read user file**: It attempts to read [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) from the determined root.
3. **Merge with defaults**: The parsed file contents are merged with the `defaultConfigYAML` defaults, with user values taking precedence.
4. **Apply CLI overrides**: Command-line flags parsed later in the startup sequence overwrite the merged configuration values before the application logic consumes them.

The entry point for this process is the **`config.Load()`** function (typically invoked via **`config.New()`**), which returns a populated `Config` struct or an error if the YAML is malformed.

## Customizing Your Configuration

### Sample .no-mistakes.yaml Structure

Create a [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) in your home directory to persist settings across sessions:

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

```

This YAML structure mirrors the fields defined in the `Config` struct within [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go).

### Command-Line Overrides

You can temporarily override global settings without editing the file by using CLI flags. The flag parsing logic in [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go) updates the configuration struct after the file is loaded:

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

```

In this example, even if [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) specifies `15m`, the command runs with a `30m` timeout because the flag value overwrites the loaded configuration before execution.

## Testing the Configuration System

The repository includes comprehensive tests in the `internal/config` directory to ensure reliability:

- **[`config_args_override_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/config_args_override_test.go)**: Verifies that command-line arguments correctly supersede file-based and default values
- **[`config_agent_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/config_agent_test.go)**: Validates agent-specific configuration handling and edge cases
- **[`config_evidence_test.go`](https://github.com/kunchenguid/no-mistakes/blob/main/config_evidence_test.go)**: Ensures that environment variables and other runtime evidence properly influence the final configuration state

These test files confirm that the loading order—defaults → file → environment → CLI flags—behaves as documented in the source code.

## Summary

- The **no-mistakes global configuration file** is [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml), stored in `$HOME` or `$NM_HOME`.
- **Source authority** for configuration logic is [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go), which defines the `Config` struct, `defaultConfigYAML` constants, and the `Load()` function.
- **Loading sequence**: Defaults are embedded in the binary, merged with the user’s YAML file, and finally overridden by CLI flags.
- **Customization** is supported through both persistent YAML files and temporary command-line flags.

## Frequently Asked Questions

### What is the default location for the no-mistakes configuration file?

By default, no-mistakes looks for [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) in your user home directory. The exact path depends on your operating system’s home directory resolution (e.g., [`/home/username/.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main//home/username/.no-mistakes.yaml) on Linux or `C:\Users\username\.no-mistakes.yaml` on Windows).

### How do I change where no-mistakes looks for its global config?

Set the `$NM_HOME` environment variable to point to a custom directory. When this variable is present, no-mistakes reads [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) from that location instead of your home directory, allowing you to maintain separate configurations for different projects or environments.

### What happens if the .no-mistakes.yaml file is missing?

The application does not fail. According to the implementation in [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go), the `Load()` function falls back to the `defaultConfigYAML` embedded in the binary. The CLI starts with safe defaults, though you may see warnings depending on the verbosity settings.

### Can CLI flags override values in the global configuration file?

Yes. The flag parsing system in [`internal/config/config.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/config/config.go) processes command-line arguments after loading the file-based configuration. Values provided via flags (e.g., `--ci-timeout`) take precedence over both the [`.no-mistakes.yaml`](https://github.com/kunchenguid/no-mistakes/blob/main/.no-mistakes.yaml) file and the compiled-in defaults.