Agent skill

using-lsp-tools

Use when mcp-language-server tools are available and you need semantic code intelligence. Triggers: 'find definition', 'find references', 'who calls this', 'rename symbol', 'type hierarchy', 'go to definition', 'where is this used', 'where is this defined', 'what type is this'. Provides navigation, refactoring, and type analysis via LSP.

Stars 5
Forks 2

Install this agent skill to your Project

npx add-skill https://github.com/axiomantic/spellbook/tree/main/skills/using-lsp-tools

SKILL.md

Using LSP Tools

Invariant Principles

  1. Semantic > Lexical: LSP understands scope, types, inheritance. Grep sees text.
  2. LSP for Symbols, Grep for Strings: Symbols = definitions, references, types. Strings = TODOs, comments, literals.
  3. Verify Before Fallback: Empty LSP result? Check file saved. Then try text-based.
  4. Atomic Operations Preferred: rename_symbol handles all files. Manual Edit misses references.

Reasoning Schema

Inputs

Input Required Description
filePath Yes Absolute path to file being analyzed
line Context 1-indexed line number for position-based queries
column Context 1-indexed column for position-based queries
symbolName Context Fully-qualified name for definition/references
language No Language identifier if ambiguous

Outputs

Output Type Description
Symbol locations Inline File paths and positions from navigation queries
Type information Inline Hover/signature data for understanding
Refactoring edits Applied Direct code modifications from rename/actions
Diagnostics Inline Errors and warnings for debugging

Tool Priority Matrix

Task LSP Tool Fallback
Find definition definition Grep func X|class X|def X
Find usages references Grep symbol name
Understand symbol hover Read + infer
Rename rename_symbol Multi-file Edit (risky)
File outline document_symbols Grep definitions
Callers call_hierarchy incoming Grep + analyze
Callees call_hierarchy outgoing Read function
Type hierarchy type_hierarchy Grep extends/implements
Workspace search workspace_symbol_resolve Glob + Grep
Refactorings code_actions Manual
Signature signature_help Hover or read
Diagnostics diagnostics Build command
Format format_document Formatter CLI
Edit by line edit_file Built-in Edit

Parameters

Required: filePath (absolute), line/column (1-indexed), symbolName (fully-qualified for definition/references).

Decision Rules

Use LSP when:

  • Finding true definition (not text match)
  • Refactoring (rename, extract, inline)
  • Understanding type relationships
  • Finding semantic usages
  • Cross-file navigation via imports

Use Grep/Glob when:

  • Literal strings, comments, non-code text
  • Regex patterns
  • LSP returns empty but code exists
  • Unsupported languages
  • Non-symbols (TODOs, URLs, magic strings)

Workflows

Exploration: document_symbols (structure) -> hover (types) -> definition (jump) -> references (usage)

Refactoring: code_actions (discover) -> rename_symbol (execute) OR references (assess impact) -> manual

Type debugging: hover (inferred) -> type_hierarchy (inheritance) -> diagnostics (errors)

Call analysis: call_hierarchy incoming = "who calls?" | outgoing = "what calls?"

Anti-Patterns

Fallback Protocol

  1. LSP error/empty -> Check file saved (LSP reads disk)
  2. Try table fallback
  3. Persistent failure -> Feature unsupported by server

Self-Check

Before completing:

  • Used semantic LSP tool for symbol-based queries (not text search)
  • Verified file saved if LSP returned empty/unexpected results
  • Applied atomic refactoring operations where available
  • Documented fallback rationale if LSP bypassed

If ANY unchecked: STOP and reconsider approach.

Expand your agent's capabilities with these related and highly-rated skills.

axiomantic/spellbook

spellbook-auditing

Meta-audit skill for spellbook development. Spawns parallel subagents to factcheck docs, optimize instructions, find token savings, and identify MCP candidates. Produces actionable report.

5 2
Explore
axiomantic/spellbook

documentation-updates

Use after modifying library skills, library commands, or agents to ensure CHANGELOG, README, and docs are updated

5 2
Explore
axiomantic/spellbook

project-encyclopedia

[DEPRECATED] Use project-level AGENTS.md files instead. Previously used for first-session codebase onboarding and persistent glossary creation.

5 2
Explore
axiomantic/spellbook

reviewing-impl-plans

Use when reviewing implementation plans before execution. Triggers: 'is this plan solid', 'review the plan', 'check before I start building', 'anything missing from this plan', 'will this plan work', 'audit the implementation plan'. NOT for: reviewing design documents (use reviewing-design-docs) or creating plans (use writing-plans).

5 2
Explore
axiomantic/spellbook

session-resume

Session resume protocol and session repairs handling. Loaded when spellbook_session_init returns resume_available: true, or when session_init returns a repairs array. Triggers: 'resume', 'continue', 'where were we', session resume, session repairs.

5 2
Explore
axiomantic/spellbook

brainstorming

Use when exploring design approaches, generating ideas, or making architectural decisions. Triggers: 'explore options', 'what are the tradeoffs', 'how should I approach', 'let's think through', 'sketch out an approach', 'I need ideas for', 'how would you structure', 'what are my options'. Also invoked by develop when design decisions are needed.

5 2
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results