linecheck 0.3.0

A fast, configurable tool that warns or errors when files exceed a set line count
Documentation

linecheck

Alpha — experimental, expect breaking changes.

Stop your AI agent from turning one file into a monolith. linecheck enforces per-file line limits so bloated files get caught before they pile up.

Features

  • Set per-file or per-glob line limits
  • Configurable warn / error thresholds
  • Inline ignore comments and config-level excludes
  • Works as a CLI, in CI pipelines, and as a library
  • Rust core with bindings for npm, pip, Go, and WASM

Installation

Bindings are coming soon. The Rust CLI is the first target.

Rust / Cargo

cargo install linecheck

npm

npm install -g linecheck

pip

pip install linecheck

Go

go install github.com/tupe12334/linecheck@latest

Usage

linecheck [OPTIONS] [FILES...]

Check all files in the current directory using your config:

linecheck .

Override the line limit inline:

linecheck --max-lines 200 src/

Example output:

src/main.rs: 450 lines (error threshold: 400)
src/utils.rs: 220 lines (warn threshold: 200)

See which files are creeping toward their limit before they breach it:

linecheck --status src/
src/main.rs:   450 / 400  [ERROR]
src/utils.rs:  220 / 200  [WARN]
src/lib.rs:    180 / 200  90%
src/config.rs:  45 / 200  22%

For scripting and CI dashboards, use --json:

linecheck --status --json src/

Presets

Use a preset flag to apply a built-in strictness level without writing a config file:

Flag Max lines
--strict 100
--default 200
--loose 400
--free unlimited
linecheck --strict src/
linecheck --loose .

Preset flags are overridden by any linecheck.yml in scope.

Configuration

linecheck resolves configuration like .gitignore — a linecheck.yml applies to its directory and all subdirectories recursively. A nested config overrides the parent for everything inside it. If no config is found anywhere, it falls back to built-in defaults: warn at 200 lines, error at 400 lines for all files.

project/
├── linecheck.yml        ← applies to everything
└── src/
    ├── linecheck.yml    ← overrides for src/ and below
    └── generated/
        └── linecheck.yml  ← can relax limits for generated code

Not sure where to start? 200 lines is a reasonable warn threshold for most source files — it's enough for a focused module but flags anything that's grown too broad.

Create a linecheck.yml at the root of your project to override the defaults:

rules:
  - pattern: "**/*.rs"
    warn: 200
    error: 400
  - pattern: "**/*.ts"
    warn: 150
    error: 300

exclude:
  - "**/generated/**"
  - "**/vendor/**"

When multiple rules match the same file, the most specific pattern wins.

CLI flags override config file values. Run linecheck --help for all options.

Ignoring files

Exclude globs — add an exclude list to linecheck.yml (see above).

Inline ignore — add this comment anywhere in the file to exempt it entirely:

# linecheck:ignore

The file will be skipped regardless of its line count. There is no partial ignore — it's all-or-nothing.

Exit codes

Code Meaning
0 All files within limits (warnings are printed but non-blocking)
1 One or more files exceed the error threshold

CI examples

See the examples/ folder for ready-to-use configurations:

  • examples/ci/ — generic CI shell setup
  • examples/github/ — GitHub Actions workflow

License

MIT