Skip to content

Commit 1a9fb34

Browse files
committed
chore: migrate from pre-commit to prek for faster hook execution
- Replace pre-commit with prek (Rust-based alternative) - Update CONTRIBUTING.md with prek installation instructions - Update .husky/pre-push to use prek command - Add exclude pattern for JSON5 files (tsconfig.json, .oxlintrc.json) - Remove Python 3.10+ requirement (prek is a single binary) Benefits: - Faster hook execution (Rust vs Python) - No Python runtime dependency required - Drop-in compatible with existing .pre-commit-config.yaml - Better security features (SHA validation, cooldown periods)
1 parent e49a8a7 commit 1a9fb34

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

.husky/pre-push

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/sh
22
set -e
33

4-
# Run pre-commit hooks (if installed)
5-
if command -v pre-commit >/dev/null 2>&1; then
6-
pre-commit run --hook-stage push
4+
# Run prek hooks (if installed)
5+
if command -v prek >/dev/null 2>&1; then
6+
prek run --stage pre-push
77
fi
88

99
# Check if bun version matches package.json

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ repos:
99
- id: end-of-file-fixer
1010
- id: check-yaml
1111
- id: check-json
12+
exclude: 'tsconfig\.json$|\.oxlintrc\.json$'
1213
- id: check-toml
1314
- id: check-added-large-files
1415
args: [ "--maxkb=1000" ]

CONTRIBUTING.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ https://github.com/anomalyco/models.dev
3131

3232
## Developing OpenCode
3333

34-
- Requirements: Bun 1.3+, Python 3.10+ (for pre-commit hooks)
34+
- Requirements: Bun 1.3+
3535
- Install dependencies and start the dev server from the repo root:
3636

3737
```bash
@@ -47,26 +47,36 @@ Pre-commit hooks automatically validate code before pushing. This includes:
4747
- Standard checks (trailing whitespace, JSON/YAML validation, etc.)
4848
- `.env` file protection
4949

50-
To install pre-commit:
50+
We use [prek](https://prek.j178.dev/), a fast Rust-based drop-in replacement for pre-commit.
51+
52+
To install prek:
5153

5254
```bash
53-
pip install pre-commit
54-
# or with uv:
55-
uv pip install pre-commit
55+
# Using uv (recommended)
56+
uv tool install prek
57+
58+
# Using pip
59+
pip install prek
60+
61+
# Using Homebrew
62+
brew install prek
63+
64+
# Or via standalone installer
65+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/latest/download/prek-installer.sh | sh
5666
```
5767

5868
Then install the git hooks:
5969

6070
```bash
61-
pre-commit install
71+
prek install
6272
```
6373

64-
This integrates pre-commit into the `pre-push` Husky hook. Hooks will run automatically when you push. To manually run:
74+
This integrates prek into the `pre-push` Husky hook. Hooks will run automatically when you push. To manually run:
6575

6676
```bash
67-
pre-commit run --hook-stage push # Run all hooks
68-
pre-commit run --hook-stage push --files <file> # Run on specific file
69-
pre-commit run gitleaks-docker --hook-stage push # Run single hook
77+
prek run --stage pre-push # Run all hooks
78+
prek run --stage pre-push --files <file> # Run on specific file
79+
prek run gitleaks-docker --stage pre-push # Run single hook
7080
```
7181

7282
### Running against a different directory

0 commit comments

Comments
 (0)