# Lefthook vs pre-commit: Hookマネージャの比較

> Lefthook vs pre-commit: 並列hooksを備えた高速なGoバイナリ vs 大きなhookレジストリを持つPythonフレームワーク。速度、エコシステム、CIへの適合性を比較。

Source: https://latchkey.dev/ja/learn/tool-comparisons/lefthook-vs-pre-commit  
Updated: 2026-06-26

Lefthookはhooksを並列実行する高速な単一のGoバイナリです。pre-commitは、すぐに使えるhooksの大きなレジストリを持つPythonフレームワークです。

LefthookはhooksをYAMLで設定し並列実行し、依存関係のない単一バイナリとして配布されるため、高速で言語非依存です。Pythonで書かれたpre-commitは、隔離されたhook環境を管理し、バージョンで固定された共有可能なhooksの巨大なエコシステムを提供します。これはリポジトリ間でチェックを標準化するのに優れています。Lefthookは速度とシンプルさを、pre-commitは豊かで再現可能なhookカタログを優先します。

## Comparison

|  | Lefthook | pre-commit |
| --- | --- | --- |
| ランタイム | 単一のGoバイナリ | Pythonフレームワーク |
| hookエコシステム | コマンドを自分で定義 | 大きな共有レジストリ |
| 並列性 | 組み込み | 限定的 |
| 環境の隔離 | なし | hookごとの環境 |
| 最適な用途 | 速度、シンプルさ | 共有・固定されたhooks |

## CIでの利用

pre-commitは、多くのリポジトリで再利用される、キュレーションされバージョン固定されたコミュニティのhooksが欲しいときに輝き、クリーンなCIモードを備えています。Lefthookはより高速で依存関係がなく、主に自分のコマンドを実行し並列性が欲しいときに理想的です。ローカルのhookを超えてチェックが強制されるよう、どちらもCIでも実行すべきです。

## 高速化する

hook環境(pre-commit)または依存関係をキャッシュして、CIのチェックがウォームな状態で始まるようにします。チェックはランナー上で実行され、より高速なマネージドランナーはhookとlintの実行を短縮します。

## Benchmark on your repository before choosing

Build-tool benchmarks published by vendors use repositories chosen to show a difference. Yours is the only one that matters, and both a cold and a warm measurement are needed because CI mostly runs cold.

```Terminal
# cold: no cache, the CI condition
rm -rf node_modules/.cache dist && time <tool> build

# warm: the local development condition
time <tool> build

# and the one people forget: incremental after a one-line change
echo "// touch" >> src/index.ts && time <tool> build
```

> Cold and warm can rank the two tools in opposite orders. Decide which one you are optimising for first: CI time is cold, developer feedback is warm and incremental.

## 結論

リポジトリ間で標準化された、共有可能でバージョン固定されたhooksの大きなレジストリが欲しい場合: pre-commit。自分のコマンドを並列で実行する高速で依存関係のないバイナリが欲しい場合: Lefthook。共有hookカタログを重視するチームはpre-commitに、速度重視のチームはLefthookに傾きます。

## FAQ

### Lefthook vs pre-commit: Hook Managers Compared?

Lefthook configures hooks in YAML, runs them in parallel, and ships as one dependency-free binary, making it quick and language-agnostic. pre-commit, written in Python, manages isolated hook environments and offers a huge ecosystem of shareable hooks pinned by version, which is excellent for standardizing checks across repos.

### In CI?

pre-commit shines when you want a curated, version-pinned set of community hooks reused across many repos, and it has a clean CI mode. Lefthook is faster and dependency-free, ideal when you mostly run your own commands and want parallelism. Both should also run in CI so checks are enforced beyond local hooks.

### Speed it up?

Cache the hook environments (pre-commit) or dependencies so CI checks start warm. The checks run on runners; faster managed runners shorten hook and lint execution.

### Which should I choose?

Wanting a large registry of shareable, version-pinned hooks standardized across repos: pre-commit. Wanting a fast, dependency-free binary running your own commands in parallel: Lefthook. Teams that value a shared hook catalog lean pre-commit; speed-focused ones lean Lefthook.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
