Approach 1: Direct command (no framework)
The simplest setup is a plain Git hook that calls aislop on staged files. Run this once in your repository root:.git/hooks/pre-commit (create the file if it doesn’t exist and make it executable):
git commit to abort.
Approach 2: pre-commit framework hook
If your project already uses the pre-commit framework, add the aislop hook to your.pre-commit-config.yaml. The bundled hook runs aislop scan --staged automatically.
Install the pre-commit framework
Add the aislop hook to your config
Create or update The hook is defined with these properties:
.pre-commit-config.yaml in your repository root:- entry:
aislop scan --staged— scans only staged files - language:
node - pass_filenames:
false— aislop discovers staged files itself - require_serial:
true— runs after other hooks complete
Install the hooks into your repository
.git/hooks/pre-commit. From this point on, every git commit runs aislop on your staged files.What the hook scans
The--staged flag tells aislop to inspect only the files in your Git staging area (git diff --cached). Files that are modified but not staged are ignored, keeping the check fast and focused on what you are actually committing.
The hook scores only the staged subset of your codebase. The quality gate threshold from
.aislop/config.yml still applies — a score below failBelow or any error-severity diagnostic will block the commit.