Skip to main content

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 30 times faster than pre-commit, lint-staged, Lefthook and nano-staged.

A pre-commit run: independent globs in parallel, overlapping ones in order

Why stagelint?

Running formatters before a commit is easy until you stage part of a file. You stage 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 your unstaged changes. 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.

Read the documentation

Getting started

Node

npm install --save-dev @stagelint/stagelint

If you do not already use a hook manager, add the hook to your prepare script so it installs itself for the whole team:

{
  "scripts": {
    "prepare": "stagelint init"
  }
}

Python

pipx install stagelint

Rust

Download a prebuilt binary using cargo-binstall:

cargo binstall stagelint

Or compile it from source:

cargo install stagelint

Go

go install github.com/abemedia/stagelint@latest

.NET

dotnet tool install -g stagelint

Homebrew

brew install abemedia/tap/stagelint

Install script

Download, verify and install a prebuilt binary:

curl -fsSL https://stagelint.dev/install.sh | sh

It installs to /usr/local/bin when that is writable, otherwise to ~/.local/bin. Set STAGELINT_INSTALL_DIR to choose the directory, or STAGELINT_VERSION to install a specific version.

Other methods

See the installation docs for more ways to install stagelint, including APT, DNF, Pacman, WinGet, Scoop, Nix and mise.

Setting up the hook

If you already use a hook manager like pre-commit, Lefthook, or husky, call stagelint from its configuration rather than running stagelint init. See the hook manager docs for how to set up each one.

stagelint init

This creates .git/hooks/pre-commit (or respects core.hooksPath). Use --force to overwrite an existing hook.

Pass any CLI flag after -- for the hook to run stagelint with:

stagelint init -- --stash tracked

See the CLI reference for the full list of supported flags.

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.

Negation patterns such as !(*.ts) are not supported, and match nothing rather than failing, so a task configured with one never runs.

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.

Locally installed tools

Commands resolve to the tools installed in your project, so there is no need for npx or uv run. Any node_modules/.bin, .venv/bin (.venv/Scripts on Windows) or vendor/bin directory in the config file's directory, or in any directory above it up to the repository root, is added to PATH.

Coding agents

The same config runs over a coding agent's edits and hands failures back for the agent to fix. For Claude Code, add this to .claude/settings.json:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "stagelint --unstaged --quiet || exit 2"
          }
        ]
      }
    ]
  }
}

See the agent hook docs for how to set up other agents.

Continuous integration

Check every pull request, including commits that skipped the hook. In GitHub Actions, add the stagelint action to a workflow:

name: stagelint

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  stagelint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      # Install the tools your stagelint config runs.

      - uses: abemedia/stagelint-action@v1

See the CI docs for the action's options and instructions for other CI providers.

Benchmarks

Each cell is fully staged / partially staged, measured on a 1,000-file repository with a no-op task, on a 2019 MacBook Pro (Intel Core i9-9880H).

Staged files stagelint Lefthook nano-staged lint-staged pre-commit
10 15ms / 30ms 152ms / 373ms 224ms / 311ms 437ms / 530ms 450ms / 525ms
100 19ms / 76ms 163ms / 537ms 249ms / 425ms 455ms / 672ms 486ms / 612ms

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.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for stagelint 0.2.2
File Actions
stagelint-0.2.2-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for stagelint-0.2.2-py3-none-win_arm64.whl
stagelint-0.2.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for stagelint-0.2.2-py3-none-win_amd64.whl
stagelint-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_2_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux musl 1.2+ x86-64 Details for stagelint-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_2_x86_64.whl
stagelint-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64, Linux glibc 2.17+ ARM64 Details for stagelint-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_2_aarch64.whl
stagelint-0.2.2-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for stagelint-0.2.2-py3-none-macosx_11_0_arm64.whl
stagelint-0.2.2-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for stagelint-0.2.2-py3-none-macosx_10_12_x86_64.whl

Total release size: 13.0 MB

Release files / stagelint-0.2.2-py3-none-win_arm64.whl

Download URL stagelint-0.2.2-py3-none-win_arm64.whl
Size 2.1 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
74f48bf6034ba813acbed14b5572cbb0707889096b798e2ae799901b66f97deb
BLAKE2b-256 checksum
How to use checksums
1e802ab6f9cd28d4584cc5252e5bb3ea289a949e36c949f1a204fbfed033152a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 29, 2026.

Transparency log

Release files / stagelint-0.2.2-py3-none-win_amd64.whl

Download URL stagelint-0.2.2-py3-none-win_amd64.whl
Size 2.2 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
05d08917d3e22999f1f9755a1c321591ba4bc92c681b4a38ee0c6b496b3b5630
BLAKE2b-256 checksum
How to use checksums
b218029edc4d87673114398ee37746733638b08a76192773b0384c6b1ad7fe4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 29, 2026.

Transparency log

Release files / stagelint-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_2_x86_64.whl

Download URL stagelint-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_2_x86_64.whl
Size 2.3 MB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
43145b470ce9346ef883c39f1d5f6c950d5a522165bf96e7853e0996f5a3f3ee
BLAKE2b-256 checksum
How to use checksums
c36c3dd1f68b402605dc4d801af56c9381313a3ef2a96c1870fdcb71f346ded8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 29, 2026.

Transparency log

Release files / stagelint-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_2_aarch64.whl

Download URL stagelint-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_2_aarch64.whl
Size 2.3 MB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b974928f39aa44f8e0c916cd828eda062fac63267871d6539aa3e74ed3c39bca
BLAKE2b-256 checksum
How to use checksums
4abf1b95c4a355616686e4254d0568646fa8fe53765019d1633c282cf367528a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 29, 2026.

Transparency log

Release files / stagelint-0.2.2-py3-none-macosx_11_0_arm64.whl

Download URL stagelint-0.2.2-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
28cfadef248d1684e0045c15a74c42ba48a76b56c24375660bd2b8a13d2621d6
BLAKE2b-256 checksum
How to use checksums
b7ccaec8cf9dd555af88678d19b53b25cf317d2937544396156e097578383c78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 29, 2026.

Transparency log

Release files / stagelint-0.2.2-py3-none-macosx_10_12_x86_64.whl

Download URL stagelint-0.2.2-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
19e5c8e7c0b6f366791d4963e3e1ae979795e4d6b062e35cdbc5bddfaba1c474
BLAKE2b-256 checksum
How to use checksums
fadb2b413f899719a51eed5a50e6d119f0d62d14fb73f8e83170f84394ce370c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 29, 2026.

Transparency log

Security for stagelint 0.2.2

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.

Select from 6 files

Attestation for stagelint-0.2.2-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 Oct 29, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page