What is Claude Scrub?
Claude Scrub is a command-line utility that finds and redacts secrets in Claude Code history stored on a computer. It scans session transcripts, prompt history, the paste cache, file history and shell snapshots, replacing detected values with labeled markers. It is for Claude Code users who want to remove credentials and tokens from retained history, whether they prefer to run cleanup themselves or set it to run automatically after sessions.
Claude Scrub Features:
History Coverage: It scans session transcripts, including subagent and tool result files, along with prompt history, the paste cache, file history and shell snapshots.
Secret Detection: It searches for secret-like assignments, authorization headers, signed URL signatures, labeled keys and patterns for more than 200 token formats.
Custom Secrets: A secrets file or supplied environment file can add specific values to redact, while an allow file can exclude individual values or an entire label.
Dry Run: The dry-run option reports detected labels and counts of values and occurrences without changing files, while a normal run asks before writing.
Session End Hook: A SessionEnd hook can run cleanup after a Claude Code session, covering its transcript, subagent and tool result files, and prompt history.
Careful File Writes: It skips recently modified files by default, preserves other bytes and file metadata, and retries if a file changes during rewriting.
Claude Scrub Benefits:
Reduced Exposure: Removing credentials from local history lowers the chance that someone reviewing those records later will see the original values.
Review Before Changes: A report-only run lets users examine detected labels and occurrence counts before deciding whether to make permanent edits.
Less Manual Searching: Once a secret is identified, its other appearances can be redacted too, avoiding the need to locate each repeated instance by hand.
Clear Failure Signals: Unreadable files are named and cause a nonzero exit status, making it easier to tell when a cleanup was incomplete.
Use Cases:
After Claude Sessions: Run cleanup after a session to remove credentials that appeared in its transcript, tool output, subagent files or prompt history.
Automatic Cleanup: Configure a SessionEnd hook to scrub files at the end of each Claude Code session instead of relying on a later manual run.
Known Credentials: Add a password or token to the secrets file when it must always be redacted, including values that automatic detection might miss.
Review Detected Matches: Use a dry run to inspect the secret labels and occurrence counts found in local history before allowing the utility to rewrite files.

