name: searching-sourcegraph description: Use when the user needs to search or navigate code with Sourcegraph (public or private) using the provided sg_* tools.
Searching Sourcegraph
You have access to Sourcegraph search and file retrieval tools.
Tools
nls_search({ query }): Semantic search.keyword_search({ query }): Keyword/regex search.read_file({ repo, path, startLine?, endLine?, revision? }): Read file contents.list_repos({ query, limit?, after?, before? }): Find relevant repos.list_files({ repo, path?, revision? }): List files/directories.go_to_definition({ repo, path, symbol, revision? }): Navigate to definitions.find_references({ repo, path, symbol, revision? }): Find references.
Workflow
- Start with a tight query (use
repo:,file:,lang:,type:if applicable). - If results are broad, add constraints and retry.
- For a promising match, fetch the file with
read_fileand read surrounding context. - Iterate: refine the query based on what you learned.
Prefer nls_search to explore, then narrow with keyword_search.
Query Tips
- Prefer
repo:^github\\.com/org/repo$for exact repo matches. - Use
file:\\.(go|ts|py)$to constrain by extension. - Use
type:symbolto find definitions;type:filefor file content.