Back to directory
a-kenji avatar
a-kenji / sizelint

sizelint

Lint your file tree based on file sizes

16

Stars

0

Forks

1

Watchers

MIT

License

$ sizelint - lint your working tree based on file sizes

Built with Nix Crates

sizelint is a fast, configurable file size linter that helps prevent large files from entering your Git repository. It can be used as a standalone tool, pre-commit hook, or as part of your CI/CD pipeline.

Overview

$ sizelint - usage

Lint your working tree based on file size

Usage: sizelint [OPTIONS] <COMMAND>

Commands:
  check        Check files for size violations
  init         Initialize sizelint configuration
  rules        Rule management
  completions  Generate shell completions
  help         Print this message or the help of the given subcommand(s)

Options:
  -c, --config <FILE>  Configuration file path
      --debug          Enable debug output (or set SIZELINT_LOG for fine-grained control)
  -h, --help           Print help
  -V, --version        Print version

$ sizelint check

Check files for size violations

Usage: sizelint check [OPTIONS] [PATHS]...

Arguments:
  [PATHS]...
          Paths to check

Options:
  -c, --config <FILE>
          Configuration file path

  -f, --format <FORMAT>
          Output format

          Possible values:
          - human: Human-readable output
          - json:  JSON output
          
          [default: human]

      --staged
          Check only staged files (git diff --staged)

      --working-tree
          Check working tree files

      --git <RANGE>
          Check files changed in a git revision range (e.g. "main", "main..HEAD", "main...feature")

      --no-history
          Skip git history scanning for deleted blobs (only check files at HEAD)

  -q, --quiet
          Quiet mode (only show violations)

      --fail-on-warn
          Treat warnings as errors

  -h, --help
          Print help (see a summary with '-h')

$ sizelint rules

Rule management

Usage: sizelint rules <COMMAND>

Commands:
  list      List available rules
  describe  Show rule documentation
  help      Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

$ sizelint init

Initialize sizelint configuration

Usage: sizelint init [OPTIONS]

Options:
  -f, --force   Force overwrite existing configuration
      --stdout  Print the default configuration to stdout
      --edit    Open configuration file in editor after creation
  -h, --help    Print help

Quick Start

Installation

cargo install sizelint --locked

Basic Usage

# Initialize configuration
sizelint init

# Check all files
sizelint check

# Check specific files
sizelint check src/main.rs README.md

Git Integration

# Check files changed since diverging from main
sizelint check --git main

# Scan the entire history of a branch for oversized blobs
sizelint check --git "$(git hash-object -t tree /dev/null)..master"

Configuration

sizelint uses TOML configuration files.

Run sizelint init to create a default configuration:

max_file_size = "2MB"
warn_file_size = "1MB"
excludes = []
check_staged = false
check_working_tree = false
respect_gitignore = true
fail_on_warn = false

[rules.default]
enabled = true
description = "Default file size check"
suggestion = "Add the file to 'excludes' or adjust 'max_file_size' in sizelint.toml"

[rules.medium_files]
enabled = false
description = "Base rule that fits many normal repos"
priority = 50
max_size = "5MB"
warn_size = "2MB"
includes = []
excludes = []

[rules.no_images]
enabled = false
description = "Warn about image files that might be better handled with LFS"
priority = 80
includes = ["*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp"]
excludes = []
warn_on_match = true
suggestion = "Consider using Git LFS: git lfs track '*.png'"

Documentation

Development

Development Shell

nix develop

Building

cargo build --release

Testing

cargo test
cargo clippy

License

MIT License - see LICENSE file for details.

Releases

Feb 27, 2026

Download .zip

What's Changed Some performance improvements for the recent git walker addition when using git. Top lint the whole codebase for example use: sizelint check --git "$(git hash-object -t tree /dev/null)....

Feb 16, 2026

Download .zip

What's Changed The main feature in this release is the ability to hook into git --git and lint a whole range of commits. This is especially useful in CI, to prevent large files in the history that are...

Jul 23, 2025

Download .zip

What's Changed

feat: Add config flag to check subcommand by @a-kenji in #10

Full Changelog: v0.1.2...v0.1.3

Jul 21, 2025

Download .zip

What's Changed Mostly some small QOL changes that came up with sizelint usage.

feat: Add --fail-on-warn flag by @a-kenji in #5 feat: Add suggestions to CLI by @a-kenji in #6 feat: Flatten root config...

Jul 17, 2025

0.1.1: Initial Release

Download .zip

The goal of sizelint is to be a fast unobtrusive file size linter for your filetree. Because once a large file has made it into your git history, it is not easy to remove anymore. Features:

  • Respects...