Loading...
Loading...
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.
npx skill4agent add lsp-client/lsp-skill lsp-code-analysislsp server start <project_path>lsp-code-analysislspreadgrepreadgrep| Task | Traditional Tool | Recommended LSP Command |
|---|---|---|
| Find Definition | | |
| Find Usages | | |
| Understand File | | |
| View Docs/Types | | |
| Refactor | | See Refactoring Guide |
-h--help--scope--find<file_path>--scope--find<line>42<start>,<end>10,20010,0<symbol_path>MyClass.my_method--find--find--scope--scope<|>--find<|><|>user.<|>namenamelsp doc foo.py --find "self.<|>"self.lsp doc foo.py --scope 42 --find "return <|>result"return resultrresultlsp doc foo.py --scope 10,20 --find "if <|>condition"if conditioncconditionlsp doc foo.py --scope MyClass.my_method --find "self.<|>"self.MyClass.my_methodlsp doc foo.py --scope MyClassMyClass--scope <symbol_path>--scope MyClass--scope MyClass.my_method--find--scopelsp locate <file_path> --scope <scope> --find <find># Verify location exists
lsp locate main.py --scope 42 --find "<|>process_data"referencesearch--pagination-id <ID>--max-items <N>--start-index <N># 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"--start-index# Get main symbols (classes, functions, methods)
lsp outline <file_path>
# Get all symbols including variables and parameters
lsp outline <file_path> --alloutline# 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 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 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_datadocread# 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--kinds# 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.validatesymbolread# 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# 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># 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># Step 1: Locate interface definition
lsp search "IUserService" --kinds interface
# Step 2: Find all implementations
lsp reference src/interfaces.py --scope IUserService --mode implementations# 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# 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# 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"