Where Claude Code, Codex and Cursor keep your sessions, what ends up in them, and how to clean them up
Every prompt you type into an AI coding agent gets written to disk. So does every file it reads, every command it runs and the output it gets back. That's what makes "resume session" work.
It also means months of your work, and anything sensitive that passed through it, sit in plain-text files in your home folder. I found 26 Codex transcripts on my Mac that I'd forgotten existed.
Here's where they are, what's in them, and how to keep them under control.
Where the transcripts live
Claude Code keeps one folder per project in ~/.claude/projects/, with a .jsonl file for each session.
Codex CLI keeps sessions in ~/.codex/sessions/, sorted by date, plus your prompt history in ~/.codex/history.jsonl.
Cursor stores chat history in SQLite files (state.vscdb) under `
~/Library/Application Support/Cursor/User/workspaceStorage/ and globalStorage/.
`
Aider writes .aider.chat.history.md and .aider.input.history into the root of each repo you use it in.
See how much space they take:
du -sh ~/.claude/projects ~/.codex/sessions "$HOME/Library/Application Support/Cursor/User/workspaceStorage" 2>/dev/null What's inside them
A transcript isn't only your prompts. It usually includes:
anything you pasted, including API keys you shared "just for a second"
the contents of files the agent read; if it opened .env, the values are in the transcript
output of commands it ran, such as env, cloud CLI output or database rows
the diffs of every edit
It's all readable text. Any process running as your user can read it, and Time Machine backs it up along with the rest of your home folder.
Check for leaked keys
This lists the files that contain common key formats without printing the keys to your screen:
grep -rlE 'sk-ant-|sk-proj-|ghp_|github_pat_|AKIA[0-9A-Z]{16}|xox[bp]-' ~/.claude ~/.codex "$HOME/Library/Application Support/Cursor/User" 2>/dev/null For a more thorough scan, use gitleaks (version 8.19 or later):
brew install gitleaks gitleaks dir ~/.claude gitleaks dir ~/.codex If anything turns up, rotate the key first. Deleting the transcript doesn't remove it from backups or anywhere the file was synced.
Clean up old sessions
Claude Code has a retention setting. Add this to ~/.claude/settings.json, and Claude Code deletes sessions inactive for longer than that when it starts (the default is 30 days):
{ "cleanupPeriodDays": 14 } Codex CLI: I haven't found a retention setting for Codex sessions, so I prune them by age. List them first, then delete:
find ~/.codex/sessions -type f -name '*.jsonl' -mtime +30 -print find ~/.codex/sessions -type f -name '*.jsonl' -mtime +30 -delete If you want to keep them, archive them before deleting:
tar czf ~/codex-sessions-backup.tar.gz -C ~/.codex sessions
Cursor: quit it first. Deleting a project's folder in workspaceStorage clears that project's chat history and UI state; your settings and extensions aren't affected.
Aider: make sure your chat history was never committed:
git ls-files | grep -i aider If anything shows up, remove it from the repo and add .aider* to .gitignore.
Keep secrets out next time
Don't paste keys into prompts. Tell the agent the name of the environment variable instead.
In Claude Code, block reads of secret files in .claude/settings.json:
`
{
"permissions": {
"deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)"]
}
}
`
In Cursor, add .env to a .cursorignore file in the project.
To keep transcripts out of Time Machine as well, run tmutil addexclusion ~/.claude/projects. You won't be able to restore old sessions from a backup after that.
The habit
Treat ~/.claude and ~/.codex the way you'd treat shell history: useful, but worth checking once a month. Ten minutes of grep is cheaper than a leaked key.
Disclosure: I build SpaceWise, a Mac and Windows app that, among other things, finds these session folders and scans them offline for keys. Everything above works without it.Where Claude Code, Codex and Cursor keep your sessions, what ends up in them, and how to clean them up

