Skip to content

feat(hooks): commits refuse staged files over 5,000 tokens - #46

Merged
iAziz786 merged 1 commit into
mainfrom
chore/max-file-size-hook
Oct 20, 2026
Merged

iAziz786 merged 1 commit into
mainfrom
chore/max-file-size-hook

Conversation

@iAziz786

Copy link
Copy Markdown
Contributor

Behavior

  • Committing a staged file over 5,000 tokens (bytes / 4, so 20,000 bytes) is refused.
  • The error names the file with its token and byte counts, and gives step-by-step instructions to split it (Rust modules, Markdown sections, other files).
  • Only staged files are checked. Deleted files are ignored.
  • Skipped: lockfiles, generated code (@generated / DO NOT EDIT / Code generated marker or generated-style names), binaries, images, fonts, PDFs.

Enable

git config core.hooksPath .githooks (once per clone; AGENTS.md updated).

Verified

Scratch index: 25,000-byte .rs blocked (exit 1); .lock, @generated, random binary, 19,999-byte file, and empty index all pass (exit 0).

Existing large files, e.g. src/cli/org.rs, are only blocked when staged for a change.

The error message says how to split the file. Lockfiles, generated code,
and binaries are skipped.
@iAziz786
iAziz786 merged commit f061f7f into main Oct 20, 2026
1 check passed
@iAziz786
iAziz786 deleted the chore/max-file-size-hook branch October 20, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant