
Searching Sourcegraph
- 68 installs
- 12 repo stars
- Updated March 16, 2026
- sourcegraph-community/sourcegraph-skill
Searching Sourcegraph is an agent skill that routes implementation, debugging, and system-understanding questions through scoped Sourcegra
About
Searching Sourcegraph is an agent skill for solo and indie builders who already rely on Claude Code, Cursor, Codex, or similar agents and need authoritative answers from code that lives in Sourcegraph-indexed organizations. It does not replace local ripgrep; it routes your questions through a structured toolkit—semantic NLS when you know the idea but not the symbol, keyword search for exact patterns, deepsearch when you need narrative system understanding, plus references, definitions, file reads, and repo or commit history when you are tracing behavior or regressions. The skill emphasizes scoping every query to the right repo or org so results stay actionable instead of noisy. Triggers align with implementation planning, debugging, and “how does X work” discovery, making it useful whenever you are about to write new code or unstuck yourself in unfamiliar modules. Treat it as procedural knowledge for code intelligence APIs, not a hosted MCP server by itself.
- 6-step tool-selection flow: exact symbol → NLS → deepsearch → references → definition → contributor repos
- Goal-to-tool table covering nls_search, keyword_search, find_references, go_to_definition, deepsearch/deepsearch_read, a
- Mandatory repo scoping patterns (exact repo, org prefix, file regex) to keep agent queries precise
- Commit, diff, compare_revisions, and get_contributor_repos paths for change tracing and ownership context
- Search-before-build discipline to reuse proven patterns and reduce speculative implementation tokens
Searching Sourcegraph by the numbers
- 68 all-time installs (skills.sh)
- +1 installs in the week ending Jul 27, 2026 (Skillselion tracking)
- Ranked #5,828 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Jul 27, 2026 (Skillselion catalog sync)
npx skills add https://github.com/sourcegraph-community/sourcegraph-skill --skill searching-sourcegraphAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 68 |
|---|---|
| repo stars | ★ 12 |
| Security audit | 2 / 3 scanners passed |
| Last updated | March 16, 2026 |
| Repository | sourcegraph-community/sourcegraph-skill ↗ |
What it does
Wire Sourcegraph-backed code search into your agent workflow before implementing features or while debugging unfamiliar repos.
Who is it for?
Best when you're working in Sourcegraph-indexed org repos and want a repeatable search ritual before coding or while tracing symbols and commits.
Skip if: Greenfield experiments with no indexed upstream to search, or teams without Sourcegraph access who only need single-repo local grep.
When should I use this skill?
Implementation questions, debugging, or “how does X work” queries against Sourcegraph-indexed codebases.
What you get
Your agent picks the right Sourcegraph tool chain, scopes queries to the correct repos, and returns patterns, definitions, and references you can implement or fix against confidently.
- Scoped search results (keyword, NLS, or deepsearch summaries)
- Symbol traces via find_references and go_to_definition with targeted read_file excerpts
By the numbers
- 6-step numbered tool-selection flow at the top of the skill
- 13+ named Sourcegraph tools in the goal-to-tool reference table
Files
Searching Sourcegraph
Search before you build. Existing patterns reduce tokens, ensure consistency, and surface tested solutions.
Tool Selection Logic
Start here:
1. Know the exact symbol or pattern? → keyword_search 2. Know the concept, not the code? → nls_search 3. Need to understand how/why? → deepsearch → deepsearch_read 4. Tracing a symbol's usage? → find_references 5. Need full implementation? → go_to_definition → read_file 6. Need to know what repos a user has worked on? → get_contributor_repos
| Goal | Tool |
|---|---|
| Concepts/semantic search | nls_search |
| Exact code patterns | keyword_search |
| Trace usage | find_references |
| See implementation | go_to_definition |
| Initiate a deep search | deepsearch |
| Read deep search results | deepsearch_read |
| Read files | read_file |
| Browse structure | list_files |
| Find repos | list_repos |
| Search commits | commit_search |
| Track changes | diff_search |
| Compare versions | compare_revisions |
| Find repos a user has worked on | get_contributor_repos |
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:typescript
Context-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":
- Use
deepsearchto initiate the search, thendeepsearch_readto retrieve results - Follow up with
read_fileon key files mentioned in the response
When the user asks who worked on something or what repos a contributor has touched:
- Use
get_contributor_reposwith one or more usernames to discover their active repositories - Then scope subsequent searches to those repos
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 troubleshooting an error, build failure, or runtime exception:
- Extract exact symbols, error codes, or log lines from the stack trace or build output
- Search for the error site, then trace the full call chain with
find_references - Check recent changes with
diff_searchandcommit_searchearly — regressions are common - Identify all affected code paths and services before proposing a fix
When fixing a bug:
- Extract exact symbols from the error message or stack trace
- Search for the error site, then trace the full call chain with
find_references - Check recent changes with
diff_searchandcommit_searchearly — regressions are common - Find all affected code paths before writing the fix
- Read existing tests to understand intended behaviour
Workflows
For detailed step-by-step workflows, see:
workflows/implementing-feature.md— when building new featuresworkflows/understanding-code.md— when exploring unfamiliar systemsworkflows/debugging-issue.md— when troubleshooting errors, build failures, stack traces, support issues, or runtime exceptionsworkflows/fixing-bug.md— when fixing bugs with extensive Sourcegraph searchworkflows/code-review.md— when reviewing a pull request or changeset
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
keyword_searchovernls_searchwhen you have exact terms (faster, more precise)
Batch your understanding:
- Read 2-3 related files before synthesising, rather than reading one and asking questions
- Use
deepsearch+deepsearch_readfor "how does X work" instead of multiple keyword searches
Avoid common token waste:
- Don't search all repos when you know the target repo
- Don't use
deepsearchfor simple "find all" queries —keyword_searchis faster - Don't re-read files you've already seen in this conversation
Query Patterns
| Intent | Query |
|---|---|
| React hooks | file:.*\.tsx$ use[A-Z].*= \( |
| API routes | `file:src/api app\.(get\ |
| Error handling | `catch.*Error\ |
| Type definitions | `file:types/ export (interface\ |
| Test setup | `file:.*\.test\. beforeEach\ |
| Config files | `file:(webpack\ |
| CI/CD | file:\.github/workflows deploy |
For more patterns, see query-patterns.md.
Output 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 repo:^github.com/org/repo$ |
| Too many results | Add file: pattern or keywords |
| Missing relevant code | Try nls_search for semantic matching |
| Not understanding context | Use deepsearch_read |
| Guessing patterns | Read implementations with read_file |
Principles
- Start narrow, expand if needed
- Chain tools: search → read → find references → definition
- Check tests for usage examples
- Read before generating
Common Search Examples
Real-world search examples for common tasks.
Finding Implementations
"Where is authentication handled?"
nls_search: "repo:^github.com/org/repo$ authentication middleware validation""How do we make API calls?"
keyword_search: "repo:^github.com/org/repo$ fetch\|axios\|http\.request""Find all database queries"
keyword_search: "repo:^github.com/org/repo$ \.query\(\|\.execute\("Understanding Flow
"How does user signup work end-to-end?"
deepsearch_read: "Trace the user signup flow from form submission to database creation""What happens when a payment fails?"
deepsearch_read: "How does the system handle failed payment attempts?"Debugging
"Find where this error is thrown"
keyword_search: "repo:^github.com/org/repo$ 'User not found'"
find_references: Find all usages of the error constant"What changed in authentication recently?"
diff_search: repos=["github.com/org/repo"] pattern="auth" after="2 weeks ago"Finding Patterns
"How do other features handle validation?"
nls_search: "repo:^github.com/org/repo$ input validation schema""Find examples of pagination"
keyword_search: "repo:^github.com/org/repo$ offset\|limit\|cursor\|pageToken"Tracing Dependencies
"What uses this utility function?"
find_references: repo="github.com/org/repo" path="src/utils/format.ts" symbol="formatDate""Where is this type defined?"
go_to_definition: repo="github.com/org/repo" path="src/api/handler.ts" symbol="UserResponse"Query Patterns Reference
Common regex patterns for Sourcegraph searches.
Language-Specific Patterns
TypeScript/JavaScript
| Intent | Query |
|---|---|
| React hooks | file:.*\.tsx$ use[A-Z].*= \( |
| React components | file:.*\.tsx$ export (default )?function [A-Z] |
| API routes (Express) | `file:src/api app\.(get\ |
| API routes (Next.js) | `file:app/api export async function (GET\ |
| Type definitions | `file:types/ export (interface\ |
| Error handling | `catch.*Error\ |
| Async functions | `async function\ |
| Class definitions | export class [A-Z] |
| Constants | export const [A-Z_]+ |
Python
| Intent | Query |
|---|---|
| Class definitions | class [A-Z].*: |
| Function definitions | def [a-z_]+\( |
| Decorators | @[a-z_]+ |
| FastAPI routes | `@app\.(get\ |
| Django views | `class.*View\ |
| Exception handling | except.*: |
Go
| Intent | Query |
|---|---|
| Function definitions | func [A-Z] |
| Method definitions | func \(.*\) [A-Z] |
| Interface definitions | type.*interface |
| Struct definitions | type.*struct |
| Error handling | if err != nil |
| HTTP handlers | func.*http\.ResponseWriter |
Project Structure Patterns
| Intent | Query |
|---|---|
| Test files | `file:.*\.(test\ |
| Test setup | `file:.*\.test\. beforeEach\ |
| Config files | `file:(webpack\ |
| Package definitions | file:package\.json "name": |
| CI/CD workflows | file:\.github/workflows deploy |
| Docker files | file:Dockerfile FROM |
| Environment config | file:\.env\. [A-Z_]+= |
Common Search Scopes
# Single repo
repo:^github.com/org/repo$
# All repos in org
repo:github.com/myorg/
# Specific file types
file:.*\.ts$ lang:typescript
# Specific directories
file:src/api/ file:.*\.ts$
# Exclude patterns
file:.*\.ts$ -file:.*\.test\.ts$ -file:__mocks__
# Multiple file types
file:\.(ts|tsx|js|jsx)$Tips
- Use
\|for OR in regex patterns - Use
^and$for exact repo matching - Escape special regex chars:
\.\(\) - Combine
file:andrepo:for precise scoping
Code Review
When reviewing a pull request or changeset, use Sourcegraph MCP to verify correctness, spot risks, and check consistency — before leaving comments.
Checklist
Task Progress:
- [ ] Understand the scope of changes
- [ ] Verify changed code against existing patterns
- [ ] Check for similar prior implementations or fixes
- [ ] Trace impact on callers and dependents
- [ ] Review test coverage
- [ ] Inspect recent changes in the same area
- [ ] Flag inconsistencies or missing conventionsSteps
1. Understand the Scope of Changes
Start by reading the diff or changed files to extract the key symbols, functions, and modules being modified.
Collect:
- New or modified function/class names
- Files touched
- Any new dependencies or imports introduced
- Error handling paths added or changed
2. Verify Against Existing Patterns
Check that the new code follows established conventions in the codebase:
nls_search: "repo:^github.com/org/repo$ how is <concept> typically implemented"
keyword_search: "repo:^github.com/org/repo$ file:src/<area>/ <pattern or function name>"Look for:
- Naming style (snake_case vs camelCase, verb prefixes, etc.)
- File organisation conventions
- How similar functionality is already implemented elsewhere
- Whether shared utilities exist that should be reused
read_file: <2-3 representative files from the same area>3. Search for Prior Art on the Same Problem
Confirm the approach isn't reinventing something already solved:
nls_search: "repo:^github.com/org/repo$ <feature or problem the PR solves>"
commit_search: repos=["org/repo"] messageTerms=["<keyword related to the change>"]If a similar feature exists, compare the approaches and flag divergence if it reduces consistency.
4. Trace Impact on Callers and Dependents
For any modified public symbol (function, type, constant), check its usage:
find_references: <modified function or type>Verify:
- All call sites are compatible with the new signature or behaviour
- No implicit contracts are broken (return value shape, error semantics, etc.)
- If a shared utility is changed, all consumers are safe
For deeper impact analysis:
deepsearch_read: "How is <changed component> used across the system?"5. Review Test Coverage
Read the existing tests for the affected area:
keyword_search: "repo:^github.com/org/repo$ file:.*\.test\. <function or module name>"
read_file: <relevant test files>Check:
- Are the new code paths covered?
- Do existing tests still match the updated behaviour?
- Are edge cases (empty inputs, errors, boundary values) tested?
- Are tests missing for non-trivial logic introduced in the PR?
6. Inspect Recent Changes in the Same Area
Recent activity reveals context and potential conflicts:
diff_search: "repo:^github.com/org/repo$ <file path or function name>"
commit_search: repos=["org/repo"] messageTerms=["<area keyword>"]Use compare_revisions to see what changed in the area recently:
compare_revisions: repo="org/repo" base="main~30" head="main" path="src/<affected area>/"Look for:
- Parallel changes that could conflict
- Recent fixes the PR might accidentally revert
- Patterns established in nearby recent work
7. Flag Inconsistencies and Missing Conventions
After searching, compile review comments around:
- Pattern divergence: Code that works but differs from established style without reason
- Missing reuse: New helpers that duplicate existing utilities
- Untested paths: Non-trivial logic without coverage
- Broken contracts: Changed behaviour that affects undiscovered callers
- Risk surface: Error handling gaps, missing validation, or unsafe assumptions
Tips
- Search before commenting — many apparent issues are intentional deviations with prior art
- Use
find_referencesbefore flagging a changed signature as breaking; verify actual impact - Read tests first — they often clarify the intended contract faster than the implementation
- Check recent commits in the same path; the PR may be part of a larger sequence of changes
- Use
deepsearch_readwhen the change touches a system you're unfamiliar with before reviewing it - Scope searches to the affected directory or module to reduce noise
Troubleshooting Issues
When investigating errors, build failures, stack traces, support issues, or runtime exceptions in production, search systematically from symptom to root cause.
Checklist
Task Progress:
- [ ] Collect symptoms (error, stack trace, logs)
- [ ] Search for the error message or code
- [ ] Find where the error originates
- [ ] Understand the context and conditions
- [ ] Check recent changes for regressions
- [ ] Identify impact and affected pathsSteps
1. Collect Symptoms
Before searching, extract all available signal:
- Exact error message or exception text
- Stack trace symbols (function names, file paths, line numbers)
- Error codes, constants, or exit codes
- Build output or log lines near the failure
- Environment details (service name, version, deployment context)
The more precise your search terms, the fewer tool calls you need.
2. Search for the Error
keyword_search: "repo:X 'ExactErrorMessageHere'"Search for:
- Exact error message text or substrings
- Exception class names or error constants
- Log message patterns near the failure
- Build task names or compiler error codes
keyword_search: "repo:X ErrBuildFailed"
nls_search: "repo:X compilation failure during asset bundling"Run multiple searches in parallel when you have several candidate terms.
3. Find Where It Originates
find_references: <error symbol or throwing function>Locate all sites that produce this error:
- Direct
throw/panic/return errstatements - Build scripts or CI steps that emit the failure
- Middleware or interceptors that wrap errors
- Error factory functions
Read each throw site with read_file to understand the exact trigger condition.
4. Understand the Context
deepsearch_read: "When does <error> occur and what are the expected conditions?"Get a deeper understanding of:
- Conditions that trigger the error or failure
- Expected handling or recovery patterns
- Related error types or failure modes
- How this path behaves under normal operation
5. Check Recent Changes
Recent commits are the most common source of regressions:
diff_search: "repo:X <function or symbol name>"
commit_search: repos=["org/repo"] messageTerms=["keyword related to failure area"]Use compare_revisions to diff a specific before/after window:
compare_revisions: repo="org/repo" base="main~30" head="main" path="src/affected/"6. Identify Impact and Affected Paths
Check how broadly the issue affects the system:
find_references: <the failing function or error symbol>
keyword_search: "repo:X <shared utility involved in the failure>"Confirm whether:
- Other callers or services are affected
- The same failure can surface in other environments (staging, canary)
- There are existing error handling paths that should have caught this
Tips
- Extract exact symbols from stack traces — they are the fastest search terms
- Build failures often reference a specific task, target, or step name — search for that
- Errors frequently have multiple throw sites; always use
find_referencesto find all of them - Recent diffs narrow suspects dramatically — check them early
- For runtime exceptions in production, search for the error constant and its callers before looking at logs
- Use
deepsearch_readwhen the failure spans multiple layers and you need architectural context
Fixing a Bug
When fixing bugs, use Sourcegraph MCP to extensively search for the root cause before touching any code.
Checklist
Task Progress:
- [ ] Reproduce and extract symptoms
- [ ] Search for error / failure site
- [ ] Trace the call chain
- [ ] Find all affected code paths
- [ ] Check recent changes
- [ ] Understand the intended behaviour
- [ ] Validate the fix against similar patternsSteps
1. Extract Symptoms
Before searching, collect everything available from the bug report:
- Exact error message or log line
- Stack trace symbols (function names, file paths, line numbers)
- Error codes or constants
- Relevant request/response data
The more precise your search terms, the fewer tool calls you need.
2. Search for the Error Site
keyword_search: "repo:^github.com/org/repo$ 'ExactErrorMessageHere'"Also search for:
- The error class or constant name
- Any unique string from the stack trace
- Log statement nearest the failure
keyword_search: "repo:X file:src/ ErrTokenExpired"
nls_search: "repo:X token validation failure handling"Run multiple searches in parallel when you have several candidate terms.
3. Find Where the Error Originates
find_references: <error symbol or throwing function>Locate every site that can produce this error:
- Direct
throw/panic/return errstatements - Error factory functions
- Middleware or interceptors that wrap errors
Read each throw site with read_file to understand the exact condition.
4. Trace the Full Call Chain
go_to_definition: <function at the throw site>
find_references: <caller of that function>Walk the chain upward until you reach the entry point (HTTP handler, queue consumer, CLI command, etc.).
For complex chains, use:
deepsearch_read: "How does the X flow work from entry point to error site?"5. Find All Affected Code Paths
Bugs often affect more than one path. Search broadly:
keyword_search: "repo:X <shared utility or function involved>"
find_references: <the function being fixed>Confirm whether:
- Other callers rely on the current (buggy) behaviour
- Tests exist that cover these paths
- The same bug can surface elsewhere
6. Check Recent Changes
Recent commits are the most common source of regressions:
diff_search: "repo:X <function or symbol name>"
commit_search: repos=["org/repo"] messageTerms=["keyword related to bug area"]Use compare_revisions if you want to diff a specific before/after window:
compare_revisions: repo="org/repo" base="main~30" head="main" path="src/auth/"7. Understand the Intended Behaviour
Before writing the fix, confirm what correct behaviour looks like:
nls_search: "repo:X how should <feature> behave when <condition>"
read_file: <relevant test files>Read existing tests to understand invariants. If tests are missing, that is part of the bug.
8. Find a Reference Fix or Pattern
Search for similar bugs that were already fixed in the codebase:
commit_search: repos=["org/repo"] messageTerms=["fix", "bug keyword"]
nls_search: "repo:X handle <edge case similar to the bug>"Match your fix to the established pattern so it stays consistent with the codebase.
Tips
- Search extensively before writing a single line of code — most fix time should be spent understanding, not coding
- Never assume the first throw site is the only one; always use
find_references - Check tests first: a failing test often tells you more than the code does
- Recent diffs narrow suspects dramatically — check them early
- If
keyword_searchreturns too many results, scope withfile:orlang:filters - Use
deepsearch_readwhen the bug spans multiple layers and you need architectural context
Implementing a Feature
When building new features, search for similar patterns first to ensure consistency.
Checklist
Task Progress:
- [ ] Find similar implementations
- [ ] Read file structure
- [ ] Study a good example
- [ ] Check shared utilitiesSteps
1. Find Similar Implementations
nls_search: "repo:^github.com/org/repo$ user settings CRUD"Look for features that solve similar problems. Note the patterns used.
2. Explore File Structure
keyword_search: "repo:^github.com/org/repo$ file:src/features/ index.ts"Understand how features are organised in this codebase.
3. Study a Representative Example
read_file: Read 2-3 files from a well-implemented similar featurePay attention to:
- Naming conventions
- File organisation
- Import patterns
- Error handling approach
4. Check for Shared Utilities
find_references: Trace usage of common utilitiesBefore creating new helpers, check if reusable utilities exist:
- Validation functions
- API wrappers
- UI components
- Type definitions
Tips
- Don't create new patterns when existing ones work
- Match the style of surrounding code
- Check tests for usage examples of utilities
- Look at recent PRs for similar features
Understanding Unfamiliar Code
When exploring systems you don't know, start broad and narrow down.
Checklist
Task Progress:
- [ ] Get big picture via Deep Search
- [ ] Find entry points
- [ ] Trace implementation
- [ ] Review related testsSteps
1. Get the Big Picture
deepsearch_read: "How does order fulfillment work in this codebase?"Deep Search provides architectural understanding. Ask "how" and "why" questions.
2. Find Entry Points
keyword_search: "repo:X file:src/routes export.*order"Look for:
- API route handlers
- Event listeners
- CLI commands
- UI component entry points
3. Trace the Implementation
go_to_definition: Jump to main handler
find_references: See how it's usedFollow the code path from entry point through business logic.
4. Review Related Tests
keyword_search: "repo:X file:.*\.test\.ts describe.*order"Tests reveal:
- Expected behaviour
- Edge cases
- Usage patterns
- Integration points
Tips
- Read 2-3 related files before synthesising
- Tests are documentation—read them
- Check for architecture docs in
docs/or README files
Related skills
How it compares
Use this procedural skill to orchestrate Sourcegraph code intelligence—not as a substitute for unstructured chat guesses or a generic filesystem-only search skill.
FAQ
Who is searching-sourcegraph for?
It is for developers using AI coding agents who need to query large, org-scale codebases indexed in Sourcegraph before implementing or while debugging.
When should I use searching-sourcegraph?
Use it during Build when you need existing patterns before writing code; during Ship › Testing when debugging unfamiliar modules; and during Idea › Research when answering “how does X work” across repos—always with explicit repo scoping.
Is searching-sourcegraph safe to install?
Review the Security Audits panel on this Prism page for ingest-time signals; the skill implies network and API access to Sourcegraph—confirm org policies and credentials before enabling it in production agents.