Chat Query Types
This page lists all the query types that will return search results with the Sourcegraph chat.
Symbol Search
Symbol Search is a query type or workflow that helps developers understand how specific symbols (like functions, variables, or hooks) are used across a codebase by combining search results with contextual analysis through chat.
It enables developers to explore and understand symbol usage patterns through a two-step process. First, developers search for a specific symbol (like useCallback
) using Sourcegraph Chat, which returns relevant code snippets from across the codebase.
These search results are automatically preserved as context for follow-up chat interactions. Developers can refine their understanding by selecting specific search results and asking natural language questions about the symbol's usage patterns. The chat will analyze the selected code context and provide a comprehensive summary of how the symbol is implemented and used throughout the codebase.
Try it
- Query for
= useCallback
- Select a subset of the search results which include usage for
useCallback
- Follow up and ask Sourcegraph chat
Summarize how useCallback is used
Example
File Search
Search is a query type or workflow that enables users to locate specific files across repositories and perform targeted analysis on the selected files through natural language follow-up queries.
File Search simplifies finding and analyzing specific file types across your codebase. Unlike traditional code search, this workflow allows you to identify relevant files (for example, all package.json
files), select the specific files you want to analyze, and then ask follow-up questions about the selected files.
This two-step approach is particularly powerful when analyzing patterns or extracting information from similar files spread across multiple repositories. For instance, you could identify all configuration files, select the ones from relevant services, and then analyze their contents for inconsistencies or gather specific information through natural language queries.
Try it
- Type
package.json
- Check the checkbox next to the results you want to analyze
- Follow up with
List all the dependencies used across these package.json files
Example
String Literal Search
String literal search is a query type or workflow that allows you to find exact text matches by enclosing your search term in quotes. This ensures precise matching instead of keyword-based results.
When you enclose the text in quotes like " authInfo: async provider =>"",
Sourcegraph performs an exact match search rather than keyword matching. After finding relevant files, you can select specific ones to analyze and ask follow-up questions about their contents - creating an interactive workflow combining precise search and contextual code analysis.
Try it
- Start a new chat with
"authInfo: async provider =>"
- Select a subset of the search results which include usage for the string
- Follow up with
Summarize the contents
Example
Error Lookups
Error Lookups is a conversational workflow for Sourcegraph chat that helps developers understand error messages by providing plain-English explanations of when and why specific errors occur in their codebase and external service calls.
Developers can use Error Lookups to understand error messages occurring in their codebase. When encountering an error, especially from external services or dependencies, developers can use chat to:
- Search for specific error messages across their codebase
- Select relevant files where the error is thrown or handled
- Request a natural language explanation of the error's context, triggers, and implications
The workflow combines Sourcegraph's code search capabilities with AI-powered analysis to provide developers with a clear, contextual understanding of error scenarios. Instead of having to dig through docs or source code manually, developers can quickly grasp the following:
- The specific conditions that trigger the error
- The underlying reasons for the error occurrence
- Common scenarios where this error might appear
- Potential approaches to handling or preventing the error
This approach helps developers make more informed decisions about error handling and debugging, reducing the time spent deciphering cryptic error messages or searching through external docs.
Try it
- Query for
"unsupported platform"
- Select the file(s) where the error is thrown
- Follow up with "Explain when and why this error is thrown"