Guides

Guides to AI coding agent security

Walk-throughs for the agent on your own machine: what Claude Code writes to disk, what it can read, how to check what it ran, and how to cut what its tokens allow. Each guide is checked against the vendors' own documentation and lists its sources at the end.

01 / Start here

Start with the checklist.

The other guides go deeper on one item each. This one puts them in order.

AI coding agent security: a checklist for your own machine

What a coding agent can reach, the boundary to put around it, what it writes to disk, how to check what it already ran, and how to scope the tokens it holds. Fourteen steps, in the order worth doing them.

02 / Claude Code

What Claude Code keeps, reads and runs.

Claude Code writes every session to a plaintext transcript under ~/.claude/projects. These seven guides cover what is in those files, how long they stay, and how to block a risky call.

Where Claude Code stores your conversation history

Where the transcripts are, what they hold, why they are deleted after 30 days by default, how to change that, and how to purge a project.

Claude Code cleanupPeriodDays: how long your history is kept

The one setting that decides how long Claude Code keeps every session: 30 days by default, why 0 fails, and what the sweep never deletes.

How to stop Claude Code reading your .env file

A Read deny rule stops cat and Claude's file tools, not grep -r or a Python script. The sandbox closes that gap. If it already read the file, rotate first.

A Claude Code audit log from what is already on disk

Read back the tool calls in the transcripts you already have, then keep a record from now on with a hook or OpenTelemetry.

Claude Code audit log tools compared: ranwhat, suvadu and cc-audit-log

Three free tools that show which commands Claude Code ran. Two read what is already on disk; one records through hooks from the day you add them. What each does well, where each stops, and which to start with.

Claude Code deleted my files. What now?

Rewind does not restore files a Bash command removed. Find what was deleted and when, restore from git or a backup, and block a repeat.

How to block a command in Claude Code with a PreToolUse hook

One tested script that refuses rm -rf and curl | sh by exiting 2, the settings that register it, the JSON deny alternative, and the pitfalls.

03 / Agents

Beyond one agent.

Claude Code is one of many. These guides cover where Cursor, Codex and the others keep their history, what an MCP server can reach, and how text in a repository becomes a command.

Where each AI coding agent keeps your conversation history

Where Claude Code, Codex, Gemini CLI, Copilot CLI, Cursor, Aider, Windsurf, Cline and Continue keep chat history on disk, its format, and how to clear it.

Where Cursor stores your chat and agent history

Every editor chat in one SQLite file, the CLI's sessions in another: where each is on macOS, Linux and Windows, what the tables hold, and how to read a copy without touching Cursor's.

Where Codex CLI keeps your session history

Every Codex thread is a JSONL file in a dated folder, and no retention period is documented for them. What a rollout holds, why shell_snapshots matter, and how to cap it.

Securing MCP servers for coding agents

An MCP server runs with your privileges or holds your OAuth token. See what is configured, what to approve, and how to scope it in Claude Code.

Prompt injection in coding agents

Text in a README, issue or tool result can become a shell command. The documented attack chains, why a prompt cannot fix it, and what limits the damage.

How to check that AI-written code is secure

Tests, scanners and CI gates that check AI-written code without asking the model, and where the agent's own review stops being evidence.

A secure-by-default AI coding agent setup

One settings file and five habits that decide what a coding agent can reach before anything goes wrong: sandbox, deny rules, scoped tokens, reviewed tools and a record.

04 / Tokens

What an agent's tokens allow.

Permission prompts decide which commands run. The token decides what a command can do once it reaches the provider.

Check what the tokens your AI agent holds can do

Check what GitHub, Google, Slack, Stripe and AWS credentials allow with each provider's own tools, see which grants were ever used, then cut them down to least privilege.

An AI agent saw my API key. What now?

An agent read or printed your key. Rotate it at the provider first, check its logs, then mask the transcript and handle git history if needed.

05 / Laptop

What the rest of the laptop gives away.

The agent is one part of a developer's OPSEC. Cloud keys, SSH keys, registry tokens and shell history sit on the same disk.

Developer OPSEC: what your laptop and your AI agents give away

Where credentials sit on a developer laptop, what agent transcripts add, how to find and rotate what is already there, and how to keep the next one out of plaintext. Ten steps at the end.

06 / More guides

More guides.

Wider comparisons and the three blocking layers side by side.

Claude Code deny rules, hooks and the sandbox: what each one blocks

A deny rule and a hook both judge the command text; the sandbox limits what a command can touch. What each layer blocks and how they combine.

Seven coding agent security tools compared on five checks

Seven tools compared on five checks anyone can verify: agents covered, blocking, what stays local, licence and finding secrets in transcripts. Written by the maker of one of them, with the method shown.

07 / Check now

Or check your own machine now.

One read-only pass over your Claude Code history: the risky actions the agent took, and the credentials left in its transcripts. It changes nothing.

$ uvx ranwhat check
Install

check runs two commands together: ranwhat watch for what your agents ran, and ranwhat clean for secrets in their transcripts. ranwhat scan is separate, and scores what their credentials allow.