Skip to content

Commit bdc06ce

Browse files
Update cpp-language-service-tools.instructions (#1917)
1 parent 6e686c6 commit bdc06ce

1 file changed

Lines changed: 18 additions & 59 deletions

File tree

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

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,32 @@ applyTo: "**/*.cpp, **/*.h, **/*.hpp, **/*.cc, **/*.cxx, **/*.c"
77

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

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

1414
---
1515

1616
## Mandatory Tool Usage Rules
1717

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

20-
**NEVER** rely on manual code inspection, `vscode_listCodeUsages`, `grep_search`, or `read_file` to find where a symbol is used.
20+
**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.
2121

2222
**ALWAYS** call `GetSymbolReferences_CppTools` when:
23-
24-
- Renaming any symbol (function, variable, class, method, etc.)
23+
- Any task involving "find all references/usages/uses"
2524
- Changing function signatures
2625
- Refactoring code
2726
- Understanding symbol impact
28-
- Finding all call sites
2927
- Identifying usage patterns
30-
- Any task involving "find all uses/usages/references/calls"
3128

3229
**Why**: `GetSymbolReferences_CppTools` uses C++ IntelliSense and understands:
33-
34-
- Overloaded functions
35-
- Template instantiations
30+
- Differentiating between overloaded functions
31+
- Differentiating between template instantiations
3632
- Qualified vs unqualified names
3733
- Member function calls
3834
- Inherited member usage
39-
- Preprocessor-conditional code
35+
- Preprocessor conditionals for the active configuration
4036

4137
Text search tools will miss these or produce false positives.
4238

@@ -59,9 +55,7 @@ Before modifying any function signature, **ALWAYS** call `GetSymbolCallHierarchy
5955
Before working with unfamiliar code, **ALWAYS** call `GetSymbolInfo_CppTools` to:
6056

6157
- Find where a symbol is defined
62-
- Understand class/struct memory layout
6358
- Get type information
64-
- Locate declarations
6559

6660
**NEVER** assume you know what a symbol is without checking.
6761

@@ -101,27 +95,12 @@ Start with minimal information and add more only if needed:
10195

10296
1. **First attempt**: Symbol name only
10397
2. **If ambiguous**: Symbol name + file path
104-
3. **If still ambiguous**: Symbol name + file path + line number (after using `read_file`)
98+
3. **If still ambiguous**: Symbol name + file path + line number (after using `read_file` workflow mentioned above)
10599

106100
---
107101

108102
## Common Workflows
109103

110-
### Renaming a Symbol
111-
112-
```
113-
CORRECT workflow:
114-
1. Call GetSymbolReferences_CppTools with symbol name (and file path if available)
115-
2. Review ALL references returned
116-
3. Update symbol at definition location
117-
4. Update symbol at ALL reference locations
118-
119-
INCORRECT workflow:
120-
❌ Using vscode_listCodeUsages or grep_search to find usages
121-
❌ Manually inspecting a few files
122-
❌ Assuming you know all the usages
123-
```
124-
125104
### Changing a Function Signature
126105

127106
```
@@ -143,8 +122,8 @@ INCORRECT workflow:
143122
```
144123
CORRECT workflow:
145124
1. Call GetSymbolInfo_CppTools on key types/functions to understand definitions
146-
3. Call GetSymbolCallHierarchy_CppTools with callsFrom=true to understand what a function does
147-
4. Call GetSymbolCallHierarchy_CppTools with callsFrom=false to understand where a function is used
125+
2. Call GetSymbolCallHierarchy_CppTools with callsFrom=true to understand what a function does
126+
3. Call GetSymbolCallHierarchy_CppTools with callsFrom=false to understand where a function is used
148127
149128
INCORRECT workflow:
150129
❌ Reading code manually without tool assistance
@@ -236,16 +215,16 @@ This is NOT an error - it means:
236215

237216
- ✅ Call `GetSymbolReferences_CppTools` for ANY symbol usage search
238217
- ✅ Call `GetSymbolCallHierarchy_CppTools` before function signature changes
239-
- ✅ Use `read_file` to find line numbers before specifying them
218+
- ✅ Use `read_file` to find line numbers before specifying them### Rule 1: Prefer GetSymbolReferences_CppTools as the default for locating C/C++ Symbol Usages
219+
- ✅ 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.
240220
- ✅ Provide absolute file paths when available
241221
- ✅ Follow error message instructions exactly
242222
- ✅ Trust tool results over manual inspection
243223
- ✅ Use minimal parameters first, add more if needed
244224
- ✅ Remember line numbers are 1-based
245225

246226
### DO NOT:
247-
248-
- ❌ Use `vscode_listCodeUsages`, `grep_search`, or `read_file` to find symbol usages
227+
- ❌ Rely on text-based search tools such as `vscode_listCodeUsages`, `grep_search`, or `read_file` to find symbol usages
249228
- ❌ Manually inspect code to find references
250229
- ❌ Guess line numbers
251230
- ❌ Assume symbol uniqueness without checking
@@ -259,26 +238,7 @@ This is NOT an error - it means:
259238

260239
## Examples of Correct Usage
261240

262-
### Example 1: User asks to rename a function
263-
264-
```
265-
User: "Rename the function ProcessData to HandleData"
266-
267-
CORRECT response:
268-
1. Call GetSymbolReferences_CppTools("ProcessData")
269-
2. Review all reference locations
270-
3. Update function definition
271-
4. Update all call sites shown in results
272-
5. Confirm all changes made
273-
274-
INCORRECT response:
275-
❌ Using grep_search to find "ProcessData"
276-
❌ Only updating files the user mentioned
277-
❌ Assuming you found all usages manually
278-
```
279-
280-
### Example 2: User asks to add a parameter to a function
281-
241+
### Example 1: User asks to add a parameter to a function
282242
```
283243
User: "Add a parameter 'bool verbose' to the LogMessage function"
284244
@@ -295,8 +255,7 @@ INCORRECT response:
295255
❌ Not using call_hierarchy tool
296256
```
297257

298-
### Example 3: User asks to understand a function
299-
258+
### Example 2: User asks to understand a function
300259
```
301260
User: "What does the Initialize function do?"
302261
@@ -332,7 +291,7 @@ INCORRECT response:
332291

333292
- **Empty results are valid**: "No results found" means the symbol has no references/calls
334293
- **Multiple results are common**: C++ has overloading, templates, namespaces
335-
- **Trust the tools**: IntelliSense knows C++ semantics better than text search
294+
- **Trust the tools**: IntelliSense knows C++ semantics better than text-based search tools
336295

337296
---
338297

@@ -349,7 +308,7 @@ INCORRECT response:
349308
- Finding string literals or comments
350309
- Searching non-C++ files
351310
- Pattern matching in configuration files
352-
- **NEVER** for finding C++ symbol usages
311+
- **NEVER** for finding C++ symbol usages unless GetSymbolReferences_CppTools is unavailable, fails, or appears incomplete
353312

354313
### When to use semantic_search
355314

@@ -368,6 +327,6 @@ INCORRECT response:
368327
2. **Function calls?**`GetSymbolCallHierarchy_CppTools`
369328
3. **Symbol definition?**`GetSymbolInfo_CppTools`
370329

371-
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.
330+
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.
372331

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

0 commit comments

Comments
 (0)