Stop large files and junk (node_modules, build output, archives, .env, keys) from sneaking into a commit. A zero-dependency pre-commit guard.
Project description
bloatguard
Stop large files and junk from sneaking into a commit. bloatguard scans
what you're about to commit and blocks the stuff that shouldn't be in version
control — a 200 MB binary, a stray node_modules/, build output, a .env full
of secrets, a private key. Run it by hand or wire it into a pre-commit hook.
Zero dependencies (pure standard library).
pip install bloatguard
bloatguard # scan staged files
bloatguard install # add it as a .git/hooks/pre-commit guard
The problem
Committing a file you didn't mean to is cheap to do and expensive to undo. A
giant binary or an accidental node_modules/ bloats the repo permanently —
removing it later means rewriting history (git filter-repo, BFG) and a
force-push that ruins everyone's day. A committed .env or *.pem is worse:
once it's pushed, the secret is burned.
.gitignore helps, but only for files you remembered to list, and a stray
git add -f or a pre-existing tracked file walks right past it. bloatguard is the
backstop: it looks at what's actually staged and says "are you sure?"
What it flags
-
Big files — anything over
--max-size(default 5 MB), whatever it is. -
Junk patterns — a curated set of things that almost never belong in git:
Category Examples deps node_modules/,bower_components/,.venv/build dist/,build/,target/,coverage/archives *.zip,*.tar.gz,*.rar,*.7zdatabases *.sqlite,*.dbbinaries *.exe,*.dll,*.so,*.dylib,*.classsecrets .env(not.env.example),*.pem,*.key,*.p12OS / editor .DS_Store,Thumbs.db,*.swp,*~Run
bloatguard rulesto see the full list.
Usage
bloatguard # = bloatguard check — scan the staged set
bloatguard scan # scan the whole working tree (honors .gitignore)
bloatguard scan src test # scan only certain paths
bloatguard --max-size 50M # raise the size limit
bloatguard --allow "assets/*.zip" # whitelist a glob (repeatable)
bloatguard --json # machine-readable
bloatguard rules # list the built-in patterns
You can also run it as a module: python -m bloatguard.
As a pre-commit hook
bloatguard install # writes .git/hooks/pre-commit (refuses to clobber an existing hook)
bloatguard uninstall
Or use it with the pre-commit framework / in CI:
# .pre-commit-config.yaml
- repo: local
hooks:
- id: bloatguard
name: bloatguard
entry: bloatguard check
language: system
pass_filenames: false
Once installed, a commit that stages anything flagged is blocked:
$ git commit -m "wip"
bloatguard 2 item(s) should not be committed (14 staged file(s) scanned)
✗ node_modules/ (1240 files, 88.4 MB) — dependency directory — reinstall instead of committing
✗ .env (412 B) — .env file — may contain secrets
Fix: add the pattern to .gitignore then git rm --cached <file>, or keep it on purpose with --allow <glob> / --max-size <size>
Exit codes
| Code | Meaning |
|---|---|
0 |
clean — nothing to scrub |
1 |
something staged shouldn't be committed (blocks the commit as a hook) |
2 |
not a git repository, or bad arguments |
Notes
- It only ever reads — bloatguard never modifies, stages, or deletes anything. It reports and sets an exit code; the fix is yours to make.
- A whole junk directory collapses into one line with a file count and total
size, so staging an un-ignored
node_modules/doesn't flood your terminal. - Output is deterministic (entries are sorted), so the Python and Node ports produce identical results.
Also available for Node
Same checks, same flags: npx bloatguard
(source: bloatguard).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bloatguard-0.1.0.tar.gz.
File metadata
- Download URL: bloatguard-0.1.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1b680921d7d3201841aeb42e4a1b06997a500145db1a0ca888f3de147e38322
|
|
| MD5 |
7f72d3a36d33fba780e55caa882284a6
|
|
| BLAKE2b-256 |
0927cdd2481c007f88637a568e3e7132f33ff716b0f73e42eed69e1f8e54787e
|
File details
Details for the file bloatguard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bloatguard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a085747e760450cbf11ff240a4849c2caf708c933453d42d62045e8069e52176
|
|
| MD5 |
bc28c4ba5fc53abf15d37a989ec03480
|
|
| BLAKE2b-256 |
32ac38b7e3be67765802d834780adb4ca53a34ad06e3cc26d1671b4b56779699
|