Skip to content

feat: Add side-by-side visual diff preview for Claude's file edits#19

Merged
rishi-opensource merged 7 commits intomainfrom
feature/diff-preview
Mar 19, 2026
Merged

feat: Add side-by-side visual diff preview for Claude's file edits#19
rishi-opensource merged 7 commits intomainfrom
feature/diff-preview

Conversation

@rishi-opensource
Copy link
Owner

@rishi-opensource rishi-opensource commented Mar 19, 2026

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:

  • @crisecheverria: Designed and built the core concept! They conceived the .claude/settings.local.json injection strategy to hijack the PreToolUse hooks, 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.
  • Maintainer (@rishi-opensource): Refactored the underlying hook scripts. Consolidated the external bash/jq dependencies into standard-library Python scripts, modified .replace() to handle MultiEdit code blocks safely, and sandboxed the IPC temp files securely inside the repo's .claude/tmp/ directory to prevent /tmp multi-user concurrency race conditions.

By merging this, we solve the 'blind-trust' edit problem while keeping the plugin lightweight and secure!

Cristian Echeverria and others added 7 commits March 19, 2026 17:30
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>
@rishi-opensource rishi-opensource merged commit 9a7a0d2 into main Mar 19, 2026
2 checks passed
@github-actions
Copy link

🎉 This PR is included in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Visual diff preview for Claude's file edits

1 participant