All guides

When a credential leaks into a session

A pasted key lives in the transcript on disk and in every later turn. Rotate first, then stop the next one.

3 min

Why a paste is a leak

Claude Code writes every prompt, command and tool result to ~/.claude/projects as JSONL. A key pasted once stays there until the file is deleted, is resent to the API on every later turn of that session, and is one grep away for anything that reads your home directory.

The same is true for cat .env, printenv and echo $TOKEN: the command output becomes part of the transcript and of the model's context.

What to do, in order

Rotate the credential where it was issued. ReadyClaw's Security page lists the kind and a masked preview with the exact place to do it; mark it rotated when done.

Replace the value with an environment reference in what you resend ($STRIPE_KEY, process.env.STRIPE_KEY). Claude does not need the value to write the code that uses it.

Turn on the guard (readyclaw guard on or the plugin). It blocks prompts, Bash commands and file writes that carry a credential before they are sent, and tells you why.

Habits that cause the next one

Keep secrets out of shell history and transcripts: test -n "$KEY" proves a variable is set without printing it; grep the name in .env.example, not the value in .env.

Never git add a .env file; put .env* in .gitignore and commit .env.example. Anything committed, even briefly, needs rotating.

Treat --dangerously-skip-permissions, sudo, curl | sh and --no-verify as things a human does deliberately in a terminal, not defaults for an agent session.

See how much this one is costing you: npx readyclaw scan