loosekeys
Find the API keys sitting in plain text on your laptop.
Shell history, forgotten .env files, AI tool and MCP configs, CLI credential stores. One command, nothing leaves your machine.
uvx loosekeys # or: pipx run loosekeys
Demo run against a sandboxed home directory filled with fake keys.
Repo scanners like gitleaks and trufflehog guard what you commit. But most leaked keys never
get near a commit. They're the export OPENAI_API_KEY=sk-... you typed into your terminal
eight months ago and your shell has saved ever since; the .env in a side project you forgot
existed; the GitHub token you pasted into an MCP server config. loosekeys looks where those
end up.
What it checks
| Where | Why it matters |
|---|---|
| Shell & REPL history (zsh, bash, fish, PowerShell, Python, Node, psql, MySQL, ...) | Every key you ever typed or pasted, saved in plain text, forever |
Shell config (.zshrc, .bashrc, .profile, fish, PowerShell profile) |
Exported keys are readable by every program you run, including every npm postinstall script |
| AI tools & MCP servers (Claude Code & Desktop, Cursor, Windsurf, VS Code, Continue, aider, Gemini CLI, Codex, Zed, llm) | Keys pasted into JSON config files |
Project files (.env*, secrets.toml, *.tfvars, service-account JSON, docker-compose, ...) across your home folder |
Flags files committed to git and projects you haven't touched in 6+ months |
CLI credential stores (~/.aws, .npmrc, .pypirc, .netrc, Docker, kubectl, gcloud, gh, Cargo, ...) |
Where tools expect logins to live, but still plain text |
| SSH keys | Private keys with no passphrase |
It recognizes 30+ token formats precisely: OpenAI, Anthropic, GitHub, GitLab, AWS, Google, Stripe,
Slack, Hugging Face, npm, PyPI, Groq, xAI, OpenRouter, Supabase, DigitalOcean, Twilio, SendGrid,
Telegram, database URLs with passwords, private keys, and more. It also catches SOMETHING_API_KEY=...
style assignments while ignoring placeholders like your_key_here, ${VAR} and changeme.
Clean up
loosekeys --redact-history
This replaces every secret in your history files with [REDACTED]:
- every other byte stays untouched, including zsh's history encoding
- it keeps a backup first (
.zsh_history.loosekeys.bak, owner-only permissions) - it writes atomically
Close other terminal sessions first: open shells hold their history in memory and can write it back.
Redacting doesn't make a leaked key safe. The report links to each provider's page for rotating the keys that ended up in history, shell config or git, and tells you what to do about the rest.
Privacy
- Nothing leaves your machine. loosekeys makes no network requests, ever.
- Secrets are never printed. Values show as
sk-proj••••••Gi, in the terminal and in--jsonalike. The test suite asserts no full secret appears in any output. - It's read-only unless you pass
--redact-history.
Options
loosekeys ~/code ~/work # search these folders for project files instead of your whole home
loosekeys --no-projects # only check the well-known locations (fast)
loosekeys --json # machine-readable, still masked; exit code 1 if anything is found
Install
pipx install loosekeys # or: uv tool install loosekeys / pip install loosekeys
Python 3.9+ on macOS, Linux and Windows. Zero config. The only dependency is rich.
Contributing
New token formats and new tool config locations are the most useful contributions. Add the
pattern in detectors.py, add a fake example in tests/fakehome.py (built at runtime, never
committed as a literal), and run pytest.
License
MIT
Metadata
Release files for loosekeys 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| loosekeys-0.1.0.tar.gz | 19.8 kB | With provenance | Details for loosekeys-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| loosekeys-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for loosekeys-0.1.0-py3-none-any.whl |
Total release size: 39.4 kB
Release files / loosekeys-0.1.0.tar.gz
| Download URL | loosekeys-0.1.0.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1851b26b3b161433add12fd1460d72e3d4058c161fd0e4e34f6d0549c0013086
|
|
BLAKE2b-256 checksum How to use checksums |
941911dd4fef7734933f8309fe68a273926ea1b0f1d57de24b3022f32071b546
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / loosekeys-0.1.0-py3-none-any.whl
| Download URL | loosekeys-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc2d0992089ff4c9892138a178aa67703e7266cca2b964fa143c73505d020a75
|
|
BLAKE2b-256 checksum How to use checksums |
0aa6505a856d2a61a8faa75b0bf513a1e3bf73cb69b8fc5a689fc7201f733df0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for loosekeys 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for loosekeys-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.