Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

lint-staged

Run linters on git staged files to catch issues before commit.

Dev workflow and configNPM

GitHubWebsite

1. License

License from npm.

github.com/lint-staged/lint-staged

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What lint-staged does

lint-staged does not lint anything itself: it hands the list of staged files to whatever shell command you map to a glob, and wraps the run in a git stash backup so a failed task can be rolled back.

lint-staged popularity

80 / 100
Gid Score, #98 overall
42.6M
downloads a week, npm
14.8K
GitHub stars
487
agent projects use it
lint-staged: downloads per weeknpm, lint-staged 42,635,558
lint-staged: GitHub starslint-staged/lint-staged 14,767

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How lint-staged is used

  • lint-staged is a dependency in 487 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (10.0% of the 4,867 JavaScript/TypeScript ones), #4 of 299 in dev workflow and config.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,035; those are left out of every share on this page.
  • The most used alternative in our scan is Lefthook (127 projects).
  • Projects that use it most often also use Husky (89.3%), Prettier (71.0%), ESLint (71.9%).
  • It is more common in projects set up for OpenAI Codex (13.9%) than for GitHub Copilot (8.2%).

By coding agent

311 projects, 9.5%
248 projects, 8.2%
228 projects, 9.3%
65 projects, 13.9%
61 projects, 12.9%
43 projects, 12.5%
27 projects, 9.7%
12 projects, 8.6%

Often used with

In 89.3% of its projects
In 71.0% of its projects
In 71.9% of its projects
In 82.3% of its projects
In 46.0% of its projects
In 39.4% of its projects
In 27.9% of its projects
In 35.7% of its projects

lint-staged in practice

Strengths

Any command, keyed by glob

lint-staged is not tied to one linter. The config maps picomatch globs to shell commands, so ESLint, Prettier, or a project script all plug in the same way.

A stash backup before every run

The README says lint-staged stashes the original state before any task runs. If a task errors, task modifications are reverted by default, and lost changes can be restored from the stash entry it labels "lint-staged automatic backup".

Partially staged files are handled

If you used <code>git add --patch</code>, the unstaged parts of those files are hidden while tasks run and restored afterwards. <code>--hide-unstaged</code> and <code>--hide-all</code> extend this to all unstaged changes, and to untracked files too.

Per-package configs in a monorepo

You can place several config files in a project. Each staged file uses the nearest one, and its tasks run in that config's directory.

Watch out for

Overlapping globs can race

Globs run concurrently by default. If two globs match the same file and both tasks edit files, they can write to it at once. The README's fix is a negation pattern plus the array syntax.

Tasks can stage your unstaged edits

Since the latest release, lint-staged stages every tracked file a task modifies, including files you never staged. The release notes point to <code>--hide-unstaged</code> to avoid this.

Some flags drop the safety stash

<code>--all</code> and <code>--diff</code> both imply <code>--no-stash</code>, so the automatic backup is off when you use them.

Typed config with defineConfig

import { defineConfig } from 'lint-staged/config'

export default defineConfig({
  '*': 'prettier --write',
})

More about lint-staged

Funding
  • Open Collective: https://opencollective.com/lint-staged

See all

Packages around it
  • husky: Git hook runner
  • prettier: Code formatter
  • eslint: JavaScript linter
  • vitest: Unit test runner
  • typescript: Typed JavaScript
  • @playwright/test: End-to-end tests
More in Dev workflow and config

Alternatives

lint-staged This page

MITGid 8042.6M/wk

Lefthook

Fast git hooks manager for running checks and tasks on commits.

MITGid 7010.2M/wk

Compare lint-staged with another tool

Get started

Install it.

npm install lint-staged

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## lint-staged
- Install with `npm install --save-dev lint-staged`, then wire it into a `pre-commit` git hook (the README names Husky). Commit `package.json` and `.husky` so the team shares the setup.
- Do not pass file paths in config commands: lint-staged appends the staged files as arguments.
- Never let two globs that match the same files both run editing tasks. Use a negation pattern such as `!(*.ts)` plus the array syntax.
- Use an array (`["prettier --list-different", "eslint"]`) to run commands in order for one glob. Nest one more array to run them in parallel.
- In CI, run `npx lint-staged --all`. Note that it implies `--no-stash`.
- Type JS configs with `defineConfig` from `lint-staged/config`.
- If tasks may edit files that have unstaged changes, use `--hide-unstaged`, or those changes get staged too.