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.
Install pre-commit
Section titled “Install pre-commit”If you haven’t already:
pip install pre-commitpre-commit installAdd the hook config
Section titled “Add the hook config”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.
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: falseUse one hook or both depending on your stack: a pure-FastAPI repo only
needs chisel-py; a pure-SvelteKit repo only needs chisel-js.
Install the CLIs the hooks call
Section titled “Install the CLIs the hooks call”pip install chisel # for the chisel-py hooknpm install -g chisel-js # for the chisel-js hook (or: bun add -g chisel-js)Commit a chisel.config.json
Section titled “Commit a chisel.config.json”Run chisel-js init once and commit the result:
chisel-js init .git add chisel.config.jsonThis 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.
Trigger
Section titled “Trigger”Every git commit now runs the hooks. They use pass_filenames: false
because chisel scans the whole project, not individual files.
What’s next
Section titled “What’s next”- Run chisel in GitHub Actions: gate pull requests on the same check.
- Turn off a rule for a file: when a hook failure is a justified exception.