Skip to content

Sprawl Guard

Keep source files and directories within explicit size limits, in any* language
An editor's file explorer with 40 files directly inside src, continuing past the bottom of the window.
One directory, 40 files
The same files grouped into api, auth, billing, customers, db, notifications, payments, and reports directories, with three files left directly inside src.
The same files, grouped by feature

Coding agents (and some coding humans!) like to crowd code into giant, unnavigable files and messy flat directories with little organization. To help battle this entropy, Sprawl Guard counts the lines in each file (using Tokei) and the source files directly inside each directory, and enforces limits that you set.

(Sprawl Guard can only admonish your agent when it goes over the limits; proper reorganization requires reasoning.)

* Sprawl Guard supports every language bundled with Tokei, including Rust, TypeScript, JavaScript, Python, Go, Java, Kotlin, Swift, C, and C++. Run sprawl-guard languages for the complete list.

If all you’re looking for is line-count limits for JavaScript or TypeScript, simply use the max-lines rule in ESLint or Oxlint.

Choose Sprawl Guard when you also want:

  • support for polyglot repositories
  • a ratchet that allows existing oversized files and crowded directories to shrink but not grow
  • separate limits for production and test code
  • limits on the number of direct files per directory
  • byte limits on (binary) file sizes

If you already use max-lines, Sprawl Guard can import its limit and existing exemptions.

Browse the source and releases, or open an issue.

© 2026 Konstantin Pozin