# pre-commit (npm)

> Installs a git pre-commit hook that runs your npm scripts before each commit

Source: https://talira.ai/catalog/pre-commit-npm-p7tsxe3k
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Command-line tool
- Categories: [developer tools / git / hooks](https://talira.ai/categories/developer-tools/git/hooks)
- Platforms: macos, linux, windows[^2]
- Licence: MIT[^1]
- Pricing: Free and open source[^1]
- Pricing notes: Free and open source (MIT).
- Free tier: yes[^1]
- Backed by: [Observing](https://talira.ai/orgs/observing.md)

pre-commit is an npm package that installs a git pre-commit hook, so your npm test, or other scripts you list in package.json, must pass before a commit goes through. Installed as a dev dependency, it replaces the repository's existing pre-commit hook (keeping a backup as pre-commit.old) and reads which scripts to run, in order, from a pre-commit field in package.json. A commit can still skip it with git's --no-verify. It's a separate project from the Python-based pre-commit framework.

## Links

- GitHub: https://github.com/observing/pre-commit

## Problems it solves

- stop teammates committing code when the npm tests fail
- run my lint and test npm scripts automatically before every git commit
- set up a git pre-commit hook from package.json without writing shell scripts

## Features

- installs a git pre-commit hook when added as a dev dependency
- runs npm test, or the scripts listed in package.json, before each commit
- backs up an existing pre-commit hook as pre-commit.old

## Trust

Overall: 0.37 out of 1.
Signals: maintenance 0.27, adoption 0.65, momentum 0.33, community 0.63, backing 0.30, extensibility 0.00.

- latest release 1.1.1 11.3 years ago
- 1.9k GitHub stars
- 37 contributors
- backed by Observing

Warnings:

- last commit 7 months ago

## Alternatives

- [Husky](https://talira.ai/catalog/husky-zpjapvjr.md): Native Git hooks for npm projects, in 2 kB with no dependencies
- [pre-commit](https://talira.ai/catalog/pre-commit-ymy35rpp.md): A framework for managing and maintaining multi-language pre-commit hooks.
- [Lefthook](https://talira.ai/catalog/lefthook-882qc1jp.md): Fast and powerful Git hooks manager for any type of projects.
- [simple-git-hooks](https://talira.ai/catalog/simple-git-hooks-258pdf36.md): A zero-dependency tool to manage git hooks from package.json
- [commitlint](https://talira.ai/catalog/commitlint-pcb6j4ak.md): Lint commit messages against your team's commit convention
- [lint-staged](https://talira.ai/catalog/lint-staged-p1rk71x0.md): Run tasks like formatters and linters against files staged in Git

## Sources

[^1]: https://github.com/observing/pre-commit/blob/master/LICENSE (checked 29 Nov 2026)
[^2]: https://github.com/observing/pre-commit/blob/master/README.md (checked 29 Nov 2026)
