[BUG] Long CLI sessions with subagents write hundreds of GB to disk (write amplification far above persisted transcript size)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 43/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- linux, node.js, typescript
- Domain
- cli, performance
Research direction
The issue does not name source files or tests. Start by identifying which CLI process writes the excess data while a session and its subagents are active, then trace those writes to the files involved. Done means the source and cause of the write amplification are identified and addressed, with measurements showing writes closer to the data persisted.
Written by the indexing model from the issue text.
Description
Summary
On Linux (WSL2), a long-running Claude Code CLI session writes hundreds of GB to disk while the files it keeps grow by only about a hundred MB. Writes run around 2 MB/s whenever the session or its subagents are active, with bursts near 300 MB/s, and about a third of the bytes are cancelled writes, meaning data written and then truncated or deleted before flush. On SSDs this is real wear.
Environment
- Claude Code 2.1.326 (CLI), Linux 6.18 (WSL2), Node runtime as shipped
- One long session (about 22 h) driving up to six in-process subagents (Agent tool) at once, with frequent tool calls (shell and the REPL tool), plus background-task notifications and Stop hooks
Measurements (from /proc/<pid>/io of the claude process itself, which excludes child processes)
- After 22 h:
write_bytes= 557 GB,cancelled_write_bytes= 194 GB. - Everything the session persists is small: the main transcript is about 55 MB, each subagent transcript is 6 to 23 MB, the session tmp dir is 1.7 GB (written mostly by child processes, which are not counted above),
~/.claude.jsonis 250 KB, and~/.claude/backupsis 1.3 MB. - A 90 s sample while subagents were active: write_bytes +176 MB and cancelled_write_bytes +73 MB, while the total size of the session's transcript files and tmp dir grew by less than 1 MB.
- Idle (no turn running, no subagents): about 0 MB/s.
- Other long CLI sessions on the same machine show the same pattern at a smaller scale: 19 to 58 GB written each.
~/.claude.jsonand the transcript were each replaced about once per 5 s in a spot check, so they alone don't explain 2 MB/s. I could not run strace or fatrace on this machine to attribute the rest.
Expected
Disk writes roughly proportional to what is persisted (append-only transcripts and small config), not 100x or more of it.
Asks
- Is the transcript, a subagent transcript, or a tool-output spill file being rewritten in full, or written to temp and then discarded, on each update? The cancelled_write_bytes ratio points that way.
- A way to attribute writes (a debug flag that logs file writes with sizes) would help users report this precisely.
I can run more diagnostics if you tell me what would help.
How to measure this on your machine
Use these steps if you'd like to check whether your sessions are affected. Each one reads the Claude Code process's own I/O counters, which exclude child processes such as shells and tests.
Linux and WSL
# find the Claude Code process ids (exact name, so this command doesn't match itself)
ps -C claude -o pid=,etimes=,args= | cut -c1-120
PID=<pid from above>
# totals since that process started
grep -E 'write_bytes|cancelled_write_bytes' /proc/$PID/io
ps -o etimes= -p $PID # seconds since it started
# rate over 60 s while a turn or subagents are running
a=$(awk '/^write_bytes/{print $2}' /proc/$PID/io); sleep 60; b=$(awk '/^write_bytes/{print $2}' /proc/$PID/io)
echo "MB/s: $(( (b-a)/60/1000000 ))"
# what the session actually keeps (transcripts)
du -sh ~/.claude/projects/*/ | sort -h | tail -5
macOS
- Activity Monitor: open the Disk tab, find the
claude(ornode) process and read Bytes Written. Note how long the session has been open. - For a live view:
sudo fs_usage -w -f filesys <pid> | grep -i writefor 30 s, which shows which files are being written. - Persisted size:
du -sh ~/.claude/projects/*/ | sort -h | tail -5
Windows (native)
Get-CimInstance Win32_Process -Filter "Name='claude.exe' OR Name='node.exe'" |
Select-Object ProcessId, Name, @{n='WrittenGB';e={[math]::Round($_.WriteTransferCount/1GB,2)}}, CreationDate
Persisted size: Get-ChildItem $env:USERPROFILE\.claude\projects -Recurse | Measure-Object Length -Sum
What to report
Please comment with: OS, Claude Code version, session age in hours, the number of subagents typically running, total bytes written (and cancelled bytes on Linux), the persisted transcript size, and the rate while active versus idle. A written-to-persisted ratio far above 10x matches this issue.
- Dominant language
- TypeScript
- Stars
- 156k
- Forks
- 25k
- Avg merge
- 16h 19m
- Merged PRs (30d)
- 5
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from anthropics/claude-code
-
area:hooks area:plugins bug has repro platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anthropics/claude-code#111771 ·
-
area:docs bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anthropics/claude-code#111658 ·
-
area:core bug platform:linux platform:wsl regression
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
anthropics/claude-code#111548 ·
-
area:vscode bug has repro platform:vscode platform:windows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
anthropics/claude-code#111416 ·
-
area:plugins area:tui bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
anthropics/claude-code#111195 ·
All issues in anthropics/claude-code
Similar issues
-
chore
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
drydocs/meridian#1503 · 1 comment ·
Maintainers usually reply within 2 days
-
refactor review: high
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
1lck/Lithe-IDEA#2376 ·
Maintainers usually reply within 1 day
-
bug extension mcp
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
primer/primitives#1426 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
danielmiessler/LifeOS#2941 ·
Maintainers usually reply within 4 days