@@ -21,7 +21,7 @@ Thus, this prompt can be used in any environment where the query files are on di
2121## Prerequisites
2222
23231 . A CodeQL pack with ` codeql-pack.yml ` on disk
24- 2 . Dependencies installed via ` codeql_pack_install ` (pointing at the pack directory)
24+ 2 . Dependencies installed via # codeql_pack_install (pointing at the pack directory)
25253 . Query files saved to disk (LSP tools operate on files, not inline strings)
2626
2727## Key Concept: Positions Are File Path + Line + Character
@@ -37,12 +37,12 @@ containing `codeql-pack.yml`) for import resolution to work. Without it, complet
3737and definitions for imported libraries will be empty.
3838
3939> ** Critical** : LSP line/character positions are 0-based, but ` read_file ` ,
40- > ` find_predicate_position ` , and ` find_class_position ` return 1-based positions.
40+ > # find_predicate_position, and # find_class_position return 1-based positions.
4141> Always subtract 1 when passing their output to LSP tools.
4242
4343## Step 1: Discover Available Types with Completions
4444
45- Use ` codeql_lsp_completion ` to explore what types and predicates are available at any
45+ Use # codeql_lsp_completion to explore what types and predicates are available at any
4646position in a query file. This replaces manual documentation browsing.
4747
4848** Example** : To see what classes are available in a ` from ` clause after ` import javascript ` :
@@ -68,7 +68,7 @@ each with full signature and documentation.
6868
6969## Step 2: Navigate to Definitions
7070
71- Use ` codeql_lsp_definition ` to find where a class, predicate, or module is defined.
71+ Use # codeql_lsp_definition to find where a class, predicate, or module is defined.
7272This returns the file URI and line range of the definition — even into library pack
7373files you haven't opened.
7474
@@ -95,7 +95,7 @@ the source.
9595
9696## Step 3: Find All References
9797
98- Use ` codeql_lsp_references ` to find how a symbol is used across the workspace.
98+ Use # codeql_lsp_references to find how a symbol is used across the workspace.
9999
100100``` text
101101Tool: codeql_lsp_references
@@ -115,7 +115,7 @@ find real usage examples instead of guessing from documentation.
115115
116116## Step 4: Locate Symbols with Position Finders
117117
118- Use ` find_predicate_position ` and ` find_class_position ` to locate where a specific
118+ Use # find_predicate_position and # find_class_position to locate where a specific
119119symbol is defined in a file. These return ** 1-based** line/column positions.
120120
121121``` text
@@ -126,18 +126,18 @@ Parameters:
126126Returns: { start_line: 12, start_col: 13, end_line: 12, end_col: 20 }
127127```
128128
129- > ** Note** : ` find_class_position ` finds ` class ` definitions only — it does not find
130- > ` module ` definitions. Use ` find_predicate_position ` for predicates inside modules.
129+ > ** Note** : # find_class_position finds ` class ` definitions only — it does not find
130+ > ` module ` definitions. Use # find_predicate_position for predicates inside modules.
131131
132132** Combining with LSP tools** : To navigate to a predicate's definition in library code:
133133
134- 1 . Use ` find_predicate_position ` to get its 1-based position
134+ 1 . Use # find_predicate_position to get its 1-based position
1351352 . Subtract 1 from line/col to convert to 0-based
136- 3 . Pass to ` codeql_lsp_definition ` to jump to the underlying type
136+ 3 . Pass to # codeql_lsp_definition to jump to the underlying type
137137
138138## Step 5: Quick-Evaluate Individual Predicates
139139
140- Use ` quick_evaluate ` to evaluate a single predicate or class against a database
140+ Use # quick_evaluate to evaluate a single predicate or class against a database
141141without running the full query. This is the fastest way to debug whether a predicate
142142matches what you expect.
143143
@@ -151,27 +151,27 @@ Parameters:
151151```
152152
153153The tool evaluates just that symbol (predicate or class) and returns the result path.
154- Use ` codeql_bqrs_decode ` on the output to inspect results in CSV or JSON format.
154+ Use # codeql_bqrs_decode on the output to inspect results in CSV or JSON format.
155155
156156## Step 6: Validate at Multiple Levels
157157
158158Use the right validation tool for each situation:
159159
160- | Tool | Use When | Input | Resolves Imports? |
161- | ------------------------ | --------------------------------------- | ------------------ | ------------------- |
162- | ` validate_codeql_query ` | Quick structural check | Inline QL string | No (heuristic only) |
163- | ` codeql_lsp_diagnostics ` | Syntax/semantic validation of fragments | Inline QL string | No |
164- | ` codeql_query_compile ` | Full compilation check | On-disk ` .ql ` file | Yes |
165- | ` codeql_test_run ` | End-to-end result validation | Test directory | Yes |
160+ | Tool | Use When | Input | Resolves Imports? |
161+ | ----------------------- | --------------------------------------- | ------------------ | ------------------- |
162+ | # validate_codeql_query | Quick structural check | Inline QL string | No (heuristic only) |
163+ | # codeql_lsp_diagnostics | Syntax/semantic validation of fragments | Inline QL string | No |
164+ | # codeql_query_compile | Full compilation check | On-disk ` .ql ` file | Yes |
165+ | # codeql_test_run | End-to-end result validation | Test directory | Yes |
166166
167- ** ` codeql_lsp_diagnostics ` ** validates QL syntax and semantics for inline code snippets,
167+ ** # codeql_lsp_diagnostics** validates QL syntax and semantics for inline code snippets,
168168but ** cannot resolve ` import ` statements** (like ` import javascript ` ). Use it for:
169169
170170- Checking predicate signatures and QL syntax
171171- Verifying ` from ` /` where ` /` select ` clause structure
172172- Catching type errors in import-free QL fragments
173173
174- For queries with imports, always use ` codeql_query_compile ` on the saved file.
174+ For queries with imports, always use # codeql_query_compile on the saved file.
175175
176176## Iterative Development Loop
177177
@@ -202,7 +202,7 @@ This example shows the tools in action for building a JavaScript XSS query.
202202### 1. Create the query file and install dependencies
203203
204204Write a ` .ql ` file with ` import javascript ` and a skeleton ` from ` /` where ` /` select ` .
205- Run ` codeql_pack_install ` on the pack directory.
205+ Run # codeql_pack_install on the pack directory.
206206
207207### 2. Explore sink types
208208
@@ -245,14 +245,14 @@ quick_evaluate(file=..., db=test.testproj, symbol="isSink") → inspect result
245245
246246## Important Notes
247247
248- - ** All LSP tools use 0-based positions** . ` find_class_position ` and
249- ` find_predicate_position ` return 1-based positions. Convert before combining.
248+ - ** All LSP tools use 0-based positions** . # find_class_position and
249+ # find_predicate_position return 1-based positions. Convert before combining.
250250- ** ` workspace_uri ` must be the pack root** (the directory containing
251251 ` codeql-pack.yml ` ). Without it, completions and definitions will be empty.
252- - ** Run ` codeql_pack_install ` first** . LSP tools require resolved dependencies.
253- - ** ` codeql_lsp_diagnostics ` cannot resolve imports** . For ` import javascript `
254- and similar, use ` codeql_query_compile ` on the on-disk file instead.
255- - ** ` find_class_position ` finds ` class ` only** , not ` module ` definitions.
256- Use grep or ` find_predicate_position ` for predicates inside modules.
257- - ** ` codeql_lsp_references ` scope** depends on ` workspace_uri ` . Point it at
252+ - ** Run # codeql_pack_install first** . LSP tools require resolved dependencies.
253+ - ** # codeql_lsp_diagnostics cannot resolve imports** . For ` import javascript `
254+ and similar, use # codeql_query_compile on the on-disk file instead.
255+ - ** # find_class_position finds ` class ` only** , not ` module ` definitions.
256+ Use grep or # find_predicate_position for predicates inside modules.
257+ - ** # codeql_lsp_references scope** depends on ` workspace_uri ` . Point it at
258258 a library pack root to find usages across library code.
0 commit comments