Skip to main content
Running aislop as a pre-commit hook catches quality regressions before they ever reach your repository history. aislop scans only the files you have staged, so the check completes in well under a second on typical diffs. You can wire it up with a one-line command or integrate it into the pre-commit framework alongside your other hooks.

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:
To make it permanent, add the command to .git/hooks/pre-commit (create the file if it doesn’t exist and make it executable):
aislop exits non-zero when it finds issues above your configured threshold, which causes 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.
1

Install the pre-commit framework

Or use your preferred package manager. Full installation options are in the pre-commit docs.
2

Add the aislop hook to your config

Create or update .pre-commit-config.yaml in your repository root:
The hook is defined with these properties:
  • 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
3

Install the hooks into your repository

This writes the framework’s hook runner to .git/hooks/pre-commit. From this point on, every git commit runs aislop on your staged files.
4

(Optional) Run against all files once

To check your entire codebase before the first commit gate:

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.

Combining with AI agent hooks

If you use Claude Code, Cursor, Gemini CLI, or another AI coding agent, you can install a complementary post-edit hook that runs aislop after every agent edit — not just at commit time. This creates a tight feedback loop for agent-generated code.
Use both together: the agent hook catches slop as it’s written, and the pre-commit hook acts as a final safety net before code enters version control.