Agent skill

Lsp Safe Edit

by blackwell-systems in blackwell-systems/agent-lsp

Wrap any code edit with before/after diagnostic comparison. An agent skill from blackwell-systems/agent-lsp.

MITAuto-check: notesAgent Workflows

Install Lsp Safe Edit

skills CLI
$ npx skills add blackwell-systems/agent-lsp --skill lsp-safe-edit -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install blackwell-systems/agent-lsp lsp-safe-edit --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/blackwell-systems/agent-lsp.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/lsp-safe-edit .claude/skills/lsp-safe-edit && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
lsp-safe-edit
GitHub stars
160
Token cost
~2.5k tokens
SKILL.md length
852 words
Files
2 (incl. references)
Skills in repo
24
Repo updated
First seen
Licence
MIT

At a glance

Wrap any code edit with before/after diagnostic comparison. An agent skill from blackwell-systems/agent-lsp.

  • Works in 9 steps: Open target file(s) → Capture baseline diagnostics (BEFORE) → Speculative preview (preview_edit) → …
  • Agent Workflows work in your project
  • SKILL.md covers Prerequisites, Input, Workflow and Decision Guide, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Lsp Safe Edit is an agent skill from blackwell-systems/agent-lsp. Wrap any code edit with before/after diagnostic comparison. Speculatively previews the change first (previewedit), 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.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/patterns.md`). Compatibility notes: Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)

It sits in Agent Workflows. It works with Model Context Protocol. The repository describes itself as: MCP server that orchestrates language servers into agent-native workflows. 65 tools, 30 CI-verified languages. The licence is MIT.

When your agent uses it

  • Agent Workflows work in your project

Example prompts

  • “/lsp-safe-edit”

Requirements

  • Compatibility (from SKILL.md): Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)
  • Pre-approved tools (allowed-tools): mcp__lsp__start_lsp, mcp__lsp__open_document, mcp__lsp__get_diagnostics, mcp__lsp__preview_edit, mcp__lsp__simulate_chain, mcp__lsp__suggest_fixes, mcp__lsp__format_document, mcp__lsp__apply_edit, Edit, Write, Bash

Workflow steps

9 steps, taken from the step headings in SKILL.md.

  1. Open target file(s)
  2. Capture baseline diagnostics (BEFORE)
  3. Speculative preview (preview_edit)
  4. Apply the edit to disk
  5. Capture post-edit diagnostics (AFTER)
  6. Compute the diagnostic diff
  7. Surface code actions if errors were introduced
  8. Format (optional)
  9. Report using DiagnosticDiffFormat

What it can do on your machine

Read from SKILL.md and the folder at commit 38ca488. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • mcp__lsp__start_lsp
    • mcp__lsp__open_document
    • mcp__lsp__get_diagnostics
    • mcp__lsp__preview_edit
    • mcp__lsp__simulate_chain
    • mcp__lsp__suggest_fixes
    • mcp__lsp__format_document
    • mcp__lsp__apply_edit
    • Edit
    • Write

    …and 1 more on the same allowed-tools line.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)

    From compatibility in the SKILL.md frontmatter.

Context cost

Lsp Safe Edit loads about 2.5k tokens when it runs, and up to ~3k if it reads all its reference files. Until then it costs about 73 tokens; SKILL.md has 852 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~73
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: mcp__lsp__start_lsp, mcp__lsp__open_document, mcp__lsp__get_diagnostics, mcp__lsp__preview_edit, mcp

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from blackwell-systems/agent-lsp at commit 38ca488, republished under its MIT licence (© blackwell-systems). 852 words, ~2,467 tokens.

Download SKILL.mdSave it as .claude/skills/lsp-safe-edit/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
lsp-safe-edit
description
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.
allowed-tools
mcp__lsp__start_lsp, mcp__lsp__open_document, mcp__lsp__get_diagnostics, mcp__lsp__preview_edit, mcp__lsp__simulate_chain, mcp__lsp__suggest_fixes, mcp__lsp__format_document, mcp__lsp__apply_edit, Edit, Write, Bash
compatibility
Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)
user-invocable
true
license
MIT
metadata.optional-capabilities
codeActionProvider documentFormattingProvider

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__preview_edit(
  file_path: "/abs/path/to/file.go",
  start_line: <N>,
  start_column: <col>,
  end_line: <N>,
  end_column: <col>,
  new_text: "<replacement text>"
)

Returns net_delta (new errors introduced minus errors resolved) without writing to disk.

Decision:

net_deltaAction
≤ 0Proceed — edit improves or does not worsen error state
> 0Pause. Report introduced errors to user and ask: "Proceed anyway? [y/n]"

If net_delta > 0 and user says "n", stop. Do not apply the edit.

Multi-file edits: preview_edit covers one file at a time. For edits spanning multiple files, run it for each file independently and sum the deltas. If any file shows net_delta > 0, pause before continuing.

When to skip Step 3: If the intended change is a new file (Write), there is no existing file to simulate against. Skip to Step 4.

Step 3b — Refactor preview with simulate_chain (renames and signature changes)

Use this step instead of or after Step 3 when the change is a rename, signature change, or any edit with dependent follow-on edits (e.g., updating all call sites after adding a parameter).

simulate_chain applies a sequence of speculative edits in-memory and reports whether the cumulative change is safe — without touching disk:

mcp__lsp__simulate_chain({
  "workspace_root": "/abs/path/to/workspace",
  "language": "go",
  "edits": [
    {
      "file_path": "/abs/path/to/file.go",
      "start_line": <N>, "start_column": <col>,
      "end_line": <N>,   "end_column": <col>,
      "new_text": "<replacement>"
    },
    // additional dependent edits (e.g. call site updates) ...
  ]
})

Returns:

  • cumulative_delta — net error change across all steps
  • safe_to_apply_through_step — how many steps are safe to apply in sequence

Decision:

cumulative_deltasafe_to_apply_through_stepAction
≤ 0= total stepsAll steps safe. Proceed to Step 4.
≤ 0< total stepsSafe up to that step. Review remaining steps.
> 0anyNet regression. Report to user before proceeding.

When to use Step 3b:

  • Renaming an exported symbol and updating its call sites
  • Adding/removing a parameter and updating all callers
  • Any multi-file refactor where edits are order-dependent

When to skip Step 3b:

  • Simple in-place edits with no dependent follow-on edits (Step 3 is sufficient)
  • New file creation (no existing text to simulate against)
Step 4 — Apply the edit to disk

Apply the change using the Edit or Write tool:

  • Use Edit for targeted replacements in an existing file.
  • Use Write only when creating a new file or doing a full rewrite.
Edit(file_path: "/abs/path/to/file.go", old_string: "...", new_string: "...")

For multi-file edits, apply each file's changes before collecting post-edit diagnostics (Step 5). If any individual edit fails, stop and report before applying remaining files.

Show full SKILL.md (335 more words)Show less
Step 5 — Capture post-edit diagnostics (AFTER)

Call mcp__lsp__get_diagnostics again for each edited file. Store as AFTER.

AFTER = mcp__lsp__get_diagnostics(file_path: "/abs/path/to/file.go")

For multi-file edits, collect diagnostics for all files and merge the results.

Step 6 — Compute the diagnostic diff

Compare BEFORE and AFTER:

  • Introduced = diagnostics in AFTER not in BEFORE (new problems).
  • Resolved = diagnostics in BEFORE not in AFTER (fixed problems).

Match by (file, line, message) tuple to handle line-number shifts. Treat error and warning severity separately.

Step 7 — Surface code actions if errors were introduced

If any new error-severity diagnostics appear, call mcp__lsp__suggest_fixes at each error location to surface quick fixes:

mcp__lsp__suggest_fixes(
  file_path: "<file>",
  start_line: <error line>,
  start_column: 1,
  end_line: <error line>,
  end_column: 999
)

Report available code actions to the user:

Errors introduced (2):
  file.go:34 — undefined: MyType
    → Code action: Import "mypackage" (quickfix)
  file.go:51 — cannot use int as string
    → No code actions available

Apply code actions? [y/n/select]

If the user accepts, apply the code action's WorkspaceEdit via mcp__lsp__apply_edit, then re-collect diagnostics and re-diff.

Step 8 — Format (optional)

If the diagnostic diff is clean (net change ≤ 0), offer to format the edited file via the language server:

mcp__lsp__format_document({ "file_path": "/abs/path/to/file" })

Returns TextEdit[]. If non-empty, apply immediately:

mcp__lsp__apply_edit({ "workspace_edit": <TextEdit[]> })

Skip if the user did not ask for formatting, or if there are unresolved errors (fix errors before formatting).

Step 9 — Report using DiagnosticDiffFormat

Output the final summary:

## Edit Summary

Files changed: N
Errors introduced: A  →  Errors resolved: B  (net: A-B)
Warnings introduced: C  →  Warnings resolved: D

### Introduced errors
- file.go:34 — undefined: MyType

### Resolved errors
- file.go:12 — unused variable: x

Decision Guide

Net changeAction
0Safe. No new errors.
NegativeNet improvement — errors resolved. Safe.
Positive (after code actions)Do NOT commit. Offer to revert.

When net change > 0 after code actions:

  1. Show the full list of remaining introduced errors.
  2. Offer to revert using the original old_string in a follow-up Edit call.
  3. Wait for user decision before proceeding.

Do not commit or stage files when net change > 0.


Multi-file workflow

For edits spanning multiple files (e.g., changing a function signature and all its call sites):

  1. Open all files in Step 1.
  2. Collect BEFORE diagnostics for all files.
  3. Simulate each file independently in Step 3 — sum net_delta values.
  4. Apply edits file by file in Step 4 — stop on first failure.
  5. Collect AFTER diagnostics for all files and merge.
  6. Check code actions on any file showing new errors.

Report the combined diagnostic diff across all files in the final summary.

© blackwell-systems, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in skills/lsp-safe-edit of blackwell-systems/agent-lsp.

  • SKILL.md
  • references/patterns.md

Open the folder on GitHubat commit 38ca488

Compare with similar skills

Lsp Safe Edit next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Lsp Safe Edit compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Lsp Safe Edit this skillblackwell-systems/agent-lsp160—~2.5kAutomated safety check: NotesMIT
MCP Server Builderanthropics/skills180k63 repos~2.3kAutomated safety check: PassApache-2.0
MCP Server BuildershareAI-lab/learn-claude-code78k4 repos~1.2kAutomated safety check: PassMIT
MCP Integration for Pluginsanthropics/claude-plugins-official38k11 repos~3.1kAutomated safety check: PassApache-2.0
MemPalace Memory SearchMemPalace/mempalace59k—~1.4kAutomated safety check: PassMIT
Crush Configurationcharmbracelet/crush29k—~3.7kAutomated safety check: PassCustom licence

Similar skills

  • MCP Server Builder

    anthropics/skills

    Official

    Guides the design and implementation of Model Context Protocol servers in TypeScript or Python, from tool naming and error messages to evaluation.

    180k GitHub starsUsed in 63 repos~2.3k tokens
    Agent WorkflowsAuto-check passed
  • MCP Server Builder

    shareAI-lab/learn-claude-code

    Walks through building MCP servers in Python or TypeScript that expose tools, resources and prompts to Claude, with templates, registration and testing.

    78k GitHub starsUsed in 4 repos~1.2k tokens
    Agent WorkflowsAuto-check passed
  • MCP Integration for Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to bundle Model Context Protocol servers in a Claude Code plugin, covering config files, stdio, SSE, HTTP and WebSocket server types, and authentication.

    38k GitHub starsUsed in 11 repos~3.1k tokens
    Agent WorkflowsAuto-check passed
  • MemPalace Memory Search

    MemPalace/mempalace

    Mines project files and conversation exports into a local, searchable memory palace and recalls past work by semantic search through the mempalace CLI.

    59k GitHub stars~1.4k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Crush Configuration

    charmbracelet/crush

    Explains how to configure the Crush coding agent with crushrc or crush.json, covering providers, models, LSPs, MCP servers, hooks, permissions and config precedence.

    29k GitHub stars~3.7k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Context Mode Output Sandbox

    mksglu/context-mode

    Routes large command, file, API and browser output through context-mode tools so only the needed result enters the agent's context, instead of dumping it via Bash.

    26k GitHub stars~4.1k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from blackwell-systems/agent-lsp

All 24 skills in this repo
  • Lsp Dead Code

    blackwell-systems/agent-lsp

    Enumerate exported symbols in a file and surface those with zero references across the workspace.

    160 GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Lsp Edit Export

    blackwell-systems/agent-lsp

    Safe workflow for editing exported symbols or public APIs. An agent skill from blackwell-systems/agent-lsp.

    160 GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Lsp Fix All

    blackwell-systems/agent-lsp

    Apply available quick-fix code actions for all current diagnostics in a file, one at a time with re-collection between each fix.

    160 GitHub stars~1.6k tokensUpdated today
    Auto-check passed
  • Lsp Generate

    blackwell-systems/agent-lsp

    Trigger language server code generation — implement interface stubs, generate test skeletons, add missing methods, generate mock types.

    160 GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Lsp Impact

    blackwell-systems/agent-lsp

    Blast-radius analysis for a symbol or file — shows all callers, type supertypes/subtypes, and reference count before you change it.

    160 GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Lsp Rename

    blackwell-systems/agent-lsp

    Two-phase safe rename across the entire workspace. An agent skill from blackwell-systems/agent-lsp.

    160 GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Categories

Questions about Lsp Safe Edit

What does Lsp Safe Edit do?

Wrap any code edit with before/after diagnostic comparison. An agent skill from blackwell-systems/agent-lsp. Lsp Safe Edit is an agent skill from blackwell-systems/agent-lsp. Wrap any code edit with before/after diagnostic comparison.

When should I use Lsp Safe Edit?

Lsp Safe Edit fits situations like: agent Workflows work in your project.

How do I install Lsp Safe Edit in Claude Code?

Run `npx skills add blackwell-systems/agent-lsp --skill lsp-safe-edit -a claude-code`. Or copy the skill folder (skills/lsp-safe-edit in blackwell-systems/agent-lsp) into .claude/skills/lsp-safe-edit in your project. Claude Code loads it when a task matches its description.

How do I install Lsp Safe Edit in Codex?

Run `npx skills add blackwell-systems/agent-lsp --skill lsp-safe-edit -a codex`. Or copy the skill folder (skills/lsp-safe-edit in blackwell-systems/agent-lsp) into .agents/skills/lsp-safe-edit in your project. Codex loads it when a task matches its description.

Can I use Lsp Safe Edit in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add blackwell-systems/agent-lsp --skill lsp-safe-edit -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/lsp-safe-edit, .gemini/skills/lsp-safe-edit, .github/skills/lsp-safe-edit and .opencode/skills/lsp-safe-edit in your project.

What does Lsp Safe Edit need to run?

SKILL.md names no scripts, command-line tools or credentials: Lsp Safe Edit is instructions for the agent only. Its frontmatter pre-approves these tools: mcp__lsp__start_lsp, mcp__lsp__open_document, mcp__lsp__get_diagnostics, mcp__lsp__preview_edit, mcp__lsp__simulate_chain, mcp__lsp__suggest_fixes, mcp__lsp__format_document, mcp__lsp__apply_edit, Edit, Write, Bash. Compatibility (from SKILL.md): Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp).

Does Lsp Safe Edit access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Lsp Safe Edit safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Lsp Safe Edit use?

Lsp Safe Edit is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Lsp Safe Edit use?

About 2.5k tokens (SKILL.md is roughly 9.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 499 tokens, read only when the agent opens those files.

What are the alternatives to Lsp Safe Edit?

Skills that share tags, products or a category with Lsp Safe Edit: MCP Server Builder (anthropics/skills, 180k stars), MCP Server Builder (shareAI-lab/learn-claude-code, 78k stars), MCP Integration for Plugins (anthropics/claude-plugins-official, 38k stars) and MemPalace Memory Search (MemPalace/mempalace, 59k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Lsp Safe Edit?

blackwell-systems (a GitHub user) maintains it in blackwell-systems/agent-lsp, which has 160 GitHub stars. The repository holds 24 skills in this directory. The repository was last updated on October 10, 2026.

Source: blackwell-systems/agent-lsp on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.