by Cannon07
A Neovim plugin that shows a live diff preview of AI coding agent's file edits before you accept or reject them.
# Add to your Claude Code skills
git clone https://github.com/Cannon07/code-preview.nvimGuides for using ai agents skills like code-preview.nvim.
Last scanned: 5/30/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-05-30T15:58:12.069Z",
"npmAuditRan": true,
"pipAuditRan": true
}code-preview.nvim is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by Cannon07. A Neovim plugin that shows a live diff preview of AI coding agent's file edits before you accept or reject them. It has 175 GitHub stars.
Yes. code-preview.nvim passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/Cannon07/code-preview.nvim" and add it to your Claude Code skills directory (see the Installation section above).
code-preview.nvim is primarily written in Lua. It is open-source under Cannon07 on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh code-preview.nvim against similar tools.
No comments yet. Be the first to share your thoughts!
Review every edit your AI coding agent makes as a native Neovim diff — before it's written to disk.
Works with Claude Code, OpenCode, GitHub Copilot CLI, and OpenAI Codex CLI — on macOS, Linux, and Windows.

Shown with Claude Code. OpenCode, GitHub Copilot CLI, and Codex CLI work the same way — expand 📺 More demos below.
Your AI coding agent proposes edits in its terminal — a cramped, scroll-past diff you have to eyeball before typing y. code-preview.nvim intercepts that moment and opens the proposed change as a real Neovim diff: full syntax highlighting, your colorscheme, your keymaps. Review it like any other diff, then accept or reject in the agent's CLI as usual.
nvim --headless -l; the only hard dep is Neovim 0.10+



With lazy.nvim:
{
"Cannon07/code-preview.nvim",
config = function()
require("code-preview").setup()
end,
}
vim.opt.rtp:prepend("/path/to/code-preview.nvim")
require("code-preview").setup()
Requirements: Neovim >= 0.10. Each agent has a couple of extra needs — see below.
| Agent | Needs |
|---|---|
| Claude Code | Claude Code CLI (with hooks) · jq |
| OpenCode | OpenCode (a version with plugin support) |
| GitHub Copilot CLI | Copilot CLI (GA since Feb 2026) |
| OpenAI Codex CLI | Codex CLI recent enough for apply_patch PreToolUse hooks · jq |
On Windows, the Copilot CLI hook runs under PowerShell 7+ and needs no
jq.
After setup(), the flow is the same for every agent:
Then run the one install command for your agent (and apply any agent-specific config):
:CodePreviewInstallClaudeCodeHooks — writes hooks to .claude/settings.local.json. No extra config needed.
Permissions: by default the plugin forces a review prompt on every edit, so the preview always lines up with a real accept/reject moment — even if Claude Code is in bypass/allowlist mode. To instead let Claude Code's own permission settings decide, set
diff.defer_claude_permissions = true(you'll then only see previews for edits Claude Code already stops to ask about).
:CodePreviewInstallOpenCodeHooks — copies the plugin to .opencode/plugins/.
Then enable permission prompts in ~/.config/opencode/opencode.json:
{ "permission": { "edit": "ask", "bash": "ask" } }
:CodePreviewInstallCopilotCliHooks — writes .github/hooks/code-preview.json. No extra config needed.
:CodePreviewInstallCodexCliHooks — writes .codex/hooks.json.
Codex must ask before applying edits, so set this in .codex/config.toml (or ~/.codex/config.toml):
approval_policy = "on-request"
sandbox_mode = "read-only"
Without it, Codex may apply changes without prompting and the preview never blocks on your decision. Hooks are enabled by default in modern Codex; if you previously set [features] hooks = false (or the legacy codex_hooks = false), remove it. Codex routes file edits through apply_patch — files created via shell redirection (printf … > foo.txt) aren't previewed.
Rejected a change? The post-tool hook only fires on accept (and not at all on rejection for Claude Code & Copilot CLI), so press
<leader>dq— or run:CodePreviewCloseDiff— to close the preview manually.
Every agent is first-class — same diff experience, same keymaps, same neo-tree indicators.
| Agent | Install command | Mechanism |
|---|---|---|
| Claude Code | :CodePreviewInstallClaudeCodeHooks |
shell hooks in .claude/settings.local.json |
| OpenCode | :CodePreviewInstallOpenCodeHooks |
TS plugin in .opencode/plugins/ |
| GitHub Copilot CLI | :CodePreviewInstallCopilotCliHooks |
shell hooks in .github/hooks/code-preview.json |
| OpenAI Codex CLI | :CodePreviewInstallCodexCliHooks |
shell hooks in .codex/hooks.json |
Each install command has a matching :CodePreviewUninstall… counterpart. More agents are planned.
setup() works with zero config. The most common knob is the diff layout:
require("code-preview").setup({
diff = {
layout = "tab", -- "tab" | "vsplit" | "inline"
},
})
| Layout | Description |
|---|---|
"tab" (default) |
Side-by-side diff in a new tab — CURRENT left, PROPOSED right |
"vsplit" |
Side-by-side as a vertical split in the current tab |
"inline" |
GitHub-style unified diff in one buffer, syntax highlighting preserved, ]c / [c to navigate |
You can also set the layout per agent — e.g. inline for Codex, a tab for everything else:
require("code-preview").setup({
diff = {
layout = "tab", -- default for all agents
layouts = { codex = "inline" }, -- keys: claudecode | opencode | copilot | codex
},
})
A realistic, opinionated lazy.nvim spec — inline diffs everywhere, a per-agent override, and neo-tree revealing from the git root:
{
"Cannon07/code-preview.nvim",
event = "VeryLazy",
config = function()
require("code-preview").setup({
diff = {
layout = "inline", -- unified GitHub-style diff (the strategic default)
layouts = { opencode = "tab" }, -- override the layout per agent, to taste
},
neo_tree = { reveal_root = "git" }, -- reveal from the git root instead of cwd
})
end,
}
Full option reference: :help code-preview-config (or doc/code-preview.txt) — every option, with the defaults kept in sync with the source.
| Command | Description |
|---|---|
:CodePreviewInstall…Hooks / :CodePreviewUninstall…Hooks |
Install/remove hooks for an agent (ClaudeCode, OpenCode, CopilotCli, CodexCli) |
:CodePreviewCloseDiff |
Manually close the diff (use after rejecting) |
:CodePreviewStatus |
Show socket path, hook status, and dependency check |
:CodePreviewToggleVisibleOnly |
Toggle visible_only — diffs only for open buffers |
:checkhealth code-preview |
Full health check (all agents) |
| Key | Scope | Description |
|---|---|---|
<leader>dq |
global | Close the diff (same as :CodePreviewCloseDiff) |
]c |
inline diff buffer | Jump to next change |
[c |
inline diff buffer | Jump to previous change |
See :help code-preview-commands and :help code-preview-keymaps for details.
If you use neo-tree.nvim, code-preview decorates your file tree with indicators whenever changes are pending — no extra config, it works out of the box. If neo-tree isn't installed, nothing changes.
| Status | Icon | Color | Meaning |
|---|---|---|---|
| Modified | | Orange | An existing file is being edited |
| Created | | Cyan + italic | A new file is being created (virtual node) |
| Deleted | | Red + strikethrough | A file is being deleted via rm |
Plus: auto-reveal of the changed file, virtual nodes for not-yet-created files, a temporarily clean focus (git status/diagnostics hidden while a change is pending), and auto-cleanup on accept/reject/<leader>dq. Symbols, colors, position, and reveal behavior are all configurable under the neo_tree table — see :help code-preview-config.
AI Agent (terminal)