This tutorial walks you through installing and using the sanitize pre-commit hook in a git repository. By the end, you'll have automatic secret detection running on every commit.
- A git repository
- Bash (macOS, Linux, or WSL on Windows)
- Node.js (for
npx skills— optional)
If you use Claude Code, Cursor, Copilot, or any tool supporting Agent Skills:
npx skills add vxcozy/sanitizeThis installs the /sanitize slash command into your project. Skip to Step 5 to use it.
git clone https://github.com/vxcozy/sanitize.git
cd sanitize./scripts/install-hooks.sh /path/to/your/projectYou should see:
Installing 12-point sanitization pre-commit hook...
install /path/to/your/project
Done. The hook runs automatically on git commit.
Bypass with: git commit --no-verify
Go to your project and commit something:
cd /path/to/your/project
echo "hello" > test.txt
git add test.txt
git commit -m "test commit"You'll see the 12-point checklist run:
Pre-commit: 12-point sanitization
[ 1/12] Staged files 1 file(s)
test.txt
[ 2/12] Private keys / mnemonics pass
[ 3/12] API keys / tokens / secrets pass
...
[12/12] Test files with real credentials pass
All 12 checks passed
Create a file with a fake API key:
echo 'API_KEY = "sk-test-abcdefghijklmnopqrstuvwxyz123"' > bad.txt
git add bad.txt
git commit -m "oops"The hook blocks the commit:
[ 3/12] API keys / tokens / secrets FAIL
API_KEY = "sk-test-abcdefghijklmnopqrstuvwxyz123"
BLOCKED: 1 check(s) failed
Fix the issues above or bypass with: git commit --no-verify
Remove the secret, then commit normally:
rm bad.txt
git reset HEAD bad.txtIf you installed via npx skills add (Step 1A), the /sanitize command is already available.
Run /sanitize in your AI coding tool for an interactive audit that scans your entire repository with detailed file:line references.
- Read the how-to guides for specific tasks like customizing patterns or installing across multiple repos
- See the reference for the full list of patterns and configuration
- Read the explanation to understand why each check exists