A VS Code extension that prevents accidental commits of secrets, credentials, and sensitive information in your repository. Includes an integrated pre-commit hook for additional protection.
- Real-time Secret Detection — Scans your files as you edit and highlights potential secrets
- Pre-commit Protection — Automatically blocks commits containing sensitive data
- Clear Diagnostics — Provides precise file and line references for detected secrets
- Customizable Patterns — Easily extend detection rules for your specific needs
- Visual Indicators — See security warnings directly in the VS Code Problems panel
- Install the extension from the VS Code Marketplace (or via VSIX)
- The pre-commit hook will be automatically configured when you open a Git repository
- If not installed automatically, open the Command Palette.
Windows:Ctrl + Shift + P
MacOS:Cmd + Shift + P
Search "Don't Commit That: Install Pre-Commit Hook" and install it - Start coding with automatic secret detection enabled
- The extension continuously scans open files for patterns matching secrets
- Detected issues appear in the Problems panel with file and line references
- Hover over highlighted code to see detailed information about the detected secret
- When you attempt to commit, staged files are automatically scanned
- If secrets are detected, the commit is blocked with a detailed report in the terminal
- Review and fix the issues before committing again
npm installnpm run compileInstall the hook automatically:
npm run install-hookOr manually integrate hooks/precommit.ts logic into your .git/hooks/pre-commit file.
Press F5 in VS Code to launch the Extension Development Host and test the extension.
Access these commands via the Command Palette (Ctrl+Shift+P or Cmd+Shift+P):
- Don't Commit That: Scan Current File — Manually scan the active file for secrets
- Don't Commit That: Scan Workspace — Scan all files in the workspace
- Don't Commit That: Configure Patterns — Customize secret detection patterns
├── src/
│ ├── extension.ts # Extension entry point
│ ├── scanner/ # Pattern-based file scanning
│ │ └── pattern.ts # Secret detection patterns
│ ├── ignore/ # Ignore rules and hash store
│ └── commands/ # VS Code extension commands
├── hooks/
│ └── precommit.ts # Pre-commit hook logic
└── package.json # Extension manifest
You can now define your own custom detection patterns directly in your VS Code settings.json using the dontCommitThat.customPatterns configuration. This allows you to add, remove, or modify patterns without editing the extension source code.
Example:
"dontCommitThat.customPatterns": [
{
"type": "Custom API Key",
"regex": "custom_api_key_[a-zA-Z0-9]{32}",
"severity": "MEDIUM",
"confidence": "0.6"
}
]Pattern Object Properties:
name(string): A label for your patternregex(string): The regular expression pattern (as a string, not a RegExp object)severity(string) "CRITICAL" | "HIGH" | "MEDIUM" | "LOW"confidence(number, optional): 0 - 1
You can add as many custom patterns as you need. These will be used in addition to the built-in patterns.
Extend ignore logic in src/ignore/ to exclude specific files, patterns, or hash values from detection.
To bypass the pre-commit hook in emergencies (not recommended):
git commit --no-verifyUse the extension's ignore functionality to whitelist false positives without disabling protection entirely.
Configure the extension through VS Code settings (settings.json):
{
"dontCommitThat.enableRealtimeScanning": true,
"dontCommitThat.scanOnSave": true,
"dontCommitThat.excludePatterns": ["**/node_modules/**", "**/dist/**"]
}- VS Code 1.80.0 or higher
- Git repository (for pre-commit hook functionality)
- Node.js 16+ (for development)
Pull requests and issues are welcome! Please open an issue to discuss your ideas or report bugs before submitting a PR.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- See the GitHub Issues page for current known issues
- Initial release
- Real-time secret detection
- Pre-commit hook integration
- Basic pattern matching for common secrets
MIT License

