A fast secret scanner for files and directories.
cargo install key-watch
key-watch --version
# Enable aliases for your current shell session
eval "$(key-watch init bash)"To make aliases persistent, add the init line to your shell config file:
# bash
echo 'eval "$(key-watch init bash)"' >> ~/.bashrc
# zsh
echo 'eval "$(key-watch init zsh)"' >> ~/.zshrc- Download the correct binary for your OS/architecture from GitHub Releases.
- Move it to a directory on your
PATH, for example~/.local/bin. - Make it executable.
- Verify it runs.
- Enable aliases with
init.
mkdir -p ~/.local/bin
mv ~/Downloads/key-watch ~/.local/bin/key-watch
chmod +x ~/.local/bin/key-watch
~/.local/bin/key-watch --version
# Enable aliases for current shell session
eval "$(~/.local/bin/key-watch init bash)"Requires Rust 1.85+ (edition 2024) when building from source.
The canonical command is key-watch.
keywatch and kw are optional shell aliases exposed via key-watch init ....
cargo uninstall key-watchIf you added aliases to your shell config, remove the init line you added earlier, for example:
# bash
sed -i.bak '/key-watch init bash/d' ~/.bashrc
# zsh
sed -i.bak '/key-watch init zsh/d' ~/.zshrc- Remove the
key-watchbinary from yourPATHdirectory. - Remove any shell init line you added for aliases.
- Restart your shell or reload your shell config.
rm -f ~/.local/bin/key-watch
# If you added aliases for the current shell config, remove that line manually
# then reload your shell config, for example:
source ~/.bashrc# Scan a file
key-watch scan secrets.txt
# Scan a directory
key-watch scan .
# Verbose output (JSON)
key-watch scan secrets.txt --verbose
# Install git hook
key-watch hook install pre-commit
key-watch hook install pre-push
# Remove git hook
key-watch hook uninstall pre-commit
key-watch hook uninstall pre-push
# Install git hook globally via core.hooksPath
key-watch hook install pre-commit --global
key-watch hook install pre-push --global
# Remove global hook
key-watch hook uninstall pre-commit --global
key-watch hook uninstall pre-push --global
# Print shell aliases
eval "$(key-watch init bash)"
# Verify binary integrity
key-watch verify-integrityscan <path>...- Scan one or more files or directoriesscan --output <path>- Save report to filescan --verbose- Print full JSON outputscan --exclude <patterns>- Comma-separated glob patterns to excludescan --exit-mode <mode>- Exit behavior:always(always pass),critical(fail on HIGH only),strict(fail on any finding, default)hook install <pre-commit|pre-push> [--global]- Install a git hookhook uninstall <pre-commit|pre-push> [--global]- Remove a git hookhook install pre-push --allowed-repos <urls>- Whitelist repos for pre-push hookshook install pre-push --blocked-repos <urls>- Block repos for pre-push hookshook install pre-commit --exclude <patterns>- Exclude patterns for pre-commit scansinit <shell>- Print shell aliases forkeywatchandkwverify-integrity- Check binary hasn't been tampered with
key-watchis the only shipped binary.keywatchandkware optional aliases.key-watch init bash|zsh|fish|posixprints shell aliases you can eval in your shell.watchis intentionally not used, to avoid colliding with the standard Unixwatchcommand.
| Code | Meaning |
|---|---|
| 0 | No secrets found (or scan --exit-mode always) |
| 1 | Secret found (in strict/critical mode) |
| 2 | Runtime/configuration error |
- Repos: All allowed (no restrictions)
- Exit mode: strict (fail on any finding)
hook install pre-commit|pre-pushinstalls a repo-local hook into.git/hooks/hook uninstall pre-commit|pre-pushremoves a KeyWatch hook from the same targethook install ... --globalinstalls into Git's global hooks directoryhook uninstall ... --globalremoves the hook from Git's global hooks directory- Local hook paths are resolved via
git rev-parse --git-path hooks, so installs work in worktrees and submodules too - If
core.hooksPathis already configured, KeyWatch installs into that directory - Otherwise KeyWatch creates a managed hooks directory and configures
git config --global core.hooksPath - KeyWatch refuses to overwrite a non-KeyWatch global hook file
- KeyWatch also refuses to remove a non-KeyWatch global hook file
cargo build --release
cargo test
cargo fmt
cargo clippy