searching-sourcegraph
Original:🇺🇸 English
Translated
Search Sourcegraph-indexed codebases for patterns, examples, and system understanding. Triggers on implementation questions, debugging, or "how does X work" queries.
5installs
Added on
NPX Install
npx skill4agent add sourcegraph-community/sourcegraph-skill searching-sourcegraphTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Searching Sourcegraph
Search before you build. Existing patterns reduce tokens, ensure consistency, and surface tested solutions.
Tool Selection Logic
Start here:
- Know the exact symbol or pattern? →
sg_keyword_search - Know the concept, not the code? →
sg_nls_search - Need to understand how/why? →
sg_deepsearch_read - Tracing a symbol's usage? →
sg_find_references - Need full implementation? → →
sg_go_to_definitionsg_read_file
| Goal | Tool |
|---|---|
| Concepts/semantic search | |
| Exact code patterns | |
| Trace usage | |
| See implementation | |
| Understand systems | |
| Read files | |
| Browse structure | |
| Find repos | |
| Search commits | |
| Track changes | |
| Compare versions | |
Scoping (Always Do This)
repo:^github.com/ORG/REPO$ # Exact repo (preferred)
repo:github.com/ORG/ # All repos in org
file:.*\.ts$ # TypeScript only
file:src/api/ # Specific directory
file:.*\.test\.ts$ -file:__mocks__ # Tests, exclude mocksStart narrow. Expand only if results are empty.
Combine filters:
repo:^github.com/myorg/backend$ file:src/handlers lang:typescriptContext-Aware Behaviour
When the user provides a file path or error message:
- Extract symbols, function names, or error codes
- Search for those exact terms first
- Trace references if the error involves a known symbol
When the user asks "how does X work":
- Prefer for architectural understanding
sg_deepsearch_read - Follow up with on key files mentioned in the response
sg_read_file
When the user is implementing a new feature:
- Search for similar existing implementations first
- Read tests for usage examples
- Check for shared utilities before creating new ones
When debugging:
- Search for the exact error string
- Trace the symbol where the error is thrown
- Check recent changes with
sg_diff_search
Workflows
For detailed step-by-step workflows, see:
- — when building new features
workflows/implementing-feature.md - — when exploring unfamiliar systems
workflows/understanding-code.md - — when tracking down bugs
workflows/debugging-issue.md
Efficiency Rules
Minimise tool calls:
- Chain searches logically: search → read → references → definition
- Don't re-search for the same pattern; use results from prior calls
- Prefer over
sg_keyword_searchwhen you have exact terms (faster, more precise)sg_nls_search
Batch your understanding:
- Read 2-3 related files before synthesising, rather than reading one and asking questions
- Use for "how does X work" instead of multiple keyword searches
sg_deepsearch_read
Avoid common token waste:
- Don't search all repos when you know the target repo
- Don't use for simple "find all" queries
sg_deepsearch_read - Don't re-read files you've already seen in this conversation
Query Patterns
| Intent | Query |
|---|---|
| React hooks | |
| API routes | |
| Error handling | |
| Type definitions | |
| Test setup | |
| Config files | |
| CI/CD | |
For more patterns, see .
query-patterns.mdOutput Formatting
Search results:
- Present as a brief summary, not raw tool output
- Highlight the most relevant file and line
- Include a code snippet only if it directly answers the question
Code explanations:
- Start with a one-sentence summary
- Use the codebase's own terminology
- Reference specific files and functions
Recommendations:
- Present as numbered steps if actionable
- Link to specific patterns found in the codebase
- Note any existing utilities that should be reused
Common Mistakes
| Mistake | Fix |
|---|---|
| Searching all repos | Add |
| Too many results | Add |
| Missing relevant code | Try |
| Not understanding context | Use |
| Guessing patterns | Read implementations with |
Principles
- Start narrow, expand if needed
- Chain tools: search → read → find references → definition
- Check tests for usage examples
- Read before generating