Guide

How to scan AI coding assistant sessions for leaked secrets

Skarn is an AI session security scanner: it reads the session logs your coding assistants write to disk and reports the credentials that were pasted into them. Those logs are where this class of leak sits. Claude Code, Gemini CLI, Antigravity, Codex CLI, Grok Build (formerly Cursor), GitHub Copilot, Copilot in Code, Kimi Code CLI, Grok Build CLI, Grok Bot, OpenCode, Cline, Cowork, Claude Enterprise, Kiro CLI each record chat history locally, and any API key, database URI, or .env value a developer pastes into a prompt is stored there in plaintext, outside every secret scanner pointed at git.

The scan is one command, skarn check, from a single local binary. It parses the on-disk logs of all 15 assistants, masks every secret it reports, and makes no network call by default. The free tier includes the full local product under a registered license, issued at getskarn.com/free.

Last updated 2026-11-03.

Where AI coding assistants store session history

Every mainstream assistant persists chat history to the local disk. That store is the audit target.

Claude Code
Writes each session as a JSONL transcript under ~/.claude (plus any directory set in CLAUDE_CONFIG_DIR). Full prompts, tool calls, and outputs are retained.
Grok Build (formerly Cursor) and VS Code Copilot Chat
Store chat history in a local SQLite state database (state.vscdb) inside the editor's application-support directory. From version 3.33 on macOS, Cursor writes each new session to its own SQLite database under ~/.grok/agent-host-daemon/sessions/ instead.
Codex CLI and Gemini CLI
Write their own local session logs in the tool's config directory. Same principle: the transcript, including anything pasted in, lives on the machine.
GitHub Copilot CLI
Writes JSONL event logs under ~/.copilot (or COPILOT_HOME), separate from the VS Code Copilot Chat state database above.
Copilot in Code
The coding workspace of the Microsoft Copilot app on Windows writes the same JSONL event logs under each profile in %LOCALAPPDATA%\Microsoft\Copilot\User Data\CopilotCodingHome\, plus a SQLite session index per profile.
Kimi Code CLI
Writes one JSONL transcript per agent under ~/.kimi-code/sessions/ (relocate with KIMI_CODE_HOME), plus a per-directory prompt log that retains prompts from sessions aborted before a transcript was written.
Antigravity
The Antigravity CLI writes a JSONL transcript per conversation under ~/.gemini/antigravity-cli/brain/; the Antigravity IDE keeps a SQLite state database (state.vscdb) in its application-support directory.
OpenCode
Keeps sessions in a SQLite database and, for sessions from before its 1.2 release, a JSON tree, both under ~/.local/share/opencode/ (relocate with XDG_DATA_HOME).
Cline
Writes each session's message history as JSON under ~/.cline/data/ (relocate with CLINE_DATA_DIR), the store its VS Code extension, CLI and JetBrains plugin share. Tasks from before Cline 4.0 can also sit in the extension storage of VS Code, Cursor or Windsurf, under User/globalStorage/saoudrizwan.claude-dev/tasks/ in the editor's application-support directory.
Grok Build CLI
Writes one JSONL transcript per session under ~/.grok/sessions/ (relocate with GROK_HOME), the local coding-agent CLI - not to be confused with Grok Bot below. Version 2.0, read on macOS, writes one SQLite database per session under ~/.grok/agent-host/sessions/ instead.
Grok Bot
xAI's persistent desktop agent app writes a cleartext transcript replica per conversation to its local application-support directory (macOS: ~/Library/Application Support/Grok Bot/), the same surface a pasted credential lands on. A value entered through the app's secure secret request is excluded from that transcript by design, and the shared cloud computer the Bots run on is not on your disk, so neither is in scope. Read how Skarn reads that store, and why the MCP config beside it leaks earlier than the transcript.

How to scan Claude Code history for secrets

1. Point a session scanner at the local store

Traditional scanners take a repo path. An AI session scanner instead reads the assistant session directories directly. Skarn discovers them automatically for all 15 assistants.

2. Run the scan locally

With Skarn: skarn check. It parses every session, runs 255 detection rules across 200-plus credential types, and correlates multi-stage prompt-injection-to-exfiltration attack chains. Nothing is uploaded. What the detection rules cost you in false alarms is measured, not asserted, and so is what the correlation costs.

3. Review redacted findings by risk

Each finding is shown with the secret masked, attributed to the exact session and message, and scored on a 0-100 risk scale. Output is human-readable, JSON, or SARIF 2.1.0 for your SIEM.

4. Rotate and coach, then gate

Skarn surfaces exposure; your team rotates the exposed credential and coaches the developer. In CI, gate on severity or risk score so a leak fails the build.

What a session scan catches that git scanners miss

Uncommitted pasted credentials

A key pasted into a chat to debug an integration, never written to a file or committed. Invisible to gitleaks and trufflehog, obvious to a session scan. This is the most common shadow-AI leak.

Prompt-injection-to-exfiltration chains

Poisoned content that drives the assistant to read a secret and exfiltrate it through a tool call - correlated across MITRE ATLAS tactic-aligned stages, mapped to the OWASP Top 10 for LLM Applications 2025 and CWE.

Did your developers paste API keys into ChatGPT or Claude?

A session scan answers that question directly and with evidence, per developer and per session, instead of leaving it a guess. See also the shadow AI DLP guide.

Skarn surfaces exposure - it does not auto-remediate. Your team owns rotation, coaching, and policy.

Related: what leaks into AI coding sessions, measured, saved command approvals hold secrets, What is an AI session security scanner, how Skarn compares to gitleaks and trufflehog, the standards crosswalk

See what is leaking in your sessions

Book a 30-minute live demo and watch Skarn scan a developer's machine in your own environment. Nothing sent to a cloud.

[email protected]