scrubscript
Keep secrets out of your Claude Code transcripts.
Claude Code writes everything a session sees to plain JSONL files under ~/.claude/projects: the .env you asked it to read, the token a command printed, the key you pasted into a prompt. They stay on disk after the session is over, where anything that reads your home folder reads them too: a backup, a sync client, a search index, the next tool you install.
scrubscript is a Claude Code plugin. A few seconds after a session ends it scans that session's transcript, tool results, subagents and prompt history with gitleaks and replaces each secret with [redacted]:
- {"type":"user","message":{"content":"export GITHUB_TOKEN=ghp_8fK2mQx9Lr4T…"}}
+ {"type":"user","message":{"content":"export GITHUB_TOKEN=[redacted]"}}
- Nothing to remember. A hook schedules the scrub. No cron job, no command to run before you share a session.
- A killed session is covered too. A crash runs no hook, so the next session to start scrubs what that one left.
- It finds the awkward ones. A key printed across two JSON fields, a token that ends on an escaped quote, a secret that only shows once a base64 blob is decoded, a private key spread over many lines.
- A pasted secret is cleaned everywhere Claude Code kept it: the transcript, the prompt history in
~/.claude/history.jsonland a large paste in~/.claude/paste-cache. - A redaction can be undone. scrubscript keeps an encrypted copy of what it replaces, which only your recovery code opens. Backups.
- Or redact before it is stored. With live redaction turned on, a secret is replaced as it comes in, before the model reads it.
🔍 See what your transcripts hold
With gitleaks and uv installed, this reads every session on your machine and rewrites nothing:
uvx scrubscript --all
It lists each file that holds a secret, never the secret itself, and ends with the total, as in the recording above.
🚀 Install
You need Linux or macOS, Python 3.9 or later, gitleaks 8.19.1 or later, which finds the secrets, and age 1.3 or later, which encrypts the backup every redaction keeps to a post-quantum key: brew install gitleaks age, or your package manager if it packages those versions. Without age, scrubscript redacts nothing.
-
Install the plugin, in a terminal:
claude plugin install scrubscript --marketplace gbottari/scrubscript -
Set up backups, in a terminal of your own and outside Claude Code:
scrubscript --setupshows the recovery code that undoes every redaction, once. scrubscript redacts nothing until you do, and the next session start tells you the command to run. -
Check that it works: end a session, then read
~/.local/state/scrubscript/hooks.log(or under$XDG_STATE_HOME, when you set it):2026-11-14T18:55:15-0300 SessionEnd reason=prompt_input_exit session=c25e2e65-…: scrub scheduled in 5 s redacted 2 secret(s) in /home/you/.claude/projects/-home-you-app/c25e2e65-….jsonl: 1 github-pat, 1 aws-access-token
Past sessions
The hooks scrub the sessions that end after you install the plugin, and the first sweep looks back one day. Older transcripts still hold whatever they held. To scrub every one of them, type this in any session:
/scrubscript:scrub all
The skill shows what it would redact and applies the redactions only after you say yes. It costs no context until you type it, because Claude Code never loads it on its own. Give it a session id instead of all to scrub one session now, or ask it for anything else scrubscript does, such as adding a rule of your own.
To run scrubscript without the plugin, see INSTALL.md.
⚖️ Before you install
- Rotate any key that leaked. Redacting a transcript limits where the key can be read. It does not make the key safe again, and whatever Claude Code sent to the model has already left your machine.
- The secret is on disk for the whole session, unless live redaction is on. The scrub starts seconds after the session ends.
- Some redactions cannot be undone: every backup whose recovery code is lost, and every file deleted since. What cannot be undone.
- A rewind into a scrubbed session writes
[redacted]into your file, because the copies a rewind restores from are scrubbed too. It can be put back.
The rest, such as what happens when Claude Code changes its file layout, is in Limits.
🧩 Where it fits
There are three other ways to keep secrets out of agent transcripts, and each one leaves a gap:
- A sweep you run by hand or from cron cleans what is already on disk, across many agents, but only when it runs. Until then the secret sits there.
- Redacting tool output as it arrives keeps a secret from being written at all, but only for the tools it wraps. What you paste into a prompt is already in the transcript.
- Guards that block the read stop
cat .envandprintenv. They cannot stop a command that prints a token nobody expected.
| Job | scrubscript | Sweep tools | Live output redaction | Read guards |
|---|---|---|---|---|
| Remove a secret that is already in a transcript | ✅ | ✅ | ❌ | ❌ |
| Clean the prompt history, debug logs and edited-file copies too | ✅ | some | ❌ | ❌ |
| Run by itself when a session ends | ✅ | ❌ | ✅ | ✅ |
| Cover a secret you pasted into the prompt | ✅ | ✅ | ❌ | ❌ |
| Cover a secret a command printed unexpectedly | ✅ | ✅ | ✅ | ❌ |
| Keep the secret from reaching the transcript at all | opt-in | ❌ | ✅ | ✅ |
They combine well: a guard or live redaction in front, scrubscript behind for what gets through. scrubscript has a live redaction of its own, off until you turn it on, which also covers the prompt.
Use something else when you want one tool for many agents. agentsweep and agentscrub cover Codex, Cursor, Gemini CLI and more, and keep a backup of everything they rewrite by default.
🧹 Use
scrubscript <session-id> # dry run: what it would redact in one session
scrubscript --apply <session-id> # rewrite that session's transcript, tool results, subagents and prompts
scrubscript --apply --ended <id> # the same for a session that ended in the last hour
scrubscript --apply path/to/file # or any file or folder
scrubscript --all --apply # every session and the whole prompt history; later runs skip sessions untouched since
scrubscript --status # when the last full scrub ran, how many sessions changed since
scrubscript --doctor # check gitleaks, your rules, the folders and the hooks
scrubscript --setup # set up backups, and see the recovery code once
scrubscript --restore path/to/file # put back what scrubscript redacted there; asks for the recovery code
scrubscript --rekey # after a new --setup, move the older backups onto its key; asks for the old code
Nothing is rewritten without --apply, and a secret's value is never printed. --apply skips a session written in the last 60 minutes, in case it is still in use; --ended says it is over. The first --all --apply over a long history takes a while; after that, --all reads only the sessions written since.
📚 More
- Backups: the recovery code,
--restore, and keeping a value that was not a secret. - Live redaction: what it covers, and why it is off by default.
- Settings: environment variables, and rules of your own for gitleaks.
- How it works and Limits.
- Troubleshooting, and installing without the plugin.
- Testing: running the tests, and mutation testing with mutmut.
📌 Status
Version 0.4.0, maintained by one person. CI runs the tests on Linux and macOS, with Python 3.9 and 3.13, and one real Claude Code session with the plugin loaded. scrubscript makes no network calls. MIT licence.
Metadata
Release files for scrubscript 0.4.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 |
|---|---|---|---|---|
| scrubscript-0.4.0.tar.gz | 121.7 kB | With provenance | Details for scrubscript-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scrubscript-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for scrubscript-0.4.0-py3-none-any.whl |
Total release size: 171.0 kB
Release files / scrubscript-0.4.0.tar.gz
| Download URL | scrubscript-0.4.0.tar.gz |
|---|---|
| Size | 121.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd26cfc51fdcf0fa5bf3b2dcbe3278f6a23bde678cad31cb177cc6285f38cc7f
|
|
BLAKE2b-256 checksum How to use checksums |
d3b4130ebd8a4ebd21e3e38bf556e4dfca1fa9a8b3ec269316e28da74cb72e20
|
| 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 Dec 3, 2026.
Transparency logRelease files / scrubscript-0.4.0-py3-none-any.whl
| Download URL | scrubscript-0.4.0-py3-none-any.whl |
|---|---|
| Size | 49.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70d76938c15becd4d0ad296b06293b2880c0a8e6597888c382f746601c3636d9
|
|
BLAKE2b-256 checksum How to use checksums |
d5ca9bb45b81db438163e100460a923697d06233a1a2eb9760d797b8f5f51f48
|
| 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 Dec 3, 2026.
Transparency logSecurity for scrubscript 0.4.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 scrubscript-0.4.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 Dec 3, 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.