Metadata-Version: 2.4
Name: agenttrail-scrub-lite
Version: 0.1.0
Summary: Claude Code secret scanner: find API keys and tokens leaked in AI agent transcripts.
Author: Alessio Auretto
License-Expression: MIT
Project-URL: Homepage, https://github.com/alessio1999xx-debug/agenttrail-scrub-lite
Project-URL: Repository, https://github.com/alessio1999xx-debug/agenttrail-scrub-lite
Project-URL: Pro version, https://py-forge.com/products/agenttrail-scrub-ai-transcript-secret-cleaner?utm_source=pypi&utm_medium=project_page&utm_campaign=agenttrail-scrub-lite
Keywords: claude-code,ai-agents,llm-security,secret-scanning,secrets-detection,api-keys,credential-leak,devsecops,security-scanner,cli,stdlib
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# agenttrail-scrub-lite: scan Claude Code transcripts for leaked secrets

Claude Code saves every session transcript as local JSONL under `~/.claude`, including any API key, token or `.env` value that passed through the terminal or a pasted file. agenttrail-scrub-lite helps you find those secrets with a read-only scan using only the standard library: it reports where they are and never modifies your files.

Need to scan other AI coding agents, redact secrets in place, or get a per-provider rotation checklist? That is the full [AgentTrail Scrub](https://py-forge.com/products/agenttrail-scrub-ai-transcript-secret-cleaner?utm_source=github&utm_medium=readme&utm_campaign=agenttrail-scrub-lite) (one-time payment, yours to keep, no subscription). A table later in this README lists what lite does and what the paid tool adds. Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=agenttrail-scrub-lite) ($99, one payment).

- One file, Python 3.9+. Nothing to `pip install`.
- Default target: `~/.claude/projects/**/*.jsonl` (override with `--path`).
- Masked previews only; exit code `1` when at least one secret pattern is reported.

## Install

```bash
curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/agenttrail-scrub-lite/main/agenttrail_scrub_lite.py
chmod +x agenttrail_scrub_lite.py
python agenttrail_scrub_lite.py --help
```

## Where Claude Code stores transcripts (and why secrets end up there)

Claude Code keeps project session logs under `~/.claude/projects/`, usually as `.jsonl` files (one JSON object per line). Anything you typed, pasted, or that an agent echoed — including `export` lines, `.env` snippets, and provider tokens — can sit there in plaintext. Sharing a transcript, opening a bug report, or syncing that folder to a backup is how keys leak.

agenttrail-scrub-lite walks that tree (or a path you pass), opens each `.jsonl` as text, and matches **common patterns** for provider credentials. It does not claim to find every possible secret.

Patterns currently checked:

| Provider / kind | Example shape (not a real key) |
|---|---|
| Anthropic API key | `sk-ant-api03-…` |
| Anthropic legacy key | `sk-ant-…` |
| OpenAI API key | `sk-…` / `sk-proj-…` |
| Google Gemini / Cloud | `AIzaSy…` |
| GitHub PAT / OAuth | `ghp_` / `gho_` / … |
| GitHub fine-grained | `github_pat_…` |
| AWS access key id | `AKIA…` / `ASIA…` |
| AWS secret access key | `aws_secret_access_key=…` |
| Stripe secret / restricted | `sk_live_` / `sk_test_` / `rk_…` |
| Slack token | `xoxb-` / `xoxp-` / … |
| Private key header | `-----BEGIN … PRIVATE KEY-----` |
| JWT | `eyJh….….…` |
| Generic `.env` assignment | `API_KEY=` / `TOKEN=` / … |

## Scan Claude Code logs for API keys and tokens

```bash
# default: ~/.claude/projects
python agenttrail_scrub_lite.py

# one project folder or a single .jsonl file
python agenttrail_scrub_lite.py --path ~/.claude/projects/my-encoded-path
python agenttrail_scrub_lite.py --path ./session.jsonl
```

Example output, recorded 25 Nov 2026 (Europe/Rome) on a throwaway sample JSONL. The token is fake and is shown only as a masked preview. Exit code `1`.

```text
================================================================================
                   AGENTTRAIL-SCRUB-LITE SCAN REPORT                           
================================================================================
Target                 : session.jsonl
JSONL Files Scanned    : 1
Findings               : 1
Secrets Reported       : 1
--------------------------------------------------------------------------------
Findings (1 total):

1. Provider  : OpenAI API Key
   Path      : session.jsonl
   Line      : 1
   Preview   : sk-p...aaa
   Details   : OpenAI API Key match (masked preview)
================================================================================
Read-only scan. No files were modified. Rotate any real credentials at the provider.
```

The report lists provider, file path, line number and a masked preview (`abcd...xyz`). Nothing is written back to disk. If matches appear, rotate the real credentials at the provider — this tool only helps you find them.

## Run it before sharing a transcript or a bug report

```bash
python agenttrail_scrub_lite.py --path ./transcript-to-share.jsonl
echo $?   # 0 = no common patterns found; 1 = at least one match
```

Use the exit code in a pre-share checklist or a local hook so you do not paste a log that still holds keys.

## agenttrail-scrub-lite vs AgentTrail Scrub (redact and clean)

agenttrail-scrub-lite checks **Claude Code** JSONL transcripts only, with regex patterns and a text report. It is read-only.

| Capability | Lite (free) | Paid AgentTrail Scrub |
| --- | --- | --- |
| Default scan target | Claude Code `~/.claude/projects` (override with `--path`) | Discovers Claude Code, Cursor, Gemini CLI, Aider, Codex, Continue.dev and Open Interpreter, plus any `--paths` you pass |
| Detection | Regex patterns (Anthropic, OpenAI, Google, GitHub, AWS, Stripe, Slack, JWT, private-key headers, `.env`-style assignments) | Regex plus Shannon entropy checks |
| Redact secrets in the files | No (read-only) | Yes (`--redact`, with a backup first) |
| Allowlist for known-safe values | No | Yes (`--allowlist`) |
| Retention / cleanup of old transcripts | No | Yes (`--apply-retention`, `--retention-days`) |
| Per-provider rotation checklist | No | Yes (`--rotation-guide`) |
| Output | Plain text | Text or JSON (`--json`) |

One-time payment, yours to keep. No subscription. Full tool: [AgentTrail Scrub](https://py-forge.com/products/agenttrail-scrub-ai-transcript-secret-cleaner?utm_source=github&utm_medium=readme&utm_campaign=agenttrail-scrub-lite). Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=agenttrail-scrub-lite) ($99, one payment).

## Need more?

Need the full version? **AgentTrail Scrub** on PyForge: https://py-forge.com/products/agenttrail-scrub-ai-transcript-secret-cleaner?utm_source=github&utm_medium=readme&utm_campaign=agenttrail-scrub-lite

Or get every PyForge tool, current and future, with the All-Access Pass: https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=agenttrail-scrub-lite

## Tests

```bash
python3 test_agenttrail_scrub_lite.py
```

## More free tools from the same author

- [agentconfig-audit-lite](https://github.com/alessio1999xx-debug/agentconfig-audit-lite) — Audit MCP config for secrets: plaintext tokens and unpinned npx/uvx servers in `.mcp.json` and `CLAUDE.md`.
- [cronpulse-lite](https://github.com/alessio1999xx-debug/cronpulse-lite) — Cron job monitoring in one Python file: alerts to Slack/Discord/webhook on failure or hang.
- [depcooldown-lite](https://github.com/alessio1999xx-debug/depcooldown-lite) — Dependency cooldown check: fail CI when a pinned PyPI or npm package is newer than N days.
- [homelab-doctor-lite](https://github.com/alessio1999xx-debug/homelab-doctor-lite) — Read-only homelab health check: stale images, exposed ports, expiring certs, silent cron, disk.
- [imagenudge-lite](https://github.com/alessio1999xx-debug/imagenudge-lite) — Docker image update checker: find running containers with a newer image (digest or tag).
- [pthguard-lite](https://github.com/alessio1999xx-debug/pthguard-lite) — Scan Python site-packages for malicious `.pth` files and startup backdoors.
- [pulseping-lite](https://github.com/alessio1999xx-debug/pulseping-lite) — Check SSL certificate expiry and URL/port uptime from cron.
- [secenv-lite](https://github.com/alessio1999xx-debug/secenv-lite) — Find `.env` files committed to git or missing from `.gitignore`, plus obvious API keys inside.

## License

MIT (this lite version). The full AgentTrail Scrub tool is sold separately under its own license.
