Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Semantic code analysis via LSP. Navigate code (definitions, references, implementations), search symbols, preview refactorings, and get file outlines. Use for exploring unfamiliar codebases or performing safe refactoring.
.claude/skills/mkurman-lsp-code-analysis/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 143% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 5% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 93% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 75% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 247% | 0% |
------------- | ---------------- | ----------------------------------------------- | | Find Definition | grep, read | definition | | Find Usages | grep -r | reference | | Understand File | read | outline | | View Docs/Types | read | doc | | Refactor | sed | See Refactoring Guide |
All commands support -h or --help.
Most commands use a unified locating syntax via the --scope and --find options.
Arguments: <file_path>
Options:
--scope: Narrow search to a symbol body or line range.--find: Text pattern to find within the scope.Scope Formats:
<line>: Single line number (e.g., 42).<start>,<end>: Line range (e.g., 10,20). Use 0 for end to mean till EOF (e.g., 10,0).<symbol_path>: Symbol path with dots (e.g., MyClass.my_method).Find Pattern (--find):
The --find option narrows the target to a text pattern within the selected scope:
--scope (line/range/symbol). If no --scope is given, the entire file is the scope.<|> inside the pattern to specify the exact position of interest within the match (for example, on a variable name, keyword, or operator).--find is omitted, the command uses the start of the scope (or a tool-specific default) as the navigation target.Cursor Marker (<|>):
The <|> marker indicates the exact position for symbol resolution. It represents the character immediately to its right. Use it within the find pattern to point to a specific element (e.g., user.<|>name to target the name property).
Examples:
lsp doc foo.py --find "self.<|>" - Find self. in entire file, position at the character after the dot (typically for completion or member access)lsp doc foo.py --scope 42 --find "return <|>result" - Find return result on line 42, position at r of resultlsp doc foo.py --scope 10,20 --find "if <|>condition" - Find if condition in lines 10-20, position at c of conditionlsp doc foo.py --scope MyClass.my_method --find "self.<|>" - Find self. within MyClass.my_method, position after the dotlsp doc foo.py --scope MyClass - Target the MyClass symbol directlyGuideline for Scope vs. Find:
--scope <symbol_path> (e.g., --scope MyClass, --scope MyClass.my_method) to target classes, functions, or methods. This is the most robust and preferred way to target symbol.--find (often combined with --scope) to target variables or specific positions. Use this when the target is not a uniquely named symbol or when you need to pinpoint a specific usage within a code block.Agents MAY use lsp locate <file_path> --scope <scope> --find <find> to verify if the target exists in the file and view its context before running other commands.
bash# Verify location exists lsp locate main.py --scope 42 --find "<|>process_data"
Use pagination for large result sets like reference or search.
--pagination-id <ID>: (Required) Unique session ID for consistent paging.--max-items <N>: Page size.--start-index <N>: Offset (0-based).Example:
bash# Page 1 lsp search "User" --max-items 20 --pagination-id "task_123" # Page 2 lsp search "User" --max-items 20 --start-index 20 --pagination-id "task_123"
Guideline: Use pagination with a unique ID for common symbols to fetch results in manageable chunks. Increment --start-index using the same ID to browse.
Get hierarchical symbol structure without reading implementation.
bash# Get main symbols (classes, functions, methods) lsp outline <file_path> # Get all symbols including variables and parameters lsp outline <file_path> --all
Agents SHOULD use outline before reading files to avoid unnecessary context consumption.
Navigate to where symbols are defined.
bash# Jump to where User.get_id is defined lsp definition models.py --scope User.get_id # Find where an imported variable comes from lsp definition main.py --scope 42 --find "<|>config" # Find declaration (e.g., header files, interface declarations) lsp definition models.py --scope 25 --mode declaration --find "<|>provider" # Find the class definition of a variable's type lsp definition models.py --scope 30 --find "<|>user" --mode type_definition
Find where symbols are used or implemented.
bash# Find all places where logger is referenced lsp reference main.py --scope MyClass.run --find "<|>logger" # Find all concrete implementations of an interface/abstract class lsp reference api.py --scope "IDataProvider" --mode implementations # Get more surrounding code context for each reference lsp reference app.py --scope 10 --find "<|>my_var" --context-lines 5 # Limit results for large codebases lsp reference utils.py --find "<|>helper" --max-items 50 --start-index 0
Get documentation and type information without navigating to source.
bash# Get docstring and type info for symbol at line 42 lsp doc main.py --scope 42 # Get API documentation for process_data function lsp doc models.py --scope process_data
Agents SHOULD prefer doc over read when only documentation or type information is needed.
Search for symbols across the workspace when location is unknown.
bash# Search by name (defaults to current directory) lsp search "MyClassName" # Search in specific project lsp search "UserModel" --project /path/to/project # Filter by symbol kind (can specify multiple times) lsp search "init" --kinds function --kinds method # Limit and paginate results for large codebases lsp search "Config" --max-items 10 lsp search "User" --max-items 20 --start-index 0
Agents SHOULD use --kinds to filter results and reduce noise.
Get the full source code of the symbol containing a location.
bash# Get complete code of the function/class at line 15 lsp symbol main.py --scope 15 # Get full UserClass implementation lsp symbol utils.py --scope UserClass # Get complete method implementation lsp symbol models.py --scope User.validate
Response includes: symbol name, kind (class/function/method), range, and complete source code.
Agents SHOULD use symbol to read targeted code blocks instead of using read on entire files.
Read Refactoring Guide for rename, extract, and other safe refactoring operations.
The background manager starts automatically. Manual control is OPTIONAL.
bash# List running servers lsp server list # Start server for a project lsp server start <path> # Stop server for a project lsp server stop <path> # Shutdown the background manager lsp server shutdown
The RECOMMENDED sequence for exploring new codebases:
bash# Step 1: Start with outline - Get file structure without reading implementation lsp outline <file_path> # Step 2: Inspect signatures - Use doc to understand API contracts lsp doc <file_path> --scope <symbol_name> # Step 3: Navigate dependencies - Follow definition chains lsp definition <file_path> --scope <symbol_name> # Step 4: Map usage - Find where code is called with reference lsp reference <file_path> --scope <symbol_name>
bash# Step 1: Locate symbol definition workspace-wide lsp search "<symbol_name>" # Step 2: Verify implementation details lsp definition <file_path> --scope <symbol_name> # Step 3: Trace all callers to understand invocation context lsp reference <file_path> --scope <symbol_name>
bash# Step 1: Locate interface definition lsp search "IUserService" --kinds interface # Step 2: Find all implementations lsp reference src/interfaces.py --scope IUserService --mode implementations
bash# Step 1: Find where data is created lsp search UserDTO --kinds class # Step 2: Find where it's used lsp reference models.py --scope UserDTO # Step 3: Check transformations lsp doc transform.py --scope map_to_dto
bash# Step 1: Get class outline lsp outline models.py # Step 2: Find subclasses (references to base) lsp reference models.py --scope BaseModel # Step 3: Check type definitions lsp definition models.py --scope BaseModel --mode type_definition
bash# Use outline instead of reading entire files lsp outline large_file.py # Better than: read large_file.py # Use symbol paths for nested structures (more precise than line numbers) lsp definition models.py --scope User.Profile.validate # Limit results in large codebases lsp search "User" --max-items 20 # Use doc to understand APIs without navigating to source lsp doc api.py --scope fetch_data # Get docs/types without jumping to definition # Verify locate strings if commands fail lsp locate main.py --scope 42 --find "<|>my_var"
For specialized scenarios, see:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 6,587 | 7,985 | +21% | 1 | 1 | 0% | 1,111 | 2,705 | +143% | 0 | 0 | — |
case-02 | fail→fail | 5,024 | 13,450 | +168% | 1 | 1 | 0% | 841 | 2,905 | +245% | 0 | 0 | — |
case-03 | fail→pass | 15,196 | 3,596 | -76% | 1 | 1 | 0% | 2,595 | 2,728 | +5% | 0 | 0 | — |
case-04 | fail→pass | 8,504 | 2,973 | -65% | 1 | 1 | 0% | 1,508 | 2,908 | +93% | 0 | 0 | — |
case-05 | fail→pass | 10,525 | 3,067 | -71% | 1 | 1 | 0% | 1,780 | 3,112 | +75% | 0 | 0 | — |
case-06 | fail→pass | 4,663 | 2,222 | -52% | 1 | 1 | 0% | 847 | 2,936 | +247% | 0 | 0 | — |
case-07 | pass→pass | 13,565 | 2,348 | -83% | 1 | 1 | 0% | 2,386 | 2,956 | +24% | 0 | 0 | — |
case-08 | fail→pass | 10,771 | 1,959 | -82% | 1 | 1 | 0% | 1,968 | 2,904 | +48% | 0 | 0 | — |
case-09 | fail→pass | 8,174 | 3,407 | -58% | 1 | 1 | 0% | 1,360 | 3,146 | +131% | 0 | 0 | — |
case-10 | fail→pass | 10,776 | 2,625 | -76% | 1 | 1 | 0% | 1,780 | 2,987 | +68% | 0 | 0 | — |
case-11 | fail→pass | 8,982 | 2,172 | -76% | 1 | 1 | 0% | 1,634 | 2,904 | +78% | 0 | 0 | — |
case-12 | fail→pass | 9,484 | 1,863 | -80% | 1 | 1 | 0% | 1,581 | 2,832 | +79% | 0 | 0 | — |
case-13 | fail→pass | 7,833 | 3,669 | -53% | 1 | 1 | 0% | 1,362 | 3,118 | +129% | 0 | 0 | — |
case-14 | fail→pass | 7,084 | 1,998 | -72% | 1 | 1 | 0% | 1,201 | 2,864 | +138% | 0 | 0 | — |
case-15 | fail→pass | 13,797 | 1,588 | -88% | 1 | 1 | 0% | 2,341 | 2,737 | +17% | 0 | 0 | — |
case-16 | fail→pass | 8,120 | 2,910 | -64% | 1 | 1 | 0% | 1,293 | 3,016 | +133% | 0 | 0 | — |
case-17 | fail→pass | 5,154 | 2,306 | -55% | 1 | 1 | 0% | 829 | 2,908 | +251% | 0 | 0 | — |
case-18 | fail→pass | 5,364 | 1,921 | -64% | 1 | 1 | 0% | 867 | 2,871 | +231% | 0 | 0 | — |
case-19 | fail→pass | 12,640 | 1,689 | -87% | 1 | 1 | 0% | 2,029 | 2,807 | +38% | 0 | 0 | — |
case-20 | pass→pass | 3,776 | 2,379 | -37% | 1 | 1 | 0% | 670 | 2,955 | +341% | 0 | 0 | — |
case-21 | pass→pass | 4,790 | 2,362 | -51% | 1 | 1 | 0% | 638 | 2,841 | +345% | 0 | 0 | — |
case-22 | pass→pass | 4,485 | 3,067 | -32% | 1 | 1 | 0% | 790 | 3,085 | +291% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +77 percentage points is the difference between those two pass rates over the 21 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.