AI Secret Hygiene — MCP server, proxy, and hooks that catch and remediate hardcoded secrets in AI-generated code
Project description
aigate
Local secret scanner that intercepts AI API calls and prevents credentials from leaking to LLMs.
Install
pip install aigate
Requires Python 3.11+ and jq (for Claude Code hooks).
Quick start
Claude Code (hooks — no proxy needed)
aigate install-hook
All prompts and tool calls are scanned automatically:
- Prompts — blocked if secrets are detected (you fix and resend)
- Tool inputs (Bash, Write, Edit, etc.) — secrets are redacted with env var placeholders and the tool runs with sanitized values. Real credentials are saved to
.envautomatically.
Any AI tool (proxy mode)
Terminal 1 — proxy:
aigate setup # one-time: installs CA cert (needs sudo)
aigate start --mode redact # start the proxy
Terminal 2 — your AI tool:
source ~/.bashrc # load cert env vars (or open a new terminal)
export HTTPS_PROXY=http://127.0.0.1:8080
export HTTP_PROXY=http://127.0.0.1:8080
claude # or any other AI tool
aigate setup installs the mitmproxy CA cert into the system trust store and adds NODE_EXTRA_CA_CERTS to ~/.bashrc so Claude Code / Node.js trusts the proxy.
Scan a file directly
aigate scan .env
cat prompt.txt | aigate scan -
aigate scan .env --redact # redact secrets and save to .env
Modes
aigate start --mode block # reject requests containing secrets (default)
aigate start --mode redact # replace secrets with env var placeholders
aigate start --mode warn # forward but log a warning
aigate start --mode audit # forward silently, log only
Redact mode
Instead of blocking, redact mode rewrites the request before it reaches the AI:
- Detects secrets in your prompt (AWS keys, API tokens, database URLs, private keys, etc.)
- Replaces them with placeholders like
[REDACTED_ANTHROPIC_API_KEY] - Saves the real credentials to a local
.envfile - Injects a system instruction telling the AI to use
os.environ[]and load from.env - Forwards the sanitized request — the AI never sees the real credentials
The AI acknowledges the redaction, then writes secure code using environment variables automatically. Token prefixes are mapped to conventional env var names:
| Token | Env var |
|---|---|
sk-ant-* |
ANTHROPIC_API_KEY |
sk-*, sk-proj-* |
OPENAI_API_KEY |
ghp_*, github_pat_* |
GITHUB_TOKEN |
glpat-* |
GITLAB_TOKEN |
xoxb-* |
SLACK_BOT_TOKEN |
SG.* |
SENDGRID_API_KEY |
AKIA* |
AWS_ACCESS_KEY_ID |
Detection rules
- AWS keys —
AKIAaccess key IDs - API tokens — OpenAI, Anthropic, GitHub, GitLab, Slack, SendGrid, Square
- Database URLs — postgres, mysql, mongodb, redis, amqp, mssql with credentials
- Private keys — RSA, EC, DSA, OPENSSH, PGP
- Environment files —
SECRET_KEY=value,DATABASE_URL=value, etc. - GCP service accounts — JSON with
type: service_accountandprivate_key - Tailscale keys —
tskey-auth-*,tskey-api-* - High-entropy secrets — password/token/secret fields with entropy > 3.5 bits
Logs
aigate logs # last 20 entries
aigate logs -n 50 # last 50 entries
aigate logs -f # live tail
Log file: ~/.aigate/scan.log
Uninstall
Remove hooks
aigate uninstall-hook
Remove proxy certificates
macOS:
sudo security delete-certificate -c mitmproxy /Library/Keychains/System.keychain
Linux (Debian/Ubuntu):
sudo rm /usr/local/share/ca-certificates/mitmproxy-aigate.crt
sudo update-ca-certificates --fresh
Linux (RHEL/Fedora):
sudo rm /etc/pki/ca-trust/source/anchors/mitmproxy-aigate.pem
sudo update-ca-trust
Then remove the generated certs and env vars:
rm -rf ~/.mitmproxy
Remove the cert env vars that aigate setup added to your shell profile (~/.bashrc or ~/.zshrc) — delete the lines after # aigate: trust mitmproxy CA.
Remove aigate entirely
pip uninstall aigate
rm -rf ~/.aigate # logs
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aigate-0.3.0.tar.gz.
File metadata
- Download URL: aigate-0.3.0.tar.gz
- Upload date:
- Size: 39.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
857072c1f3244733c22739b9c48dfa872dc97e27d6c45b91feb98b4a387dfa81
|
|
| MD5 |
b5ae7238a8e776d3820a6342e6c10e94
|
|
| BLAKE2b-256 |
f9606ea3c9d4bb848ece62a500f2d72171eaac73d85640fc0aff6784222d5515
|
File details
Details for the file aigate-0.3.0-py3-none-any.whl.
File metadata
- Download URL: aigate-0.3.0-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a4ca6a35ea90d10eb037cca2d88146342650f751603f7dfa6e03e34719d15dc
|
|
| MD5 |
0bce33cafe8eb110efeea8da4461d93f
|
|
| BLAKE2b-256 |
fcb02880b8d59f337184045926248b6c6a144fb479c9d3f0856e22559c94f45a
|