[BUG] VS Code extension crashes (stream closed) when Write tool creates/edits markdown files
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When Claude Code's Write tool creates or edits a .md file, the VS Code extension auto-reveals the file in the editor. For markdown files of moderate size (~90+ lines), this consistently crashes the extension's communication stream. The tool returns "Error: Tool permission request failed: Error: Stream closed" — sometimes 4-5 times in a row for the same write attempt. The file does actually get written to disk successfully, but the stream between Claude and VS Code dies, requiring the user to retry or restart.
What Should Happen?
1. The Write tool should complete without crashing regardless of file type or size.
2. Ideally, auto-revealing written files should be configurable via a setting (e.g., claudeCode.autoRevealFiles: true/false), so users can disable it for non-code files like planning docs.
3. At minimum, if the file was written successfully, the tool should return success even if the reveal/preview step fails.
Error Messages/Logs
Tool permission request failed: Error: Stream closed
Steps to Reproduce
1. Open a project in VS Code with the Claude Code extension
2. Ask Claude to write a markdown file (~90+ lines) to any path outside the workspace (e.g., ~/.claude-workflow/contexts/project/planning/ticket.md)
3. The Write tool will fail with "Error: Stream closed"
4. Verify the file was actually written to disk (it was — a linter/watcher detects the change)
5. Retry the Write tool — same error repeats
_Note: Reproducible every time with markdown files. Does not occur with .txt files of the same content._
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
N/A
Claude Code Version
2.1.39 (VS Code extension: anthropic.claude-code-2.1.39-win32-x64)
Platform
Other
Operating System
Windows
Terminal/Shell
Other
Additional Information
Claude Code Version
2.1.39 (VS Code extension: anthropic.claude-code-2.1.39-win32-x64)
Platform
Windows (VS Code native extension, not terminal)
Operating System
Windows 11 Pro 10.0.26200
Terminal/Shell
Windows PowerShell (not relevant — issue is in native VS Code extension UI, not terminal mode)
Additional Information
claudeCode.preferredLocation is set to "panel"
User already has "*.md": "default" in workbench.editorAssociations and "markdown.extension.preview.autoShowPreviewToSide": false — neither prevents the crash
Workaround: write files as .txt instead of .md, or use Bash tool with cat > which bypasses the auto-reveal behavior
The extension's package.json and settings schema have no setting to control file auto-reveal behavior
Files outside the workspace (e.g., in ~/.claude-workflow/) seem more likely to trigger this, possibly because VS Code struggles to resolve the editor association for external paths
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗