Skip to main content
skill CX Codex

lsp-edit-symbol — Claude Code skill: edit a symbol by name

Changes a function, type or variable by name when you don't know the file or position. Runs on the agent-lsp MCP server.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add blackwell-systems/agent-lsp --skill lsp-edit-symbol -a claude-code
Open on GitHub

What lsp-edit-symbol does

The skill resolves a symbol name to its definition, pulls the full range and applies the edit. The main route is replace_symbol_body: it locates the symbol inside the file and swaps the whole body, so no line and column arithmetic is needed. Methods take dot notation — MyStruct.Method.

When the server handles document symbols poorly, the skill falls back to manual resolution. find_symbol gives you the file, list_symbols returns a tree with ranges, then apply_edit rewrites either by matching old text or by position. Positional mode has a trap: list_symbols counts lines from one, while apply_edit in workspace_edit expects zero-based values, so subtract one. Text-match mode skips that step entirely.

Renames are out of scope. The skill touches only the definition it found; call sites elsewhere stay as they were. Use /lsp-rename for that job. You need the agent-lsp MCP server installed with workspaceSymbolProvider support, otherwise the mcp__lsp__* tools never show up. Run get_diagnostics afterwards to catch broken types.

What it helps with

  • swap a function body without opening the file or counting lines
  • fix a method signature by class-qualified name
  • locate a definition when several symbols share a name
  • replace a type or variable body in one call
  • confirm an edit didn't break compilation

Example prompts for the agent

  • Replace the body of MyFunc in /path/to/file.go with a version that returns an error
  • Find MyStruct.Method and change only its signature
  • Edit the body of parseConfig, then run get_diagnostics

How to install lsp-edit-symbol

1Skills CLI (Vercel)

npx skills add blackwell-systems/agent-lsp --skill lsp-edit-symbol -a claude-code

2Manually: put the files in place

~/.claude/skills/lsp-edit-symbol/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/lsp-edit-symbol/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about lsp-edit-symbol

How do I install lsp-edit-symbol in Claude Code?

Run npx skills add blackwell-systems/agent-lsp --skill lsp-edit-symbol -a claude-code. The skill lands in ~/.claude/skills/lsp-edit-symbol/SKILL.md.

What does lsp-edit-symbol do?

It edits a named symbol — function, type or variable — without exact path or coordinates. It finds the definition first, then replaces the body through replace_symbol_body.

How is it different from /lsp-rename?

/lsp-rename updates every call site of a symbol, while this skill edits only the definition it resolved. Pick the first for project-wide renames.

Source text

SKILL.md · MIT
---
name: lsp-edit-symbol
description: "Edit a named symbol without knowing its file or position. Use when you want to change a function, type, or variable by name and don't have exact coordinates. Resolves the symbol to its definition, retrieves its full range, and applies the edit."
argument-hint: "[symbol-name] [new-body-or-signature]"
user-invocable: true
allowed-tools:
  - mcp__lsp__find_symbol
  - mcp__lsp__list_symbols
  - mcp__lsp__apply_edit
  - mcp__lsp__replace_symbol_body
license: MIT
compatibility: Requires the agent-lsp MCP server (github.com/blackwell-systems/agent-lsp)
metadata:
  required-capabilities: workspaceSymbolProvider
---

# lsp-edit-symbol

Edit a named symbol (function, type, variable) without needing its exact file path
or line/column. Primary path uses `replace_symbol_body` for direct symbol replacement.
Falls back to `find_symbol` + `list_symbols` + `apply_edit` when
the server does not support document symbols well.

## Workflow

### Step 1 — Locate the file

```json
{ "tool": "find_symbol", "query": "MyFunc" }
```

Returns a list of matching symbols with file URI and position. Pick the definition
(not a test file, not a stub). If multiple matches, use the container name or file
path to disambiguate.

### Step 2 — Replace the symbol body (primary path)

Use `replace_symbol_body` to replace the entire function/method/type body by name:

```json
{
  "tool": "replace_symbol_body",
  "file_path": "/path/to/file.go",
  "symbol_path": "MyFunc",
  "new_body": "func MyFunc() error {\n\treturn nil\n}"
}
```

For methods, use dot notation: `"MyStruct.Method"`.

This resolves the symbol by name within the file, finds its full range, and replaces
it atomically. No position math required.

**If `replace_symbol_body` fails** (e.g., the server cannot resolve document symbols
for this file), fall back to the manual path below.

### Fallback — Manual resolution via document symbols

**Step 2b — Get the full range:**

```json
{
  "tool": "list_symbols",
  "file_path": "/path/to/file.go",
  "language_id": "go"
}
```

Find `MyFunc` in the returned tree. The `range` field covers the entire symbol
including its body; `selectionRange` covers only the name.

**Step 3b — Apply the edit:**

Option A (text-match, recommended when you have the old text):
```json
{
  "tool": "apply_edit",
  "file_path": "/path/to/file.go",
  "old_text": "func MyFunc() {",
  "new_text": "func MyFunc() error {"
}
```

Option B (positional, when you have the exact range):
```json
{
  "tool": "apply_edit",
  "workspace_edit": {
    "changes": {
      "file:///path/to/file.go": [{
        "range": { "start": {"line": 12, "character": 0}, "end": {"line": 18, "character": 1} },
        "newText": "func MyFunc() error {\n\treturn nil\n}"
      }]
    }
  }
}
```

## Decision guide

| Situation | Approach |
|-----------|----------|
| Replacing full body | `replace_symbol_body` (primary path) |
| Changing signature only | Step 1 + apply_edit with one-line old_text |
| Symbol name ambiguous | Use `find_symbol` query + container name filter |
| Server lacks document symbols | Fallback path (Step 2b + 3b) |
| After edit | Run `get_diagnostics` to verify no errors introduced |

## Notes

- `replace_symbol_body` is the preferred path for full-body replacements. It handles
  symbol resolution and range calculation internally.
- `find_symbol` returns declaration sites, not all references. The
  first non-test result is usually the definition.
- Positions in `list_symbols` are **1-based** (shifted from LSP convention).
  `apply_edit` `workspace_edit` expects **0-based**; subtract 1 when using positional
  mode (Option B). Text-match mode (Option A) requires no position math.
- For renames (not edits), use `/lsp-rename` instead; it updates all call sites.

© blackwell-systems · MIT · blackwell-systems/agent-lsp

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set9

lsp-test-correlation Maps an edited source file to the tests that cover it, then runs just those. Useful when one file changed and the full suite is overkill. CX Codex +1 ★ 165repo stars lsp-rename Renames functions, methods, variables and types across a workspace in two phases: it lists every affected site first, then edits after you confirm. CX Codex +1 ★ 165repo stars lsp-local-symbols Lists the functions and types a file declares, finds every use of a symbol inside it, and reports the type. Handy before you edit a single file. CX Codex +1 ★ 165repo stars lsp-impact Maps every caller, supertype and subtype, and reference count for a symbol or file before you touch it. Built for refactors and deletions. CX Codex +1 ★ 165repo stars lsp-fix-all Walks every diagnostic in a file and applies the quick-fixes your language server offers. Handy when errors and warnings have piled up before you start new work. CX Codex +1 ★ 165repo stars lsp-dead-code The skill lists exported symbols in a file and checks each one for references across the workspace. Useful when you want to know which exports are safe to drop. CX Codex +1 ★ 165repo stars lsp-architecture Produces a structural overview of a repository: languages, packages, entry points, dependency flow and hotspot files. One call instead of a manual sweep. CX Codex +1 ★ 165repo stars agent-lsp Coordinates language servers into 65 agent tools across 32 languages, keeping project indexes warm and testing edits in memory. CX Codex +1 ★ 165repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor