---
name: lsp-guide
description: Recipes for the lsp tool — resolving where a symbol is defined, every place it is used, type signatures and docs, file outlines, and compiler/type errors through a real language server (Go, TypeScript/JavaScript, Python, Rust). Use when navigating or explaining code by symbol, finding callers or usages, checking what broke after an edit, or deciding between lsp and text search.
title: lsp-guide
canonical_url: https://skilld.dev/gh/weave-os/router/lsp-guide
last_updated: 2026-10-20T08:46:19.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install weave-os/router/lsp-guide`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/lsp-guide`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/weave-os/router/lsp-guide) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/lsp-guide`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/lsp-guide --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/lsp-guide --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Using the lsp tool

The `lsp` tool answers *semantic* questions through the language's own server:
it resolves through imports, types, and aliases, where grep only matches text.
Reach for it whenever the question is about a **symbol**; keep grep for plain
strings, comments, and file types no server supports.

## Operations

| Operation | Answers | Needs |
|---|---|---|
| `definition` | where the symbol at a position is defined | `path`, `line`, `column` |
| `references` | every place the symbol at a position is used | `path`, `line`, `column` |
| `hover` | type signature + docs for the symbol at a position | `path`, `line`, `column` |
| `documentSymbol` | the outline (types, functions, methods) of one file | `path` |
| `diagnostics` | compiler/type errors and warnings for one file | `path` |

Positions are 1-based, and `column` must point **at the identifier** (its first
character works). All paths resolve against the working directory.

## Recipes

**"Where is X defined?"** — from any usage site of X:
`{"operation": "definition", "path": "<file>", "line": <L>, "column": <C>}`.
Don't know a usage site? Find one first (see next recipe's step 1).

**"Everywhere X is used"** — two steps, always:

1. Locate the declaration: `rg -n --column '\bX\b'` (the `--column` output is
   exactly the coordinate the next call needs), or `documentSymbol` when you
   already know the file.
2. `{"operation": "references", "path": "<decl file>", "line": <L>, "column": <C>}`.

A grep hit list is **not** a references answer: it includes comments and
strings, misses aliased imports, and can't distinguish same-named symbols.
Step 2 is what makes the answer authoritative.

**"What is this / what's its signature?"** — `hover` at the symbol. Prefer it
over reading the definition file when you only need the type or doc comment.

**"What's in this file?"** — `documentSymbol` before reading a large file; jump
straight to the line the outline gives you.

**"Did my edit break anything here?"** — `diagnostics` on the file after
editing. It reports the server's current analysis of the saved file.

## Behavior worth knowing

- **First query per workspace is slow** (the server indexes — up to a minute
  in a big repo). Later queries on that workspace are fast; don't give up
  after one timeout, retry once.
- **References are capped** (default 100, header says how many exist).
- **Unsupported file type or missing server** returns advice text, not an
  error — fall back to grep for that file. A missing server can be installed
  with the user's consent via `lsp_enable` (see the install-lsps skill for
  toolchain prerequisites).
- Works inside dispatch subagents too (they share the parent's warm servers),
  so symbol lookups are safe to fan out.
