Overview

locguard

A Rust CLI that checks source files against a configurable line limit. Changed files for the local feedback loop, a full-tree scan for CI, and early exit as soon as a violation is proven.

RustCLI
Developer ToolsCI
locguard

I built locguard to turn a simple source-size limit into something a coding agent or CI job can actually enforce. The default is 1,000 physical lines per source file, including comments and blank lines. The point is a clear boundary on file size, not a clever estimate of how complicated the code is.

A quick local loop and an authoritative full scan

Bare locguard checks staged, unstaged, and nonignored untracked source files. That keeps the ordinary edit-check loop focused on what changed. locguard scan walks the full tree for CI. Generated code, dependencies, vendored files, and build output are filtered out, with explicit configuration for project-specific inclusions and legacy exemptions.

A violation exits with code 1, and warnings start at 90% of the configured limit by default. The agent gets a concrete failing file and a machine-readable result when it needs one, rather than another instruction it has to remember to follow.

The implementation is Rust, but the useful optimization is recognizing how little this question needs. There is no AST or source decoding: count newline bytes, skip files that metadata can already prove small enough, and stop reading as soon as the limit is exceeded. It’s a threshold check, so I made the work stop at the threshold too.

Use ← and → to navigate