Configure checks
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 lists every setting.
Set limits
Section titled “Set limits”These are the built-in limits. Change any of them:
[limits.max_lines_per_file]production = 400test = 800
[limits.max_direct_files_per_directory]production = 10test = 10Test 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:
[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
Section titled “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:
[files]extend_exclude = ["vendor/**", "src/generated/**"]To stop checking a language, disable it:
[languages.markdown]enabled = falseMake exceptions
Section titled “Make exceptions”To give some paths different limits, add an override with a reason:
[[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 instead.
Find out how a path is checked
Section titled “Find out how a path is checked”When a result surprises you, ask Sprawl Guard how it treats the path:
pnpm exec sprawl-guard explain src/example.rsnpm exec -- @kpozin/sprawl-guard explain src/example.rsuv run sprawl-guard explain src/example.rssprawl-guard explain src/example.rssprawl-guard explain src/example.rsexplain 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.