Skip to content

Commit e864b42

Browse files
committed
Update cpp-language-service-tools.instructions
1 parent c1931fa commit e864b42

1 file changed

Lines changed: 18 additions & 53 deletions

File tree

instructions/cpp-language-service-tools.instructions.md

Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,32 @@ applyTo: **/*.cpp, **/*.h, **/*.hpp, **/*.cc, **/*.cxx, **/*.c
66

77
You have access to three specialized C++ tools:
88

9-
1. **`GetSymbolInfo_CppTools`** - Find symbol definitions and get type details
9+
1. **`GetSymbolInfo_CppTools`** - Find symbol definitions and get type information
1010
2. **`GetSymbolReferences_CppTools`** - Find ALL references to a symbol
1111
3. **`GetSymbolCallHierarchy_CppTools`** - Analyze function call relationships
1212

1313
---
1414

1515
## Mandatory Tool Usage Rules
1616

17-
### Rule 1: ALWAYS Use GetSymbolReferences_CppTools for Symbol Usages
17+
### Rule 1: Prefer GetSymbolReferences_CppTools as the default for locating C/C++ Symbol Usages
1818

19-
**NEVER** rely on manual code inspection, `vscode_listCodeUsages`, `grep_search`, or `read_file` to find where a symbol is used.
19+
**DO NOT** rely on text-based search tools such as `vscode_listCodeUsages`, `grep_search`, or `read_file`. Only if GetSymbolReferences_CppTools is unavailable, fails, or appears incomplete, resort to these text-based search tools as a fallback.
2020

2121
**ALWAYS** call `GetSymbolReferences_CppTools` when:
22-
- Renaming any symbol (function, variable, class, method, etc.)
22+
- Any task involving "find all references/usages/uses"
2323
- Changing function signatures
2424
- Refactoring code
2525
- Understanding symbol impact
26-
- Finding all call sites
2726
- Identifying usage patterns
28-
- Any task involving "find all uses/usages/references/calls"
2927

3028
**Why**: `GetSymbolReferences_CppTools` uses C++ IntelliSense and understands:
31-
- Overloaded functions
32-
- Template instantiations
29+
- Differentiating between overloaded functions
30+
- Differentiating between template instantiations
3331
- Qualified vs unqualified names
3432
- Member function calls
3533
- Inherited member usage
36-
- Preprocessor-conditional code
34+
- Preprocessor conditionals for the active configuration
3735

3836
Text search tools will miss these or produce false positives.
3937

@@ -54,9 +52,7 @@ Before modifying any function signature, **ALWAYS** call `GetSymbolCallHierarchy
5452

5553
Before working with unfamiliar code, **ALWAYS** call `GetSymbolInfo_CppTools` to:
5654
- Find where a symbol is defined
57-
- Understand class/struct memory layout
5855
- Get type information
59-
- Locate declarations
6056

6157
**NEVER** assume you know what a symbol is without checking.
6258

@@ -91,27 +87,12 @@ Before working with unfamiliar code, **ALWAYS** call `GetSymbolInfo_CppTools` to
9187
Start with minimal information and add more only if needed:
9288
1. **First attempt**: Symbol name only
9389
2. **If ambiguous**: Symbol name + file path
94-
3. **If still ambiguous**: Symbol name + file path + line number (after using `read_file`)
90+
3. **If still ambiguous**: Symbol name + file path + line number (after using `read_file` workflow mentioned above)
9591

9692
---
9793

9894
## Common Workflows
9995

100-
### Renaming a Symbol
101-
102-
```
103-
CORRECT workflow:
104-
1. Call GetSymbolReferences_CppTools with symbol name (and file path if available)
105-
2. Review ALL references returned
106-
3. Update symbol at definition location
107-
4. Update symbol at ALL reference locations
108-
109-
INCORRECT workflow:
110-
❌ Using vscode_listCodeUsages or grep_search to find usages
111-
❌ Manually inspecting a few files
112-
❌ Assuming you know all the usages
113-
```
114-
11596
### Changing a Function Signature
11697

11798
```
@@ -133,8 +114,8 @@ INCORRECT workflow:
133114
```
134115
CORRECT workflow:
135116
1. Call GetSymbolInfo_CppTools on key types/functions to understand definitions
136-
3. Call GetSymbolCallHierarchy_CppTools with callsFrom=true to understand what a function does
137-
4. Call GetSymbolCallHierarchy_CppTools with callsFrom=false to understand where a function is used
117+
2. Call GetSymbolCallHierarchy_CppTools with callsFrom=true to understand what a function does
118+
3. Call GetSymbolCallHierarchy_CppTools with callsFrom=false to understand where a function is used
138119
139120
INCORRECT workflow:
140121
❌ Reading code manually without tool assistance
@@ -219,15 +200,16 @@ This is NOT an error - it means:
219200
### DO:
220201
- ✅ Call `GetSymbolReferences_CppTools` for ANY symbol usage search
221202
- ✅ Call `GetSymbolCallHierarchy_CppTools` before function signature changes
222-
- ✅ Use `read_file` to find line numbers before specifying them
203+
- ✅ Use `read_file` to find line numbers before specifying them### Rule 1: Prefer GetSymbolReferences_CppTools as the default for locating C/C++ Symbol Usages
204+
- ✅ Prefer C++ tools as the default. Rely on text-based search tools only as a fallback if C++ tools are unavailable, fail, or appear incomplete.
223205
- ✅ Provide absolute file paths when available
224206
- ✅ Follow error message instructions exactly
225207
- ✅ Trust tool results over manual inspection
226208
- ✅ Use minimal parameters first, add more if needed
227209
- ✅ Remember line numbers are 1-based
228210

229211
### DO NOT:
230-
-Use `vscode_listCodeUsages`, `grep_search`, or `read_file` to find symbol usages
212+
-Rely on text-based search tools such as `vscode_listCodeUsages`, `grep_search`, or `read_file` to find symbol usages
231213
- ❌ Manually inspect code to find references
232214
- ❌ Guess line numbers
233215
- ❌ Assume symbol uniqueness without checking
@@ -241,24 +223,7 @@ This is NOT an error - it means:
241223

242224
## Examples of Correct Usage
243225

244-
### Example 1: User asks to rename a function
245-
```
246-
User: "Rename the function ProcessData to HandleData"
247-
248-
CORRECT response:
249-
1. Call GetSymbolReferences_CppTools("ProcessData")
250-
2. Review all reference locations
251-
3. Update function definition
252-
4. Update all call sites shown in results
253-
5. Confirm all changes made
254-
255-
INCORRECT response:
256-
❌ Using grep_search to find "ProcessData"
257-
❌ Only updating files the user mentioned
258-
❌ Assuming you found all usages manually
259-
```
260-
261-
### Example 2: User asks to add a parameter to a function
226+
### Example 1: User asks to add a parameter to a function
262227
```
263228
User: "Add a parameter 'bool verbose' to the LogMessage function"
264229
@@ -275,7 +240,7 @@ INCORRECT response:
275240
❌ Not using call_hierarchy tool
276241
```
277242

278-
### Example 3: User asks to understand a function
243+
### Example 2: User asks to understand a function
279244
```
280245
User: "What does the Initialize function do?"
281246
@@ -308,7 +273,7 @@ INCORRECT response:
308273
### Understanding Results
309274
- **Empty results are valid**: "No results found" means the symbol has no references/calls
310275
- **Multiple results are common**: C++ has overloading, templates, namespaces
311-
- **Trust the tools**: IntelliSense knows C++ semantics better than text search
276+
- **Trust the tools**: IntelliSense knows C++ semantics better than text-based search tools
312277

313278
---
314279

@@ -323,7 +288,7 @@ INCORRECT response:
323288
- Finding string literals or comments
324289
- Searching non-C++ files
325290
- Pattern matching in configuration files
326-
- **NEVER** for finding C++ symbol usages
291+
- **NEVER** for finding C++ symbol usages unless GetSymbolReferences_CppTools is unavailable, fails, or appears incomplete
327292

328293
### When to use semantic_search
329294
- Finding code based on conceptual queries
@@ -341,6 +306,6 @@ INCORRECT response:
341306
2. **Function calls?**`GetSymbolCallHierarchy_CppTools`
342307
3. **Symbol definition?**`GetSymbolInfo_CppTools`
343308

344-
These tools are your primary interface to C++ code understanding. Use them liberally and often. They are fast, accurate, and understand C++ semantics that text search cannot capture.
309+
These tools are your primary interface to C++ code understanding. Use them liberally and often. They are fast, accurate, and understand C++ semantics that text-based search tools cannot capture.
345310

346311
**Your success metric**: Did I use the right C++ tool for every symbol-related task?

0 commit comments

Comments
 (0)