feat: Add side-by-side visual diff preview for Claude's file edits#19
Merged
rishi-opensource merged 7 commits intomainfrom Mar 19, 2026
Merged
feat: Add side-by-side visual diff preview for Claude's file edits#19rishi-opensource merged 7 commits intomainfrom
rishi-opensource merged 7 commits intomainfrom
Conversation
Adds side-by-side diff preview when Claude proposes file edits (Edit, Write, MultiEdit). Uses Claude Code PreToolUse/PostToolUse hooks to intercept changes and display a diff tab in Vim before accepting. New commands: - :Claude preview install — register hooks in .claude/settings.local.json - :Claude preview uninstall — remove hooks - :Claude preview close — manually close diff tab - :Claude preview status — show status and dependency checks New files: - autoload/claude_code/diff.vim — diff display, polling, hook management - bin/vim-preview-diff.sh — PreToolUse hook script - bin/vim-close-diff.sh — PostToolUse hook script - bin/apply-proposed.py — compute proposed file content Requires python3 and jq. Supports both file-based polling (universal) and vim --servername (instant, when +clientserver available). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ect keybindings - Fix s:bin_dir() using <sfile> inside function (returns call stack, not file path) - Strip trailing slash from $TMPDIR on macOS to avoid double-slash paths - Skip stale trigger files when temp files no longer exist - Add ga/gr keybindings in diff buffer to accept/reject changes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add documentation for the new diff preview commands, requirements, configuration, and plugin structure changes introduced in ba1ecc9. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…y and properly isolate temp files
e84a58f to
00a45db
Compare
|
🎉 This PR is included in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the Visual Diff Preview feature to safely review Claude Code file modifications in a native Vim side-by-side buffer. It resolves #18.
Credits & Implementation
This is a collaborative effort:
.claude/settings.local.jsoninjection strategy to hijack thePreToolUsehooks, authored the deep Vimscript window management logic (autoload/claude_code/diff.vim), the sub-command dispatcher routing (plugin/claude_code.vim), and the IPC fallback mechanisms.jqdependencies into standard-library Python scripts, modified.replace()to handleMultiEditcode blocks safely, and sandboxed the IPC temp files securely inside the repo's.claude/tmp/directory to prevent/tmpmulti-user concurrency race conditions.By merging this, we solve the 'blind-trust' edit problem while keeping the plugin lightweight and secure!