AI Coding Tools & Storage
How to Clean Claude Code & AI Coding Agent Session History on Mac
Agentic coding assistants like Claude Code CLI, Cursor Agent, Windsurf Cascade, and GitHub Copilot CLI silently hoard 10–50 GB in raw JSONL transcripts, tool diffs, and SQLite WAL logs. Here is where they hide, how to audit them for exposed credentials, and how to safely compress or purge stale sessions.
Why AI coding assistants balloon disk usage so fast
Unlike standard chat interfaces that only record markdown text, agentic AI coding tools (such as Claude Code CLI, Cursor Agent, and Windsurf Cascade) operate in high-frequency tool-calling loops.
Every time the model reads a file, runs a bash command, inspects a test failure, or generates a diff patch, the entire payload is appended to raw .jsonl transcript logs and SQLite state databases.
- Full file snapshots: Reading a 2,000-line source file creates an immediate 100 KB JSON record. If the agent reads 50 files in a session, that session alone exceeds 5–10 MB.
- Terminal execution buffers: Build outputs, test traces, and package install logs are stored in raw text without compression.
- Cumulative sprawl: After 30 days of active programming, developers typically find between 12 GB and 45 GB of forgotten transcripts scattered across hidden user directories.
Where AI coding assistants store transcripts on macOS
Here is the exact filesystem breakdown for where the major developer AI agents store their session logs, transcripts, and SQLite databases:
| Agent / Assistant | macOS File Location | What Gets Stored |
|---|---|---|
| Claude Code CLI | ~/.claude/projects/*/transcripts/ ~/.claude/history/ | Turn-by-turn JSONL conversation logs, tool calls, and prompt history |
| Cursor Agent | ~/Library/Application Support/Cursor/User/workspaceStorage/ ~/Library/Application Support/Cursor/User/globalStorage/ | workspaceState.vscdb, chat checkpoint sqlite tables, and embeddings |
| Windsurf (Cascade) | ~/.codeium/windsurf/ ~/Library/Application Support/Windsurf/User/workspaceStorage/ | Cascade conversation trajectories, checkpoints, and language server logs |
| Codex CLI / Aider | ~/.codex/sessions/ ~/.aider.chat.history.md | Session snapshots, markdown chat logs, and git commit history caches |
| GitHub Copilot CLI | ~/.config/github-copilot/ ~/.local/share/github-copilot/ | CLI interaction telemetry logs and session authentication tokens |
The hidden risk: Exposed API keys & environment secrets
Storage bloat is only half the issue. AI transcripts frequently contain unredacted secrets.
When an AI agent runs a terminal command (e.g. env, cat .env, or git status) or prints stack traces containing authorization headers, those credentials are saved in plain text into your local transcript files.
Step 1 — Measure your AI session footprint in Terminal
To inspect how much disk space AI coding agents are consuming right now, run:
du -sh ~/.claude ~/.codeium ~/Library/Application\ Support/Cursor/User/workspaceStorage 2>/dev/nullIf you have been coding actively with Claude Code CLI, check the project transcript directory specifically:
du -sh ~/.claude/projects/*/transcripts 2>/dev/null | sort -hr | head -n 10On machines with several active projects, individual transcript directories frequently exceed 1–4 GB each.
Step 2 — Compress older sessions with tarball archiving
Because session transcripts are plain text JSON, they have an exceptional compression ratio (~80–88%). Rather than deleting recent transcripts you might still reference, you can compress sessions older than 30 days:
mkdir -p ~/AI-Archives find ~/.claude/projects -name "transcripts" -type d -exec tar -czf ~/AI-Archives/claude-transcripts-backup-$(date +%F).tar.gz +A 10 GB transcript folder will compress into less than 1.5 GB.
Step 3 — Purge inactive session transcripts (>30 days old)
To delete Claude Code session transcripts that haven't been touched in over 30 days without breaking current projects:
find ~/.claude/projects -name "*.jsonl" -mtime +30 -deleteTo clean Cursor workspace SQLite journal files and cached state databases from abandoned folders:
find ~/Library/Application\ Support/Cursor/User/workspaceStorage -name "*.vscdb-wal" -mtime +14 -deleteNote: Claude Code will automatically recreate clean project state metadata when you run commands inside that repository again.
The 1-Click Solution: SpaceWise AI Session History Vault
If you prefer not to manage terminal scripts or risk deleting active project context, SpaceWise includes a native, privacy-first AI Session History module:
- Multi-Agent Autodiscovery: Instantly discovers sessions from Claude Code, Cursor Agent, Windsurf Cascade, Codex, and Copilot.
- Offline Heuristic Secret Audit: Scans `.jsonl` lines for leaked Anthropic, OpenAI, AWS, and GitHub tokens before any action is taken.
- POSIX Ustar Tarball Compression: Compresses stale transcripts with integrity hashing, slashing disk consumption by ~85%.
- 30-Day Quarantine & Instant Undo: Archived sessions are stored in an isolated local quarantine vault with 1-click restore or clean eviction to the native macOS Trash.
Frequently Asked Questions
Will deleting session history break my Claude Code project?
No. When you invoke Claude Code in a directory, it queries git and inspects current files to assemble context. Removing past transcripts only resets the session history log; your repository files and git commits remain 100% untouched.
How can I prevent AI assistants from ballooning disk space?
Add .claude/ and editor cache directories to your global ~/.gitignore, and run periodic archives of session histories every 30 days.
Can SpaceWise restore archived sessions if I need to reference an old prompt?
Yes. SpaceWise maintains an integrity-hashed local archive index. With a single click in the SpaceWise AI Sessions view, you can unarchive any session back to its original path.
Run this cleanup in SpaceWise
Same targets, Recovery Bin rollback, no Terminal required. Free tier included.
Download for Mac