lsp-safe-edit

Solid

Wrap any code edit with before/after diagnostic comparison. Speculatively previews the change first (preview_edit), then applies to disk only if the error delta is acceptable. If post-edit errors appear, surfaces code actions for quick fixes. Handles single and multi-file edits.

AI & Automation 56 stars 2 forks Updated today MIT

Install

View on GitHub

Quality Score: 91/100

Stars 20%
58
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

> Requires the agent-lsp MCP server. # lsp-safe-edit Wrap any code edit with a before/after diagnostic comparison. Speculatively previews the change in-memory before touching disk, then diffs errors introduced vs. resolved after applying. If errors appear, surfaces code actions to fix them. ## Prerequisites LSP must be running for the target workspace. If not yet initialized, call `mcp__lsp__start_lsp` with the workspace root before proceeding. Auto-init note: agent-lsp supports workspace auto-inference from file paths. Explicit `start_lsp` is only needed when switching workspace roots. ## Input - **target file(s):** One or more files to be edited (absolute paths). - **description of change:** What you intend to edit and why. --- ## Workflow ### Step 1 — Open target file(s) Call `mcp__lsp__open_document` for each file that will be edited: ``` mcp__lsp__open_document(file_path: "/abs/path/to/file.go", language_id: "go") ``` ### Step 2 — Capture baseline diagnostics (BEFORE) Call `mcp__lsp__get_diagnostics` for each target file. Store as BEFORE. For multi-file edits, collect diagnostics for all files involved. ``` BEFORE = mcp__lsp__get_diagnostics(file_path: "/abs/path/to/file.go") ``` If the server returns an empty list immediately after open, wait briefly and retry — LSP analysis is async. ### Step 3 — Speculative preview (preview_edit) Before touching disk, call `mcp__lsp__preview_edit` to preview the error delta of the intended change: ``` mcp__lsp__prev...

Details

Author
blackwell-systems
Repository
blackwell-systems/agent-lsp
Created
2 months ago
Last Updated
today
Language
Go
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category