stagelint
Run commands like linters and formatters on staged git files.
- Safe. Partially staged files are three-way merged, so a conflicting edit never aborts your commit.
- Universal. A single binary with no runtime - the same tool in Node, Python, Go, Rust or a polyglot monorepo.
- Fast. Written in Rust, it is 5 to 28 times faster than Lefthook, nano-staged and lint-staged.
Why stagelint?
Running formatters before a commit is easy until you stage part of a file. You add the hunks you want and leave the rest in your working tree - a debug line, a half-finished function. A formatter rewrites the whole file, so its output has to be reconciled with the edits you deliberately held back. Most tools give up and abort the commit or, worse, commit them along with the fix.
stagelint stashes the unstaged edits, runs your commands, then three-way merges the result. What you staged gets formatted, what you did not stays exactly where you left it, and the commit goes through either way.
Getting started
Node
npm install --save-dev @stagelint/stagelint
Add the hook to your prepare script so it installs itself for the whole team:
{
"scripts": {
"prepare": "stagelint init"
}
}
prepare runs after npm install, so nobody has to remember a setup step. stagelint init is
idempotent, and does nothing outside a git repository.
Everything else
Download a binary from Releases, or install from crates.io:
cargo install stagelint
Then install the git pre-commit hook:
stagelint init
This creates .git/hooks/pre-commit (or respects core.hooksPath). Use --force to overwrite an
existing hook.
Using an existing hook manager
If you use pre-commit, Lefthook, or husky, install stagelint as above, then call stagelint from
your existing hook configuration instead of running stagelint init.
Configuration
Create .stagelint.yml, .stagelint.yaml, .stagelint.json, .stagelint.jsonc, or
.stagelint.json5 in your project root. The format is a map of glob patterns to commands:
# .stagelint.yml
# String: single command, files appended as args
'*.md': 'prettier --write'
# Object: control whether files are passed
'*.go':
command: 'go vet ./...'
pass_filenames: false
# Array: sequential commands, each a string or an object
'*.ts':
- eslint --fix
- command: 'tsc --noEmit'
pass_filenames: false
Matching files are always appended as arguments unless pass_filenames: false is set. Commands run
from the directory of the config file that declared them, and receive absolute paths.
Commands are split using POSIX shell rules on all platforms, so quote any argument containing spaces or backslashes.
Monorepo support
Place config files at any level in the repo. Each staged file uses the closest config file walking up toward the root.
CLI flags
--concurrent <true|false|N>
true runs every task at once, false runs them one at a time, and a number caps how many run
together. Tasks whose globs match the same file are always serialised regardless, in the order the
patterns are declared.
--continue-on-error
By default the first failing command stops the run and cancels the rest. This runs everything to completion and reports all failures together. The commit is still blocked, and the working tree is still restored.
--diff <REVSPEC>
Runs commands against the files changed in a revision range instead of the staged files. For
example, main...HEAD for everything since your branch diverged, or HEAD~3 for the last three
commits.
--stash <partial|tracked|untracked>
Controls how much of your working tree is hidden while commands run, so they see the content being committed rather than your work in progress. Each scope includes the previous, and ignored files are never touched.
partial(default) - Only stash unstaged edits to partially staged filestracked- Also stash every other dirty tracked file.untracked- Also stash untracked files.
Widen it when a command reads files it was not given - a type-checker or go vet ./... sees your
whole tree, and the default leaves your uncommitted work in place for it to trip over.
--quiet
Prints only the output of failed commands and errors: no task tree, no warnings. Cannot be combined
with --verbose.
--verbose
Prints the output of every command and keeps the task tree fully expanded. By default only failed commands have their output shown, so a passing run is just the task tree.
How it works
- Identifies staged files and detects partially-staged ones
- Creates a git stash (based on
--stashscope) for crash recovery - Overwrites stashed files with their clean index state
- Runs commands on the real working tree with full project context
- Updates the git index for staged files the commands modified
- Restores stashed files from the stash commit
- Three-way merges the commands' changes into partially-staged files
- Drops the stash ref
If a command fails, the working tree is restored and the commit is blocked. On crash (SIGKILL, power
loss), the stash ref survives - recover with git stash pop.
Paths marked SKIP_WORKTREE - by git sparse-checkout or git update-index --skip-worktree - are
left exactly as staged. No command sees them, and nothing on disk is staged in their place.
Benchmarks
Each cell is fully staged / partially staged, measured on a 1,000-file repository with a no-op
task so the figures show tool overhead rather than formatter runtime.
| Staged files | stagelint | Lefthook | nano-staged | lint-staged |
|---|---|---|---|---|
| 10 | 16ms / 32ms | 160ms / 385ms | 236ms / 323ms | 450ms / 543ms |
| 100 | 20ms / 76ms | 169ms / 538ms | 258ms / 430ms | 474ms / 696ms |
Partial staging is the expensive path, and the only one where a tool has to hide your unstaged edits
and restore them afterwards. On a commit where prettier takes two seconds this is noise; it matters
on small commits and fast formatters, which is most of them. Reproduce with bench/run.sh.
Thanks
- lint-staged - Inspired the configuration format and overall workflow.
- git-format-staged - Inspired the concept of formatting staged content and merging it back without blocking commits.
Metadata
Release files for stagelint 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 13.3 MB
Release files / stagelint-0.1.3-py3-none-win_arm64.whl
| Download URL | stagelint-0.1.3-py3-none-win_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | Python 3 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
2fb7818591631868ab8eb5c29b0ab80d7a9bab0a7da84137b9bfeb563f2db3b6
|
|
BLAKE2b-256 checksum How to use checksums |
27135f066aa3ee3d144a51680a81c4c0e82f050c38fe771bf5b8b2e815a102f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / stagelint-0.1.3-py3-none-win_amd64.whl
| Download URL | stagelint-0.1.3-py3-none-win_amd64.whl |
|---|---|
| Size | 2.3 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
cd9eda3cba1f10dd33d3253723fb17bd0ae9b9416b53e3a2dcdc5a3ccd70b2b7
|
|
BLAKE2b-256 checksum How to use checksums |
6a113cb547e3cee82a069db21a1157b83c0633a88dc5f6cb87ec1bb5ac298607
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / stagelint-0.1.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_2_x86_64.whl
| Download URL | stagelint-0.1.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_2_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | Linux glibc 2.17+ x86-64 Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
50a4073c22d9155cd9fb36b2d2900011d7757946ccad9ef4990f749751bdcc16
|
|
BLAKE2b-256 checksum How to use checksums |
20d5728ba9f8e636d05810c0efc91483176c93949ad090fe72991b39a4a2ff06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / stagelint-0.1.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_2_aarch64.whl
| Download URL | stagelint-0.1.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_2_aarch64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | Linux glibc 2.17+ ARM64 Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
cc692653bd02b872957162822ed11ddcdd75a4d205f2fef80e59cec5f8305868
|
|
BLAKE2b-256 checksum How to use checksums |
242d5882d819f1c671dc92069f23ed6eb73a1ab6bc61bc0d43b97f6d4dac4e58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / stagelint-0.1.3-py3-none-macosx_11_0_arm64.whl
| Download URL | stagelint-0.1.3-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
69e4564ec0b84cb4a7b7c88799b4304c02cad02748a774b5ed48a2c3f88dc212
|
|
BLAKE2b-256 checksum How to use checksums |
ef10f2bf32111de35414b44e10bcddf1fd45a9ec9db0dc2acc0c83f817a67afd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / stagelint-0.1.3-py3-none-macosx_10_12_x86_64.whl
| Download URL | stagelint-0.1.3-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
92cbd0e1e9818777f3b466378cc26e2f68f2e2fa72a3e48f48eb70d95f8f8cac
|
|
BLAKE2b-256 checksum How to use checksums |
4bb46c67a44d2746a2763020baa015a378b4477974351ea43a93886f9e643a32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logSecurity for stagelint 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for stagelint-0.1.3-py3-none-win_arm64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.