Skip to content

Block violations before commit

You want violations blocked locally before they’re committed, so a bad commit never even lands on your branch. This guide wires both checkers into pre-commit.

If you haven’t already:

Terminal window
pip install pre-commit
pre-commit install

Drop this at the repo root as .pre-commit-config.yaml. Adjust the files: filters to match where your code lives: chisel_py / chisel_js below are chisel’s own monorepo dirs, rename them to your project.

.pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: chisel-py
name: chisel (Python)
entry: chisel check chisel_py --strict
language: python
language_version: python3.12
additional_dependencies: [grimp>=3.0, radon>=6.0, typer>=0.12, rich>=13.0]
files: ^chisel_py/src/.*\.py$
pass_filenames: false
- id: chisel-js
name: chisel (TypeScript)
entry: chisel-js check .
language: system
files: ^(chisel_js/src/.*\.ts|chisel_js/.*\.svelte)$
pass_filenames: false

Use one hook or both depending on your stack: a pure-FastAPI repo only needs chisel-py; a pure-SvelteKit repo only needs chisel-js.

Terminal window
pip install chisel # for the chisel-py hook
npm install -g chisel-js # for the chisel-js hook (or: bun add -g chisel-js)

Run chisel-js init once and commit the result:

Terminal window
chisel-js init .
git add chisel.config.json

This matters more for a hook than for an ad-hoc check. Without the config chisel-js re-detects the topology on every run, so a dependency change could quietly alter which rules gate your commits. Committing the file pins the mode and makes any change to it show up in review, like any other change.

Every git commit now runs the hooks. They use pass_filenames: false because chisel scans the whole project, not individual files.