# Configure checks

Choose which files to check, set limits, and make exceptions.

Commands on this page run `sprawl-guard` as installed with Cargo or Homebrew. If you installed Sprawl Guard with pnpm, npm, or uv, replace `sprawl-guard` with `pnpm exec sprawl-guard`, `npm exec -- @kpozin/sprawl-guard`, or `uv run sprawl-guard`.

Use `sprawl-guard.toml` in the repository root to configure checks. Add only the settings you want
to change. Everything else keeps its default. The
[configuration reference](/sprawl-guard/reference/configuration.md) lists every setting.

## Set limits

These are the built-in limits. Change any of them:

```toml title="sprawl-guard.toml"
[limits.max_lines_per_file]
production = 400
test = 800

[limits.max_direct_files_per_directory]
production = 10
test = 10
```

Test files have their own limits. By default, a file is a test file when its path matches a common
test pattern, such as `tests/**` or `**/*.test.*`. To use your own patterns, set `[tests].globs`:

```toml title="sprawl-guard.toml"
[tests]
globs = ["tests/**", "**/*_test.py"]
```

This list replaces the default patterns, so include any of them you still need.

Sprawl Guard counts only lines of code by default. To also count comments or blank lines, set
`count_lines = ["comments", "blank_lines"]` under `[limits.max_lines_per_file]`.

## Choose which files to check

Sprawl Guard checks every file written in a language it recognizes. It skips hidden files and
directories, and anything that `.gitignore` or a similar ignore file excludes. Run
`sprawl-guard languages --detected` to see which languages it finds in the repository.

To skip generated or third-party code, exclude it:

```toml title="sprawl-guard.toml"
[files]
extend_exclude = ["vendor/**", "src/generated/**"]
```

To stop checking a language, disable it:

```toml title="sprawl-guard.toml"
[languages.markdown]
enabled = false
```

## Make exceptions

To give some paths different limits, add an override with a reason:

```toml title="sprawl-guard.toml"
[[overrides]]
paths = ["src/legacy/**"]
max_lines_per_file = { production = 1000 }
reason = "Legacy subsystem, scheduled for removal"
```

Use an override for an exception you intend to keep. For a violation you intend to fix, record it
in the [ratchet file](/sprawl-guard/ratchet.md) instead.

## Find out how a path is checked

When a result surprises you, ask Sprawl Guard how it treats the path:

```sh
sprawl-guard explain src/example.rs
```

`explain` shows whether the path is checked, its language, whether it is a test file, its limits,
and the overrides that apply to it. For a path that doesn't exist yet, it shows the language and
whether it would be a test file, so you can check where a new file would land. To see the whole
configuration with defaults filled in, run `sprawl-guard config resolved`.
