Metadata-Version: 2.4
Name: scrubscript
Version: 0.3.0
Summary: Keep secrets out of your Claude Code transcripts: gitleaks finds them, and scrubscript redacts them when a session ends or, if you turn it on, as they come in
Author: Giulio Bottari
License: MIT
Project-URL: Homepage, https://github.com/gbottari/scrubscript
Project-URL: Issues, https://github.com/gbottari/scrubscript/issues
Keywords: claude-code,secrets,redaction,transcripts,gitleaks
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

<h1 align="center">scrubscript</h1>

<p align="center">
  Keep secrets out of your Claude Code transcripts.
</p>

<p align="center">
  <a href="https://github.com/gbottari/scrubscript/actions/workflows/ci.yml"><img src="https://github.com/gbottari/scrubscript/actions/workflows/ci.yml/badge.svg" alt="CI"/></a>
  <a href="https://pypi.org/project/scrubscript/"><img src="https://img.shields.io/pypi/v/scrubscript" alt="PyPI version"/></a>
  <img src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS-blue" alt="Platforms: Linux, macOS"/>
</p>

![A terminal: uvx scrubscript --all lists five transcripts holding secrets and ends with "found 6 secrets in 5 sessions: 3 github-pat, 2 aws-access-token, 1 gitlab-pat"; then one session is redacted, and grep shows GITHUB_TOKEN=[redacted] in it.](https://raw.githubusercontent.com/gbottari/scrubscript/main/docs/demo/demo.gif)

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](https://github.com/gitleaks/gitleaks) and replaces each secret with `[redacted]`:

```diff
- {"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.jsonl` and 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](https://github.com/gbottari/scrubscript/blob/main/docs/backups.md).
- **Or redact before it is stored.** With [live redaction](https://github.com/gbottari/scrubscript/blob/main/docs/live-redaction.md) turned on, a secret is replaced as it comes in, before the model reads it.

## 🔍 See what your transcripts hold

With [gitleaks](https://github.com/gitleaks/gitleaks#installing) and [uv](https://docs.astral.sh/uv/getting-started/installation/) 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](https://github.com/gitleaks/gitleaks#installing) 8.19.1 or later, which finds the secrets, and [age](https://github.com/FiloSottile/age), which encrypts the backup every redaction keeps: `brew install gitleaks age`, or your package manager. Without age, scrubscript redacts nothing.

1. Install the plugin, in a terminal:

   ```
   claude plugin install scrubscript --marketplace gbottari/scrubscript
   ```

2. Set up backups, in a terminal of your own and outside Claude Code: `scrubscript --setup` shows 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.

3. 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](https://github.com/gbottari/scrubscript/blob/main/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](https://github.com/gbottari/scrubscript/blob/main/docs/live-redaction.md) 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](https://github.com/gbottari/scrubscript/blob/main/docs/backups.md#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](https://github.com/gbottari/scrubscript/blob/main/docs/limits.md).

The rest, such as what happens when Claude Code changes its file layout, is in [Limits](https://github.com/gbottari/scrubscript/blob/main/docs/limits.md).

## 🧩 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 .env` and `printenv`. 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](https://github.com/gbottari/scrubscript/blob/main/docs/live-redaction.md), which also covers the prompt.

Use something else when you want one tool for many agents. [agentsweep](https://github.com/Ishannaik/agent-sweep) and [agentscrub](https://github.com/ppravdin/agentscrub) cover Codex, Cursor, Gemini CLI and more, and keep a backup of everything they rewrite by default.

## 🧹 Use

```bash
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
```

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](https://github.com/gbottari/scrubscript/blob/main/docs/backups.md): the recovery code, `--restore`, and keeping a value that was not a secret.
- [Live redaction](https://github.com/gbottari/scrubscript/blob/main/docs/live-redaction.md): what it covers, and why it is off by default.
- [Settings](https://github.com/gbottari/scrubscript/blob/main/docs/settings.md): environment variables, and rules of your own for gitleaks.
- [How it works](https://github.com/gbottari/scrubscript/blob/main/docs/how-it-works.md) and [Limits](https://github.com/gbottari/scrubscript/blob/main/docs/limits.md).
- [Troubleshooting](https://github.com/gbottari/scrubscript/blob/main/docs/troubleshooting.md), and [installing without the plugin](https://github.com/gbottari/scrubscript/blob/main/INSTALL.md).
- [Testing](https://github.com/gbottari/scrubscript/blob/main/docs/testing.md): running the tests, and mutation testing with mutmut.

## 📌 Status

Version 0.3.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.
