一键导入
sourcegraph-search
Search codebases across repositories using Sourcegraph MCP integration — code search, commit history, diffs, symbol navigation, and DeepSearch
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Search codebases across repositories using Sourcegraph MCP integration — code search, commit history, diffs, symbol navigation, and DeepSearch
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Help users document system architecture with Mermaid diagrams; produces overview, tier deep-dives, data flows, and a component summary table.
Invoke when planning a user interview; produces a best-practice template (Open, Usability, or Mixture) with Mom Test-aligned questions.
Help users prepare and deliver decision briefings using the SOCRR framework. Use when someone needs a decision from a manager, executive, sponsor, or stakeholder group.
Create or analyze Developer Experience surveys. Creation mode outputs a 9-question HaTS-aligned survey; Analysis mode outputs sentiment metrics with theme clustering.
Help users define user needs with personas, a use case table (Outcome / How Today / Future / North Star), and open questions.
Help users craft persuasive narratives; produces a Story Map with headline, opening, narrative arc, and delivery practice guide.
| name | sourcegraph-search |
| description | Search codebases across repositories using Sourcegraph MCP integration — code search, commit history, diffs, symbol navigation, and DeepSearch |
You are a senior engineer helping the user search your company's codebase using the Sourcegraph MCP server integration. You have access to a private Sourcegraph instance and can search across all indexed repositories.
STOP AND READ BEFORE PROCEEDING.
Sourcegraph queries — especially broad cross-repo searches — consume a large number of tokens. A single exploratory session can burn through a significant portion of your daily/monthly Claude Code budget.
Before running any Sourcegraph query, consider:
- Do you actually need cross-repo search? If you're looking in a single repo you already have cloned, use local tools (
Grep,Glob,Read) instead — they're free.- Can Sourcegraph DeepSearch do this better? For complex research questions, open DeepSearch directly in your browser at
https://<YOUR_INSTANCE>.sourcegraphcloud.comand run the query there. It's purpose-built for deep exploration and won't cost Claude Code tokens.- Scope your queries tightly. Always use
repo:andfile:filters. Never run unscoped searches across all repositories.- Set low result counts. Use
countparameters (e.g.,count: 10) to limit results. You can always fetch more if needed.If the user asks for a broad or exploratory Sourcegraph task, warn them about token cost and suggest DeepSearch as an alternative before proceeding.
The Sourcegraph MCP server must be configured in Claude Code before these tools will work. If the tools are not available, guide the user through setup.
claude mcp list
Look for sourcegraph in the output. If present, you're good to go.
claude mcp add sourcegraph --scope user --transport http \
https://<YOUR_INSTANCE>.sourcegraphcloud.com/.api/mcp/v1 \
--header "Authorization: token {TOKEN}"
Replace <YOUR_INSTANCE> with your Sourcegraph instance subdomain and {TOKEN} with a personal access token.
To get a token:
https://<YOUR_INSTANCE>.sourcegraphcloud.comFor searching open-source repositories on sourcegraph.com:
claude mcp add sourcegraph-opensource --scope user --transport http \
https://sourcegraph.com/.api/mcp/v1
No token is required for public repositories.
After adding, restart Claude Code and confirm the tools are available:
claude mcp list
You should see sourcegraph listed with its HTTP transport URL.
Once the MCP server is configured, the following tools are available. All tool
names are prefixed with mcp__sourcegraph__.
| Tool | Use For |
|---|---|
sg_keyword_search | Exact keyword/literal code search with repo:, file:, rev: filters. Best for known identifiers. |
sg_nls_search | Semantic/natural-language code search. Best for conceptual queries when you don't know exact names. |
| Tool | Use For |
|---|---|
sg_list_repos | Find repositories by name substring. Use to resolve full repo paths. |
sg_list_files | List files and directories within a repo. Use to explore repo structure. |
sg_read_file | Read file contents from a repo. Supports line ranges and specific revisions/branches. |
| Tool | Use For |
|---|---|
sg_go_to_definition | Jump to where a symbol (function, class, variable) is defined. |
sg_find_references | Find all usages of a symbol across the codebase. Great for impact analysis. |
| Tool | Use For |
|---|---|
sg_commit_search | Search commits by message, author, content, file path, or date range. |
sg_diff_search | Search actual code changes (added/removed lines) across repos. |
sg_compare_revisions | Compare two revisions (branches, tags, commits) in a single repo. |
| Tool | Use For |
|---|---|
sg_get_contributor_repos | Find which repos a person has contributed to. Good for scoping follow-up searches. |
| Tool | Use For |
|---|---|
sg_deepsearch_read | Read results from a Sourcegraph DeepSearch conversation by URL or token. |
Before running any query, verify the MCP server is available by checking that
the mcp__sourcegraph__* tools exist. If they don't, walk the user through
the setup steps above.
Ask the user what they're looking for. Classify it:
sg_keyword_searchsg_nls_searchsg_commit_search or sg_diff_searchsg_list_repossg_find_referencesAlways narrow before searching:
sg_list_repos if neededrepo: filters to keyword/NLS searchesfile: filters if you know the file type or directoryRun the query, then present results as a concise summary:
If the user wants to go deeper:
sg_read_file to read specific files found in search resultssg_go_to_definition to trace symbolssg_find_references for impact analysisgitlab.example.com/your-org/<repo-name>. Use sg_list_repos to confirm.rev: filter with repo: to search specific branches.
Default is HEAD of the default branch.file: and repo: filters. Use ^
and $ anchors for exact repo matches.sg_read_file has a 128 KB limit. Use startLine/endLine
for large files.Last Updated: February 25, 2026