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-cliMeasured on real codebases
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.
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.
The whole trick
Do less work.
locguard optimizes the question it actually needs to answer: “did this file cross the limit?”
Changed files for the everyday loop; the full tracked + nonignored tree for CI.
Extensions and high-confidence generated, dependency, vendor, cache, and build paths first.
A bounded worker pool reuses buffers. No AST, parser, or UTF-8 decoding sits in the hot path.
The moment the violation is proven, the rest of that file is irrelevant unless you asked for --exact.
Opinionated defaults
A boring rule agents can trust.
No semantic scoring system, language parser, or per-repo bootstrap script to keep in sync.
Zero config
Install it and run it. Create .agents/.locguard.toml only when a repository actually needs custom policy.
Changed files by default
Bare locguard asks Git for staged, unstaged, and untracked source changes instead of rescanning the whole tree.
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.
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.
Legacy debt without legacy instructions
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",
]Documentation
Nothing to initialize until you want to customize.
Start with locguard. Use locguard scan for the authoritative CI/pre-push invariant.
Quickstart
Install once, run locguard, and add the full scan to CI.
Configuration
Strong defaults with explicit escape hatches in .agents/.locguard.toml.
Command reference
The complete compact CLI surface.
CI and agent loops
Fast local feedback without weakening the repository-wide CI invariant.
Performance model
The threshold-scanning design and the optimizations that matter most.
Changelog
New commands, policy behavior, performance changes, and compatibility notes.