scrubscript 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Giulio Bottari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.4
2
+ Name: scrubscript
3
+ Version: 0.2.0
4
+ 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
5
+ Author: Giulio Bottari
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/gbottari/scrubscript
8
+ Project-URL: Issues, https://github.com/gbottari/scrubscript/issues
9
+ Keywords: claude-code,secrets,redaction,transcripts,gitleaks
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Security
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: license-file
21
+
22
+ <h1 align="center">scrubscript</h1>
23
+
24
+ <p align="center">
25
+ Keep secrets out of your Claude Code transcripts.
26
+ </p>
27
+
28
+ <p align="center">
29
+ <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>
30
+ <a href="https://pypi.org/project/scrubscript/"><img src="https://img.shields.io/pypi/v/scrubscript" alt="PyPI version"/></a>
31
+ <img src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS-blue" alt="Platforms: Linux, macOS"/>
32
+ </p>
33
+
34
+ ![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)
35
+
36
+ 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.
37
+
38
+ 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]`:
39
+
40
+ ```diff
41
+ - {"type":"user","message":{"content":"export GITHUB_TOKEN=ghp_8fK2mQx9Lr4Tโ€ฆ"}}
42
+ + {"type":"user","message":{"content":"export GITHUB_TOKEN=[redacted]"}}
43
+ ```
44
+
45
+ - **Nothing to remember.** A hook schedules the scrub. No cron job, no command to run before you share a session.
46
+ - **A killed session is covered too.** A crash runs no hook, so the next session to start scrubs what that one left.
47
+ - **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.
48
+ - **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`.
49
+ - **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).
50
+ - **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.
51
+
52
+ ## ๐Ÿ” See what your transcripts hold
53
+
54
+ 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:
55
+
56
+ ```
57
+ uvx scrubscript --all
58
+ ```
59
+
60
+ It lists each file that holds a secret, never the secret itself, and ends with the total, as in the recording above.
61
+
62
+ ## ๐Ÿš€ Install
63
+
64
+ 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.
65
+
66
+ 1. Install the plugin, in a terminal:
67
+
68
+ ```
69
+ claude plugin install scrubscript --marketplace gbottari/scrubscript
70
+ ```
71
+
72
+ 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.
73
+
74
+ 3. Check that it works: end a session, then read `~/.local/state/scrubscript/hooks.log` (or under `$XDG_STATE_HOME`, when you set it):
75
+
76
+ ```
77
+ 2026-11-14T18:55:15-0300 SessionEnd reason=prompt_input_exit session=c25e2e65-โ€ฆ: scrub scheduled in 5 s
78
+ redacted 2 secret(s) in /home/you/.claude/projects/-home-you-app/c25e2e65-โ€ฆ.jsonl: 1 github-pat, 1 aws-access-token
79
+ ```
80
+
81
+ ### Past sessions
82
+
83
+ 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:
84
+
85
+ ```
86
+ /scrubscript:scrub all
87
+ ```
88
+
89
+ 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.
90
+
91
+ To run scrubscript without the plugin, see [INSTALL.md](https://github.com/gbottari/scrubscript/blob/main/INSTALL.md).
92
+
93
+ ## โš–๏ธ Before you install
94
+
95
+ - **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.
96
+ - **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.
97
+ - **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).
98
+ - **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).
99
+
100
+ 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).
101
+
102
+ ## ๐Ÿงฉ Where it fits
103
+
104
+ There are three other ways to keep secrets out of agent transcripts, and each one leaves a gap:
105
+
106
+ - **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.
107
+ - **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.
108
+ - **Guards that block the read** stop `cat .env` and `printenv`. They cannot stop a command that prints a token nobody expected.
109
+
110
+ | Job | scrubscript | Sweep tools | Live output redaction | Read guards |
111
+ | --- | :-: | :-: | :-: | :-: |
112
+ | Remove a secret that is already in a transcript | โœ… | โœ… | โŒ | โŒ |
113
+ | Clean the prompt history, debug logs and edited-file copies too | โœ… | some | โŒ | โŒ |
114
+ | Run by itself when a session ends | โœ… | โŒ | โœ… | โœ… |
115
+ | Cover a secret you pasted into the prompt | โœ… | โœ… | โŒ | โŒ |
116
+ | Cover a secret a command printed unexpectedly | โœ… | โœ… | โœ… | โŒ |
117
+ | Keep the secret from reaching the transcript at all | opt-in | โŒ | โœ… | โœ… |
118
+
119
+ 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.
120
+
121
+ 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.
122
+
123
+ ## ๐Ÿงน Use
124
+
125
+ ```bash
126
+ scrubscript <session-id> # dry run: what it would redact in one session
127
+ scrubscript --apply <session-id> # rewrite that session's transcript, tool results, subagents and prompts
128
+ scrubscript --apply --ended <id> # the same for a session that ended in the last hour
129
+ scrubscript --apply path/to/file # or any file or folder
130
+ scrubscript --all --apply # every session and the whole prompt history; later runs skip sessions untouched since
131
+ scrubscript --status # when the last full scrub ran, how many sessions changed since
132
+ scrubscript --doctor # check gitleaks, your rules, the folders and the hooks
133
+ scrubscript --setup # set up backups, and see the recovery code once
134
+ scrubscript --restore path/to/file # put back what scrubscript redacted there; asks for the recovery code
135
+ ```
136
+
137
+ 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.
138
+
139
+ ## ๐Ÿ“š More
140
+
141
+ - [Backups](https://github.com/gbottari/scrubscript/blob/main/docs/backups.md): the recovery code, `--restore`, and keeping a value that was not a secret.
142
+ - [Live redaction](https://github.com/gbottari/scrubscript/blob/main/docs/live-redaction.md): what it covers, and why it is off by default.
143
+ - [Settings](https://github.com/gbottari/scrubscript/blob/main/docs/settings.md): environment variables, and rules of your own for gitleaks.
144
+ - [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).
145
+ - [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).
146
+
147
+ ## ๐Ÿ“Œ Status
148
+
149
+ Version 0.2.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.
@@ -0,0 +1,128 @@
1
+ <h1 align="center">scrubscript</h1>
2
+
3
+ <p align="center">
4
+ Keep secrets out of your Claude Code transcripts.
5
+ </p>
6
+
7
+ <p align="center">
8
+ <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>
9
+ <a href="https://pypi.org/project/scrubscript/"><img src="https://img.shields.io/pypi/v/scrubscript" alt="PyPI version"/></a>
10
+ <img src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS-blue" alt="Platforms: Linux, macOS"/>
11
+ </p>
12
+
13
+ ![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)
14
+
15
+ 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.
16
+
17
+ 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]`:
18
+
19
+ ```diff
20
+ - {"type":"user","message":{"content":"export GITHUB_TOKEN=ghp_8fK2mQx9Lr4Tโ€ฆ"}}
21
+ + {"type":"user","message":{"content":"export GITHUB_TOKEN=[redacted]"}}
22
+ ```
23
+
24
+ - **Nothing to remember.** A hook schedules the scrub. No cron job, no command to run before you share a session.
25
+ - **A killed session is covered too.** A crash runs no hook, so the next session to start scrubs what that one left.
26
+ - **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.
27
+ - **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`.
28
+ - **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).
29
+ - **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.
30
+
31
+ ## ๐Ÿ” See what your transcripts hold
32
+
33
+ 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:
34
+
35
+ ```
36
+ uvx scrubscript --all
37
+ ```
38
+
39
+ It lists each file that holds a secret, never the secret itself, and ends with the total, as in the recording above.
40
+
41
+ ## ๐Ÿš€ Install
42
+
43
+ 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.
44
+
45
+ 1. Install the plugin, in a terminal:
46
+
47
+ ```
48
+ claude plugin install scrubscript --marketplace gbottari/scrubscript
49
+ ```
50
+
51
+ 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.
52
+
53
+ 3. Check that it works: end a session, then read `~/.local/state/scrubscript/hooks.log` (or under `$XDG_STATE_HOME`, when you set it):
54
+
55
+ ```
56
+ 2026-11-14T18:55:15-0300 SessionEnd reason=prompt_input_exit session=c25e2e65-โ€ฆ: scrub scheduled in 5 s
57
+ redacted 2 secret(s) in /home/you/.claude/projects/-home-you-app/c25e2e65-โ€ฆ.jsonl: 1 github-pat, 1 aws-access-token
58
+ ```
59
+
60
+ ### Past sessions
61
+
62
+ 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:
63
+
64
+ ```
65
+ /scrubscript:scrub all
66
+ ```
67
+
68
+ 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.
69
+
70
+ To run scrubscript without the plugin, see [INSTALL.md](https://github.com/gbottari/scrubscript/blob/main/INSTALL.md).
71
+
72
+ ## โš–๏ธ Before you install
73
+
74
+ - **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.
75
+ - **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.
76
+ - **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).
77
+ - **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).
78
+
79
+ 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).
80
+
81
+ ## ๐Ÿงฉ Where it fits
82
+
83
+ There are three other ways to keep secrets out of agent transcripts, and each one leaves a gap:
84
+
85
+ - **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.
86
+ - **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.
87
+ - **Guards that block the read** stop `cat .env` and `printenv`. They cannot stop a command that prints a token nobody expected.
88
+
89
+ | Job | scrubscript | Sweep tools | Live output redaction | Read guards |
90
+ | --- | :-: | :-: | :-: | :-: |
91
+ | Remove a secret that is already in a transcript | โœ… | โœ… | โŒ | โŒ |
92
+ | Clean the prompt history, debug logs and edited-file copies too | โœ… | some | โŒ | โŒ |
93
+ | Run by itself when a session ends | โœ… | โŒ | โœ… | โœ… |
94
+ | Cover a secret you pasted into the prompt | โœ… | โœ… | โŒ | โŒ |
95
+ | Cover a secret a command printed unexpectedly | โœ… | โœ… | โœ… | โŒ |
96
+ | Keep the secret from reaching the transcript at all | opt-in | โŒ | โœ… | โœ… |
97
+
98
+ 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.
99
+
100
+ 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.
101
+
102
+ ## ๐Ÿงน Use
103
+
104
+ ```bash
105
+ scrubscript <session-id> # dry run: what it would redact in one session
106
+ scrubscript --apply <session-id> # rewrite that session's transcript, tool results, subagents and prompts
107
+ scrubscript --apply --ended <id> # the same for a session that ended in the last hour
108
+ scrubscript --apply path/to/file # or any file or folder
109
+ scrubscript --all --apply # every session and the whole prompt history; later runs skip sessions untouched since
110
+ scrubscript --status # when the last full scrub ran, how many sessions changed since
111
+ scrubscript --doctor # check gitleaks, your rules, the folders and the hooks
112
+ scrubscript --setup # set up backups, and see the recovery code once
113
+ scrubscript --restore path/to/file # put back what scrubscript redacted there; asks for the recovery code
114
+ ```
115
+
116
+ 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.
117
+
118
+ ## ๐Ÿ“š More
119
+
120
+ - [Backups](https://github.com/gbottari/scrubscript/blob/main/docs/backups.md): the recovery code, `--restore`, and keeping a value that was not a secret.
121
+ - [Live redaction](https://github.com/gbottari/scrubscript/blob/main/docs/live-redaction.md): what it covers, and why it is off by default.
122
+ - [Settings](https://github.com/gbottari/scrubscript/blob/main/docs/settings.md): environment variables, and rules of your own for gitleaks.
123
+ - [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).
124
+ - [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).
125
+
126
+ ## ๐Ÿ“Œ Status
127
+
128
+ Version 0.2.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.
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scrubscript"
7
+ dynamic = ["version"]
8
+ description = "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"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Giulio Bottari" }]
13
+ keywords = ["claude-code", "secrets", "redaction", "transcripts", "gitleaks"]
14
+ classifiers = [
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: MacOS",
19
+ "Operating System :: POSIX :: Linux",
20
+ "Programming Language :: Python :: 3",
21
+ "Topic :: Security",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/gbottari/scrubscript"
26
+ Issues = "https://github.com/gbottari/scrubscript/issues"
27
+
28
+ [project.scripts]
29
+ scrubscript = "scrubscript:main"
30
+
31
+ [tool.setuptools]
32
+ py-modules = ["scrubscript"]
33
+
34
+ [tool.setuptools.dynamic]
35
+ version = { attr = "scrubscript.__version__" }
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.4
2
+ Name: scrubscript
3
+ Version: 0.2.0
4
+ 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
5
+ Author: Giulio Bottari
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/gbottari/scrubscript
8
+ Project-URL: Issues, https://github.com/gbottari/scrubscript/issues
9
+ Keywords: claude-code,secrets,redaction,transcripts,gitleaks
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Security
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: license-file
21
+
22
+ <h1 align="center">scrubscript</h1>
23
+
24
+ <p align="center">
25
+ Keep secrets out of your Claude Code transcripts.
26
+ </p>
27
+
28
+ <p align="center">
29
+ <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>
30
+ <a href="https://pypi.org/project/scrubscript/"><img src="https://img.shields.io/pypi/v/scrubscript" alt="PyPI version"/></a>
31
+ <img src="https://img.shields.io/badge/platform-Linux%20%7C%20macOS-blue" alt="Platforms: Linux, macOS"/>
32
+ </p>
33
+
34
+ ![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)
35
+
36
+ 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.
37
+
38
+ 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]`:
39
+
40
+ ```diff
41
+ - {"type":"user","message":{"content":"export GITHUB_TOKEN=ghp_8fK2mQx9Lr4Tโ€ฆ"}}
42
+ + {"type":"user","message":{"content":"export GITHUB_TOKEN=[redacted]"}}
43
+ ```
44
+
45
+ - **Nothing to remember.** A hook schedules the scrub. No cron job, no command to run before you share a session.
46
+ - **A killed session is covered too.** A crash runs no hook, so the next session to start scrubs what that one left.
47
+ - **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.
48
+ - **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`.
49
+ - **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).
50
+ - **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.
51
+
52
+ ## ๐Ÿ” See what your transcripts hold
53
+
54
+ 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:
55
+
56
+ ```
57
+ uvx scrubscript --all
58
+ ```
59
+
60
+ It lists each file that holds a secret, never the secret itself, and ends with the total, as in the recording above.
61
+
62
+ ## ๐Ÿš€ Install
63
+
64
+ 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.
65
+
66
+ 1. Install the plugin, in a terminal:
67
+
68
+ ```
69
+ claude plugin install scrubscript --marketplace gbottari/scrubscript
70
+ ```
71
+
72
+ 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.
73
+
74
+ 3. Check that it works: end a session, then read `~/.local/state/scrubscript/hooks.log` (or under `$XDG_STATE_HOME`, when you set it):
75
+
76
+ ```
77
+ 2026-11-14T18:55:15-0300 SessionEnd reason=prompt_input_exit session=c25e2e65-โ€ฆ: scrub scheduled in 5 s
78
+ redacted 2 secret(s) in /home/you/.claude/projects/-home-you-app/c25e2e65-โ€ฆ.jsonl: 1 github-pat, 1 aws-access-token
79
+ ```
80
+
81
+ ### Past sessions
82
+
83
+ 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:
84
+
85
+ ```
86
+ /scrubscript:scrub all
87
+ ```
88
+
89
+ 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.
90
+
91
+ To run scrubscript without the plugin, see [INSTALL.md](https://github.com/gbottari/scrubscript/blob/main/INSTALL.md).
92
+
93
+ ## โš–๏ธ Before you install
94
+
95
+ - **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.
96
+ - **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.
97
+ - **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).
98
+ - **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).
99
+
100
+ 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).
101
+
102
+ ## ๐Ÿงฉ Where it fits
103
+
104
+ There are three other ways to keep secrets out of agent transcripts, and each one leaves a gap:
105
+
106
+ - **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.
107
+ - **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.
108
+ - **Guards that block the read** stop `cat .env` and `printenv`. They cannot stop a command that prints a token nobody expected.
109
+
110
+ | Job | scrubscript | Sweep tools | Live output redaction | Read guards |
111
+ | --- | :-: | :-: | :-: | :-: |
112
+ | Remove a secret that is already in a transcript | โœ… | โœ… | โŒ | โŒ |
113
+ | Clean the prompt history, debug logs and edited-file copies too | โœ… | some | โŒ | โŒ |
114
+ | Run by itself when a session ends | โœ… | โŒ | โœ… | โœ… |
115
+ | Cover a secret you pasted into the prompt | โœ… | โœ… | โŒ | โŒ |
116
+ | Cover a secret a command printed unexpectedly | โœ… | โœ… | โœ… | โŒ |
117
+ | Keep the secret from reaching the transcript at all | opt-in | โŒ | โœ… | โœ… |
118
+
119
+ 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.
120
+
121
+ 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.
122
+
123
+ ## ๐Ÿงน Use
124
+
125
+ ```bash
126
+ scrubscript <session-id> # dry run: what it would redact in one session
127
+ scrubscript --apply <session-id> # rewrite that session's transcript, tool results, subagents and prompts
128
+ scrubscript --apply --ended <id> # the same for a session that ended in the last hour
129
+ scrubscript --apply path/to/file # or any file or folder
130
+ scrubscript --all --apply # every session and the whole prompt history; later runs skip sessions untouched since
131
+ scrubscript --status # when the last full scrub ran, how many sessions changed since
132
+ scrubscript --doctor # check gitleaks, your rules, the folders and the hooks
133
+ scrubscript --setup # set up backups, and see the recovery code once
134
+ scrubscript --restore path/to/file # put back what scrubscript redacted there; asks for the recovery code
135
+ ```
136
+
137
+ 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.
138
+
139
+ ## ๐Ÿ“š More
140
+
141
+ - [Backups](https://github.com/gbottari/scrubscript/blob/main/docs/backups.md): the recovery code, `--restore`, and keeping a value that was not a secret.
142
+ - [Live redaction](https://github.com/gbottari/scrubscript/blob/main/docs/live-redaction.md): what it covers, and why it is off by default.
143
+ - [Settings](https://github.com/gbottari/scrubscript/blob/main/docs/settings.md): environment variables, and rules of your own for gitleaks.
144
+ - [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).
145
+ - [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).
146
+
147
+ ## ๐Ÿ“Œ Status
148
+
149
+ Version 0.2.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.
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ scrubscript.py
5
+ scrubscript.egg-info/PKG-INFO
6
+ scrubscript.egg-info/SOURCES.txt
7
+ scrubscript.egg-info/dependency_links.txt
8
+ scrubscript.egg-info/entry_points.txt
9
+ scrubscript.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ scrubscript = scrubscript:main
@@ -0,0 +1 @@
1
+ scrubscript