scrubscript 0.2.0__py3-none-any.whl
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.
- scrubscript-0.2.0.dist-info/METADATA +149 -0
- scrubscript-0.2.0.dist-info/RECORD +7 -0
- scrubscript-0.2.0.dist-info/WHEEL +5 -0
- scrubscript-0.2.0.dist-info/entry_points.txt +2 -0
- scrubscript-0.2.0.dist-info/licenses/LICENSE +21 -0
- scrubscript-0.2.0.dist-info/top_level.txt +1 -0
- scrubscript.py +2477 -0
|
@@ -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,7 @@
|
|
|
1
|
+
scrubscript.py,sha256=U-Vt_qAbOlRTSyZ3604prppPq-iGnoIEBalr4KshNP8,113432
|
|
2
|
+
scrubscript-0.2.0.dist-info/licenses/LICENSE,sha256=6FjlitJ6zvT5w67tD3EVtnvEjlHNNlbNeFE5NkX7esQ,1071
|
|
3
|
+
scrubscript-0.2.0.dist-info/METADATA,sha256=O4ymMEkDxBUcYs0KEGwP-c-6T5NzC2YNRsvADW8TUN0,10722
|
|
4
|
+
scrubscript-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
scrubscript-0.2.0.dist-info/entry_points.txt,sha256=FHig-58Yr_19B_EzC4NbyVoEByZAsUjHuXhgDFa5U7A,49
|
|
6
|
+
scrubscript-0.2.0.dist-info/top_level.txt,sha256=vFTOG9v13bgzE894C_6PoLJqMRocpB11c3YkqHR2qjA,12
|
|
7
|
+
scrubscript-0.2.0.dist-info/RECORD,,
|
|
@@ -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 @@
|
|
|
1
|
+
scrubscript
|