Skip to content

Commit 7db402e

Browse files
committed
add lsp to claude code
1 parent a9c62b5 commit 7db402e

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,78 @@ iceberg-rust-spec (pure specification types)
1515

1616
**Core Philosophy:** Deep modules with simple interfaces (John Ousterhout's "A Philosophy of Software Design")
1717

18+
## LSP-Based Codebase Navigation
19+
20+
**IMPORTANT:** When an LSP (Language Server Protocol) MCP server is available (such as `rust-analyzer`), **ALWAYS prefer LSP tools over text-based search** for code navigation and analysis.
21+
22+
### When to Use LSP Tools
23+
24+
Use LSP tools for:
25+
- **Finding definitions:** `get_symbol_definitions` instead of grepping for function/type names
26+
- **Finding references:** `get_symbol_references` instead of searching for usage
27+
- **Type information:** `get_hover` for accurate type and documentation
28+
- **Code structure:** `get_symbols` for understanding module organization
29+
- **Implementations:** `get_implementations` for finding trait implementations
30+
- **Call hierarchy:** `get_call_hierarchy` for understanding call relationships
31+
- **Diagnostics:** `get_diagnostics` for compiler errors and warnings
32+
- **Completions:** `get_completions` for valid code suggestions
33+
34+
### Why LSP Over Text Search
35+
36+
**LSP Advantages:**
37+
- **Semantic understanding:** Knows about scopes, types, and language semantics
38+
- **Accurate references:** Distinguishes between `Result` (std) vs `Result` (custom type)
39+
- **Cross-file navigation:** Follows imports and module boundaries correctly
40+
- **Type-aware:** Understands trait bounds, generic parameters, associated types
41+
- **Compiler-backed:** Uses the same analysis as the compiler
42+
43+
**When Text Search is Appropriate:**
44+
- Finding string literals or comments
45+
- Pattern-based searches across multiple file types
46+
- Exploratory searches when you don't know exact symbols
47+
- Searching in non-code files (markdown, configs, etc.)
48+
49+
### Common LSP Workflows
50+
51+
**Understanding a function:**
52+
```
53+
1. get_symbol_definitions (find where it's defined)
54+
2. get_hover (see type signature and docs)
55+
3. get_symbol_references (see where it's used)
56+
```
57+
58+
**Exploring a trait:**
59+
```
60+
1. get_symbol_definitions (find trait definition)
61+
2. get_implementations (find all implementations)
62+
3. get_type_hierarchy (understand inheritance)
63+
```
64+
65+
**Fixing errors:**
66+
```
67+
1. get_diagnostics (get all errors/warnings)
68+
2. get_code_actions (get automated fixes)
69+
3. get_hover (understand type mismatches)
70+
```
71+
72+
### Integration with Development
73+
74+
Before modifying code:
75+
1. Use `get_symbol_definitions` to find the target
76+
2. Use `get_hover` to understand types and contracts
77+
3. Use `get_symbol_references` to assess impact
78+
4. Make changes with full context
79+
80+
**Example Decision Tree:**
81+
```
82+
Need to understand code structure? → get_symbols
83+
Need to find where something is defined? → get_symbol_definitions
84+
Need to find all usages? → get_symbol_references
85+
Need to understand types? → get_hover
86+
Need to find trait impls? → get_implementations
87+
Searching for text/patterns? → Grep/text search
88+
```
89+
1890
### Deep vs Shallow Modules
1991

2092
**Deep Modules** = Powerful functionality + Simple interface

0 commit comments

Comments
 (0)