Crash when Edit tool modifies settings.json during active session
Bug Description
Claude Code crashes when the Edit tool is used to modify ~/.claude/settings.json during an active session. The file watcher detects the change, triggers a hot-reload of settings mid-stream, and the rendering engine breaks — dumping a wall of raw data to the terminal before the REPL unmounts.
Steps to Reproduce
- Start a Claude Code session
- Ask Claude to edit
~/.claude/settings.jsonusing the Edit tool (e.g., add a hook or change a setting) - The Edit tool writes the file successfully
- The file watcher fires and hot-reloads settings while the model is streaming a response
- Session crashes with a massive terminal dump
Debug Log Timeline
20:45:25.226 — Edit tool writes settings.json (2188 bytes, atomic write succeeds)
20:45:26.240 — File watcher: "Detected change to /home/ec2-user/.claude/settings.json"
20:45:26.244 — "Settings changed from userSettings, updating app state"
20:45:26.246 — "Replacing all allow rules for destination 'localSettings' with 68 rule(s)"
20:45:27.207 — Stream started (model responding)
20:45:28.274 — Screen jumps from 331x130 to 1107x130, dumps 112KB in one frame
(blit=0, write=112780, 100.0% writes)
20:45:28.328 — [REPL:unmount] REPL unmounting
What Happens
The layout engine miscalculates the screen width (triples from ~331 to 1107 columns) after the settings hot-reload, causing a single 112KB frame to be written to the terminal. This appears to the user as a wall of raw/garbled output, then the session dies.
Expected Behavior
Editing settings.json from within the session should either:
- Pause the file watcher during Edit tool writes to watched files
- Handle the hot-reload gracefully without disrupting active streams
- Use an internal settings API instead of raw file editing for settings changes
Environment
- Claude Code version: 2.1.32
- Platform: Linux (Amazon Linux, EC2)
- Terminal: SSH session (130 rows)
Workaround
Don't use the Edit tool on ~/.claude/settings.json. Use /config or edit manually between sessions instead.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗