architectural guardrail for source files

Small files.
Fewer collisions.

locguard is a tiny, zero-config CLI that keeps source files below a physical line limit. It is intentionally language-agnostic, Git-aware, and fast enough to live in every agent check loop.

$npm install -g locguard-cli
1,000 line limit90% warning band8 worker cap

Faster than wc, even when wc gets the file list for free.

Median wall time on an M1 MacBook Air. locguard is timed end-to-end; the comparison precomputes a NUL-delimited source list using the same default extension/exclusion policy, removes binary-like paths, then times only xargs -0 wc -l.

wclocguardeach repo normalized to wc = 100% · lower is better
VS Codemicrosoft/vscode12,966 source files · 677 over 1k · 33e1911ac9cf
wc4.29s
locguard1.46s
2.95× faster2.83s less wall time
Rustrust-lang/rust37,967 source files · 664 over 1k · 8925ea358a0f
wc13.2s
locguard2.59s
5.09× faster10.6s less wall time
Linuxtorvalds/linux67,433 source files · 8,758 over 1k · 77ae27fd98f3
wc33.3s
locguard6.51s
5.11× faster26.8s less wall time
Conservative by design.

The wc baseline pays no Git discovery, source-type filtering, generated/vendor exclusion, metadata, or binary-like-file detection cost. locguard pays all of them inside the measured command. Linux contains case-colliding tracked paths on macOS; both commands use the same materialized checkout.

8 measured · 3 warmupsApple M1 · 8 GBmacOS 26.3.1Aug 21, 2026

Do less work.

locguard optimizes the question it actually needs to answer: “did this file cross the limit?”

01Ask Git

Changed files for the everyday loop; the full tracked + nonignored tree for CI.

→
02Reject noise

Extensions and high-confidence generated, dependency, vendor, cache, and build paths first.

→
03Read in parallel

A bounded worker pool reuses buffers. No AST, parser, or UTF-8 decoding sits in the hot path.

→
04Stop at 1,001

The moment the violation is proven, the rest of that file is irrelevant unless you asked for --exact.

A boring rule agents can trust.

No semantic scoring system, language parser, or per-repo bootstrap script to keep in sync.

01

Zero config

Install it and run it. Create .agents/.locguard.toml only when a repository actually needs custom policy.

02

Changed files by default

Bare locguard asks Git for staged, unstaged, and untracked source changes instead of rescanning the whole tree.

03

Stops at the proof

A 20,000-line offender does not need 20,000 lines counted. Once line 1,001 is proven, locguard can stop reading.

04

Built for agent-heavy repos

Generated and vendor trees stay quiet, while exact legacy exemptions let new files face a strict rule without old debt becoming agent context.

Grandfather exact old files. Keep the rule strict everywhere else.

Existing oversized files can disappear from normal agent checks without teaching agents what to ignore. Exemptions are exact paths, not globs, so new files and renamed copies are caught automatically.

Configuration guide →
# .agents/.locguard.toml
limit = 1000
warn_percent = 90

[exempt]
files = [
  "src/legacy/runtime.rs",
  "src/ui/old_screen.tsx",
]

Nothing to initialize until you want to customize.

Start with locguard. Use locguard scan for the authoritative CI/pre-push invariant.