This skill should be loaded when working with Ruby files to understand when to use LSP operations (documentSymbol, findReferences, goToDefinition, hover) versus standard tools (Read, Grep)...
This project has Ruby LSP (shopify/ruby-lsp) integration enabled. Use the LSP tool proactively for Ruby code intelligence.
BEFORE Reading Any Ruby File, determine what information is needed:
Need file structure overview? ā documentSymbol ā Need to know what methods exist? ā documentSymbol ā Need method signatures? ā documentSymbol + Read ā (NOT hover - doesn't work on definitions) Need to understand class/module structure? ā documentSymbol ā Need to see where a method is defined? ā goToDefinition ā (from call site) Need to see where a method is used? ā findReferences ā (very detailed) Need quick signature from call site? ā hover ā (works on calls, not definitions) Need implementation details? ā Read ā Need to search across project? ā Grep ā (workspaceSymbol doesn't work)
Key Rule: documentSymbol for structure, Read for content, LSP for navigation.
| What You Need | Use This | NOT This |
|---|---|---|
| File structure overview | documentSymbol | Read entire file |
| Method signature | documentSymbol + Read | hover on definition (doesn't work) |
| Where method is defined | goToDefinition | Grep for "def method" |
| Where method is used | findReferences | Grep for method name |
| Cross-project search | Grep | workspaceSymbol (broken) |
| Quick signature from call | hover on call site | Navigate away |
| Implementation details | Read | documentSymbol (only gives structure) |
CRITICAL: Ruby LSP cannot extract signatures from method definitions.
ā BROKEN - Hover on definitions (this will never work):
Step 1: documentSymbol ā get "initialize" at line 41
Step 2: hover at line 41 ā Returns "No hover information available"
Why: Hover does NOT support Prism::DefNode (method definitions)
ā CORRECT - documentSymbol + Read:
Step 1: documentSymbol on file.rb ā get method list:
- process_payment at line 145
- validate_card at line 167
- charge_card at line 189
Step 2: Read file.rb offset=144 limit=5 ā see actual def:
def process_payment(amount, currency = 'USD', metadata = {})
validate_card(metadata[:card])
charge_card(amount, currency)
end
Result: Full signature without reading entire file
ā ALTERNATIVE - Hover on call site (if you have one):
Context: You see `processor.process_payment(100, 'EUR')` at line 89
Step 1: hover at that call site (on "process_payment")
Result: Shows signature from definition: process_payment(amount, currency = 'USD', metadata = {})
Limitation: Requires finding a call site first
Ruby LSP's ALLOWED_TARGETS:
This is by design. To get signatures from definitions, use documentSymbol + Read.
ā Wrong:
Task: Understand what's in this Ruby file
Assistant: [Reads entire file and manually parses for classes/methods]
ā Correct:
Task: Understand what's in this Ruby file
Step 1: documentSymbol ā get hierarchical structure
Result:
PaymentProcessor (Class) - Line 10
initialize (Constructor) - Line 12
process_payment (Method) - Line 145
validate_card (Method) - Line 167
Step 2: Read specific methods if needed
ā Wrong:
Task: Find all places where process_payment is called
Assistant: [Uses Grep to search for "process_payment" as text]
ā Correct:
Task: Find all places where process_payment is called
Step 1: goToDefinition or documentSymbol ā find method at line 145
Step 2: findReferences at line 145
Result: Found 12 references:
app/controllers/payments_controller.rb:
Line 23:15
Line 67:11
lib/billing/processor.rb:
Line 89:27
[... detailed, semantic matches]
Use when you need:
Returns:
How to use:
LSP operation="documentSymbol" filePath="/absolute/path/file.rb" line=1 character=1
Note: line/character parameters are required but don't affect results - you always get all symbols.
Example:
Context: User asks "What methods are available in payment_processor.rb?"
LSP operation="documentSymbol" filePath="/app/payment_processor.rb" line=1 character=1
Returns:
PaymentProcessor (Class) - Line 10
initialize (Constructor) - Line 12
process_payment (Method) - Line 145
validate_card (Method) - Line 167
charge_card (Method) - Line 189
Follow-up: Use Read with offset/limit to see specific method signatures.
Use when you need:
Returns:
How to use:
Context: Want to find all usages of log method at line 259
LSP operation="findReferences" filePath="/path/file.rb" line=259 character=7
Returns: Found 48 references across 3 files:
lib/journeys/brief_writer.rb:
Line 109:11
Line 117:7
scripts/generate_briefs.rb:
Line 143:27
Line 153:27
[... comprehensive list]
Example scenarios:
Context: About to rename or refactor process_payment method
Step 1: documentSymbol or goToDefinition ā find definition location
Step 2: findReferences at definition location
Result: All call sites across project for impact analysis
Use when you need:
Returns:
How to use:
Context: Line 143 has `log(msg)` call, need to see implementation
LSP operation="goToDefinition" filePath="/path/file.rb" line=143 character=27
Returns: Defined in scripts/generate_briefs.rb:259:7
Example scenarios:
Context: Looking at code that calls User.authenticate, need to see how it's implemented
Step 1: goToDefinition on authenticate call site
Result: Jumps to exact definition, even if in parent class or mixin
Don't use Grep to search for "def method_name" - goToDefinition understands inheritance.
CRITICAL: Hover is a LIMITED tool in Ruby. It works on usage sites, not definitions.
Works on:
user.save ā shows signaturePaymentProcessor ā shows class definition@user, @@class_var, $global ā shows where definedsuper, yieldDoes NOT work on:
def save ā no responseWhen to use: Reading code and encounter a method call to something defined in another file. Hover gives you quick signature without navigating away.
Example - The actual use case:
Context: You're reading payment_processor.rb and see:
validator.check_amount(amount)
You want to know check_amount's signature without navigating to validator.rb
LSP operation="hover" filePath="/app/payment_processor.rb" line=24 character=15
Returns:
check_amount(amount, options = {})
Definition: lib/validators/amount_validator.rb:45
Documentation: [if any exists]
This is useful but narrow - not a primary workflow tool.
When NOT to use:
Why hover is secondary:
LSP operations don't require line/character precision for most use cases:
documentSymbol:
goToDefinition:
findReferences:
hover:
Ruby LSP in Claude Code has 4 useful operations:
Get all symbols in a document
Find all references to a symbol
Find where a symbol is defined
Get information from call sites and constants
Use LSP operations proactively when:
documentSymbolgoToDefinitionfindReferenceshover (limited)Use standard tools when:
validator.check_amount(amount)Proactively use these 4 LSP operations throughout your Ruby development workflow for semantic code intelligence.