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

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

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.0
File Actions
stagelint-0.2.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for stagelint-0.2.0-py3-none-win_arm64.whl
stagelint-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for stagelint-0.2.0-py3-none-win_amd64.whl
stagelint-0.2.0-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.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_2_x86_64.whl
stagelint-0.2.0-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.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_2_aarch64.whl
stagelint-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for stagelint-0.2.0-py3-none-macosx_11_0_arm64.whl
stagelint-0.2.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for stagelint-0.2.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 13.4 MB

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

Download URL stagelint-0.2.0-py3-none-win_arm64.whl
Size 2.2 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
5ed11ee255f14ec88eb617c141ce080f9740f5a1c2322ee1ffa213a57e90fde7
BLAKE2b-256 checksum
How to use checksums
b116c82885da67c89eae6e23ff898bd36bc05d92795c6dc7ad353ccd92b1b392
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 Sep 16, 2026.

Transparency log

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

Download URL stagelint-0.2.0-py3-none-win_amd64.whl
Size 2.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
2fcfe8a753b775c8768417e4edbe08cbc26370e969781ed0a57b5b219a2b7525
BLAKE2b-256 checksum
How to use checksums
4aec254efeaeb993cc0a393abfef045ef4c974abbeb5a4c6a270f400456288c7
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 Sep 16, 2026.

Transparency log

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

Download URL stagelint-0.2.0-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
d787d7308dc74258abeb128745c81626606067ec74936d9c501e07e349f1f116
BLAKE2b-256 checksum
How to use checksums
0f77c69abfd19db4da18bfeed1c074767c6f972ca0dc901ca3b7a38687f9aef6
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 Sep 16, 2026.

Transparency log

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

Download URL stagelint-0.2.0-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
00e86cd40fb2fad9a5621aa9520ce86c4508b3886cd19370980b994c70140c1b
BLAKE2b-256 checksum
How to use checksums
b6113f6757e20ac41be66be6ce0415e6568ecff824217caa3fc583e6acbe64e0
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 Sep 16, 2026.

Transparency log

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

Download URL stagelint-0.2.0-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
b7436de5b05df5a3ee25b8e2269ff0286450e14b3038afeb607cc6d7e25d8f79
BLAKE2b-256 checksum
How to use checksums
2cfe8fcfec271e4a935f0e1e1699a2f1df82ba36cefb36526634d05703c3540e
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 Sep 16, 2026.

Transparency log

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

Download URL stagelint-0.2.0-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
f6247058f315b5d8dd8c4fb35fbf996ae5828e17b2b16fe8ad28b42b1f9ebc8b
BLAKE2b-256 checksum
How to use checksums
ffc098f4a78a8ef3a56a8b6a762c2a122d48686e57573bf64b9b1acd45fa1e8c
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 Sep 16, 2026.

Transparency log

Security for stagelint 0.2.0

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.0-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 Sep 16, 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