harnessleaks
v0.1.1
Published
Gitleaks-inspired secret scanner for AI agent and harness transcripts
Maintainers
Readme
HarnessLeaks
A small, dependency-free, Gitleaks-inspired secret scanner for AI-agent and harness transcripts.
It is designed for transcript formats such as JSON, JSONL/NDJSON, logs, Markdown, text, traces, YAML, and session dumps. Like ccusage does for token usage, HarnessLeaks auto-locates the local session files of popular harnesses so you can scan them by name.
Usage
npx harnessleaks # show help
npx harnessleaks codex # scan Codex CLI transcripts (auto-located)
npx harnessleaks claude-code cursor # scan several harnesses at once
npx harnessleaks list # list supported harnesses
npx harnessleaks --known # scan every known harness location
npx harnessleaks . # scan the current directory
npx harnessleaks ./transcripts # scan a directory
npx harnessleaks ~/.my-agent/sessions
npx harnessleaks transcript.jsonl --json
cat transcript.jsonl | npx harnessleaks -A bare harness name resolves to that harness's known transcript locations, so harnessleaks codex finds and scans every Codex session on the machine. Only transcript paths are scanned — never the harness's source code, caches, or SQLite state. While scanning, a spinner reports progress on stderr.
Secrets are shown by default so you can triage them. Pass --redact (-r) to mask them — recommended whenever output may be logged or shared, including CI.
Findings are grouped by secret: the same credential repeated across many sessions is shown once with an occurrence count and up to three locations. Use --all-occurrences to list every match individually.
Human output is a boxed report with a summary header and one panel per lead (severity, full secret, fingerprint/entropy, and source locations), colorized on a TTY. Long secrets wrap across lines so nothing is cut off. The scan always exits 0.
Supported harnesses
HarnessLeaks recognizes the on-disk transcript locations of the most widely used AI coding agents and labels every finding with the harness it came from. Detection is path-based, so it keeps working when a harness changes its internal schema.
Claude Code, OpenAI Codex CLI, GitHub Copilot, Cursor, Windsurf, Cline, Roo Code, Kilo Code, Continue, Aider, Gemini CLI, Qwen Code, OpenCode, Goose, Amazon Q Developer, Zed, Void, Sourcegraph Cody, Crush, Factory Droid, Amp, Kiro, and Trae.
Run harnessleaks --list-harnesses for the full list and their default locations.
SQLite-backed harnesses (for example Cursor's state.vscdb) are scanned by
recovering printable strings from the binary, so secrets stored in the database
are still caught.
What it detects
The initial rules cover common AWS, GitHub, GitLab, npm, PyPI, Slack, Stripe, Google, OpenAI-style, Anthropic, Hugging Face, JWT, bearer-token, private-key, connection-string, and generic credential-assignment patterns.
The detection model borrows the useful architecture of Gitleaks: provider-specific regex rules, keyword prefilters, a secret capture group, Shannon entropy thresholds, and allowlisting. The JavaScript rules are implemented independently rather than copied verbatim because Gitleaks uses Go/RE2-style regular expressions while this package uses JavaScript RegExp.
CLI
--json, -j [path] JSON report (stdout, or write to a file/directory)
--csv, -c [path] CSV report (stdout, or write to a file/directory)
--redact, -r Mask secrets in the report (recommended for CI/logs)
--all-files Scan every file
--harness <id> Force a harness label (and scan its locations if no paths)
--known, --all Scan the default locations of every known harness
--list-harnesses List supported harnesses and exit
--max-size MB Per-file size limit (default 50 MB)
--no-progress Disable the scanning spinner
--all-occurrences List every match instead of unique secrets
--verbose Show skipped files and other diagnosticsThe scan always exits 0 whether or not leads are found.
Saving reports
-j and -c write to stdout by default, or to an optional path. The path can be a directory (default filename harnessleaks-report.<ext>) or a file; the extension is corrected to match the format. A path is only consumed as the output target when it starts with ~, ends with /, or ends in .json/.csv — so -j ./transcripts still scans.
harnessleaks codex -j # JSON to stdout
harnessleaks codex -c # CSV to stdout
harnessleaks codex -j ~/Desktop # ~/Desktop/harnessleaks-report.json
harnessleaks codex -c ~/Desktop/scan.txt # ~/Desktop/scan.csv
harnessleaks codex -j report.json # ./report.jsonLocal development
npm test
node bin/harnessleaks.js ./transcriptsPublishing
The package is ready to publish (files whitelist, bin, LICENSE, and a
prepublishOnly test hook are configured). The name harnessleaks was available
on npm at the time of writing.
npm login
npm publish # access: public is set in publishConfigThen verify:
npx harnessleaks --version
npx harnessleaks --helpTo publish a new version later:
npm version patch # or minor / major
npm publish