[Feature Request] Trigger VSCode formatOnSave when editing files via VSCode extension
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When using Claude Code in the VSCode extension, file edits do not trigger VSCode's formatOnSave or other save-related hooks (like Prettier, ESLint auto-fix, Biome, etc.).
This is because Claude Code writes directly to the filesystem rather than going through VSCode's editor API.
The current workflow requires me to manually save the file in VSCode after Claude edits it, or wait for pre-commit hooks to fix formatting issues later.
Proposed Solution
In the VSCode extension, use VSCode's editor API for file modifications instead of direct filesystem writes:
// Instead of direct fs.writeFile()
const edit = new vscode.WorkspaceEdit();
edit.replace(uri, range, newContent);
await vscode.workspace.applyEdit(edit);
await document.save(); // This triggers formatOnSave
This would trigger the onDidSaveTextDocument event, and VSCode's configured formatOnSave, linters, and other extensions would run automatically.
Alternative Solutions
- PostToolUse hooks - Users can configure hooks to run formatters after edits, but this requires manual setup per project and doesn't integrate with VSCode's existing configuration
- Manual save - Users can manually save files after Claude edits, but this adds friction to the workflow
- Pre-commit hooks - Formatting happens at commit time, but this delays feedback and can cause unexpected diffs
Priority
Low - Nice to have
Feature Category
Other
Use Case Example
Example scenario:
- I'm working on a TypeScript/React project with Biome configured for formatOnSave
- I ask Claude Code to edit a component file
- Claude edits the file, but Biome doesn't run because the save didn't go through VSCode's API
- When I commit, pre-commit hooks catch and fix the formatting, creating unnecessary diff noise
- With this feature, formatting would happen immediately after Claude's edit, keeping the code consistent
Additional Context
This feature is specific to the VSCode extension
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗