🛡️ Prevent secrets from being committed to your Git repositories
A lightweight CLI tool that automatically detects and blocks API keys, passwords, and other sensitive data from being committed to version control.
- 🔍 Smart Detection - Detects AWS keys, Stripe keys, OpenAI tokens, database URLs, and more
- 🪝 Git Integration - Automatic pre-commit hooks to prevent accidents
- 🚀 Zero Config - Works out of the box with sensible defaults
- ⚡ Fast & Lightweight - Minimal dependencies, maximum performance
- 🎯 Developer Friendly - Clear error messages and helpful suggestions
npx secure-commit scannpx secure-commit installThis installs a git pre-commit hook that automatically scans files before each commit.
npx secure-commit init| Command | Description |
|---|---|
npx secure-commit scan |
Scan current directory for secrets |
npx secure-commit install |
Install git pre-commit hooks |
npx secure-commit uninstall |
Remove git pre-commit hooks |
npx secure-commit init |
Setup .gitignore patterns and install hooks |
npx secure-commit clean |
Remove tracked sensitive files from git |
npx secure-commit preview |
Preview .gitignore changes |
- AWS Access Keys (
AKIA...) - Stripe API Keys (
sk_live_...,sk_test_...) - OpenAI API Keys (
sk-...) - GitHub Personal Access Tokens (
ghp_...) - Google API Keys (
AIza...) - Database Connection Strings (connection URLs with credentials)
# Scan for secrets
npx secure-commit scan
# Install protection
npx secure-commit install
# Test with a dummy secret (will be blocked)
echo "const key = 'your-api-key-here'" > test.js
git add test.js
git commit -m "test" # This will be blocked!# Force reinstall hooks
npx secure-commit install --force
# Preview cleanup without making changes
npx secure-commit clean --preview- Pre-commit Hook: When you try to commit, the hook scans staged files
- Pattern Matching: Uses regex patterns to identify secret formats
- Immediate Feedback: Shows exactly what was found and where
- Helpful Guidance: Suggests how to fix the issue
Sometimes you need to commit test data or examples:
# Skip the pre-commit hook (use carefully!)
git commit --no-verify -m "Add test fixtures"The tool works without configuration, but you can customize:
- Add patterns to
.gitignore - Modify the pre-commit hook for custom behavior
- Use with existing git hooks (they're preserved)
- Node.js 14+
- Git repository
MIT © Samuel Umoren