Hello Rustaceans! ![]()
I built SecretGuard, an open-source terminal privacy guard in Rust that intercepts API keys and credentials at the keystroke level before commands ever touch persistent disk (~/.zsh_history, ~/.bash_history) or local AI coding agent logs (Claude Code, Cursor).
Why Rust?
To make a pre-exec line-hook imperceptible, it has to run in microseconds. SecretGuard achieves 15.68 µs (0.016 ms) average scan latency across 1,000 synthetic commands with a 1.56 MB static binary footprint (opt-level = 3, lto = true, codegen-units = 1, panic = "abort").
Architecture:
- Tier 1 (RegexSet): Compiled in-memory matcher for known SaaS signatures (OpenAI, AWS, GitHub, Stripe, Slack, Postgres URIs).
- Tier 2 (Contextual Shannon Entropy): Evaluates character probability distribution ($H \ge 3.6$) for raw passwords while eliminating false positives like UUIDs and Git commit hashes.
Core Capabilities (v0.1.2):
-
secretguard hook <shell>— Line hooks for Zsh, Bash, Fish, NuShell, and PowerShell. -
secretguard install-pre-commit— Installs an ultra-fast (<0.02ms) git pre-commit hook into your repo. -
secretguard scan <path>— Recursive codebase and.envscanner. -
secretguard audit&clean-history— Audits past history with atomic.bakbackups. -
secretguard protect-agent— Workspace shield for Claude Code & Cursor configs. -
secretguard doctor— System diagnostics & live latency benchmarking. -
Interactive Web Sandbox: SecretGuard — Never Leak API Keys to Your Terminal History
I would love to get the community's thoughts on the entropy heuristics and benchmark methodology!
2 posts - 1 participant

