Pre-commit
Pre-commit Hooks
Run GauntletCI before every commit to catch risky changes before they reach CI. Choose the hook manager that fits your toolchain - or skip them all with gauntletci init.
No hook manager required
The fastest setup. Run this once inside your repository to install a native git hook:
$ cd your-repo
$ gauntletci init
This writes a .git/hooks/pre-commit script that runs gauntletci analyze --staged before every commit. No Node.js or Gradle required.
dotnet-husky
dotnet-husky is a .NET-native hook manager with no Node.js dependency. Best for pure .NET repositories.
1. Install dotnet-husky
$ dotnet tool install -g Husky
$ dotnet husky install
2. Create .husky/task-runner.json
{
"tasks": [
{
"name": "GauntletCI",
"command": "gauntletci",
"args": ["analyze", "--sensitivity", "balanced"],
"pathFilter": ["**/*.cs", "**/*.csproj", "**/*.sln", "**/*.slnx"],
"output": "always"
}
]
}3. Create .husky/pre-commit
#!/bin/sh . "$(dirname "$0")/_/husky.sh" dotnet husky run --name GauntletCI
4. Automate for the team
Add to your CI setup step so every developer gets the hook after cloning:
- run: dotnet tool restore - run: dotnet husky install
husky
husky is the most popular git hooks manager for JavaScript and TypeScript projects. Use it for monorepos or full-stack apps that already have a Node.js toolchain.
1. Install and initialize
$ npm install --save-dev husky
$ npx husky init
2. Replace .husky/pre-commit
#!/bin/sh
SENSITIVITY="${GAUNTLETCI_SENSITIVITY:-balanced}"
gauntletci analyze --sensitivity "$SENSITIVITY"3. Share with the team via package.json
{
"scripts": {
"prepare": "husky"
}
}Skip the hook for one commit
Lefthook
Lefthook is a fast, cross-platform hook manager with no Node.js dependency and native support for parallel hook execution. Ideal for pure .NET repositories.
Install
# macOS/Linux
$ brew install lefthook
# Windows
PS> scoop install lefthook
# npm
$ npm install --save-dev lefthook
Configure lefthook.yml
pre-commit:
commands:
gauntletci:
run: gauntletci analyze --sensitivity balanced
glob: "*.cs"The glob filter only triggers GauntletCI when .cs files are staged.
Parallel hooks
Run GauntletCI alongside formatters without blocking on each other:
pre-commit:
parallel: true
commands:
gauntletci:
run: gauntletci analyze --sensitivity balanced
glob: "*.cs"
dotnet-format:
run: dotnet format --verify-no-changes
glob: "*.cs"Install hooks and verify
$ lefthook install
$ lefthook run pre-commit
Choosing a tool
| Tool | Requires | Best for |
|---|---|---|
| gauntletci init | Nothing extra | Solo devs, quick setup |
| dotnet-husky | .NET SDK | Pure .NET teams, task runner |
| husky | Node.js | Monorepos already using npm |
| Lefthook | Nothing extra | Fast parallel hooks, any stack |
Also see: GitHub Action and Azure DevOps for CI/CD pipeline integration.
