Skip to main content
Sourcegraph is a code intelligence platform for developers. It lets you search and explore your organization’s code on the web, with integrations into your existing tools. This tour walks through the most common ways developers use Sourcegraph every day. Sourcegraph code search is fast, works across all your repositories at any commit, and supports multiple search modes.

Search modes

Try it on open source

You can try Sourcegraph search on public repositories at sourcegraph.com/search. For example:

Code review: gain context on changed code

When reviewing a pull request, you often need to understand the full context of changed code—not just the lines in the diff.

Workflow

1

Install the browser extension

Install the Sourcegraph browser extension for Chrome, Firefox, or Safari. This adds code navigation directly to GitHub, GitLab, and Bitbucket pull requests.
2

Open a pull request

Visit a pull request in your code host. With the browser extension active, you’ll see hover tooltips appear when you mouse over code in the diff.
3

Use Go to definition

Hover over any symbol in the diff—added, unchanged, or deleted code. Click Go to definition to jump to the symbol’s implementation, even if it’s in a different repository.
4

Use Find references

Click Find references on a modified function to enumerate all call sites across your entire codebase. This helps you verify that every caller accounts for new behavior or assumptions introduced by the change.
To try this on an open-source pull request, install the browser extension and visit gorilla/websocket#342. Use Find references on the newly added AllowClientContextTakeover field to see all places it’s used.

Explore code: understand an unfamiliar codebase

As a new developer on a project, or when working in an unfamiliar part of the codebase, Sourcegraph’s code navigation helps you orient quickly.

Workflow

1

Search for the entry point

Search on Sourcegraph for the function or module you want to understand. Use the query bar on your organization’s Sourcegraph instance, or initiate a search from your editor or browser extension.
2

Navigate to the relevant result

Click through to the file. If the search returns many results, use the suggested filters below the search box or add filters like lang:go or repo:my-org/my-service to narrow them down.
3

Drill down with Go to definition

Click on any token and select Go to definition to navigate to its implementation. Continue drilling down depth-first until you’ve mapped the relevant call chain.
4

Share a link

If you have questions, use the blame information to identify who wrote the code. Copy the Sourcegraph URL for the relevant file and line, and send it with your question. Sourcegraph links include the exact revision, so the recipient sees exactly what you’re referring to.
Try this on the open-source node-jsonc-parser repository. Start at the getLocation function, follow Go to definition through visit, and continue until you reach createScanner.

Debug issues: trace what changed

When you receive a crash report with a stack trace, diff search helps you quickly identify what changed that might have caused the problem.

Workflow

1

Run a diff search on the crashing function

Take the function name from the top of the stack trace and run a diff search:
type:diff myCrashingFunctionName
Results show all commits that modified code matching that name, newest first.
2

Review recent changes

Scroll through the results. Each result shows the diff with context. Click on the commit message to view the full diff with code navigation enabled.
3

Drill into the change

Click on code in the commit diff to open the full file at the revision before or after the commit. Use Go to definition and Find references to understand how the change affected callers and behavior.
4

Narrow the search if needed

If there are too many results, add filters to focus on the relevant repositories and time window:
type:diff after:"last week" repo:my-org/my-service myCrashingFunctionName

Learn how a function should be called

When you need to add a new feature that uses an unfamiliar function or library, looking at real-world call sites is more reliable than reading documentation that may be outdated.

Workflow

1

Search for the function

Search on Sourcegraph for the name of the function you want to call.
2

Open a matching file

Find and click on a search result that looks like a relevant usage. If there are many results, narrow them using filters.
3

Find all references

Click on the function name in the file and select Find references to see all call sites across your codebase (and optionally, across public open-source repos).
4

Evaluate the examples

Click through to various call sites. Use the inline blame information to see who wrote each call site and when. More recent, non-test call sites by experienced team members are typically the best examples to follow.

Code Navigation

Sourcegraph provides two tiers of code navigation:
Available for 40+ languages with no setup required. Uses heuristics to find definitions and references. Works across all repositories but may occasionally return false positives for symbols with common names. Does not support cross-repository navigation.
Available for 11 languages (Go, TypeScript, JavaScript, C, C++, Java, Scala, Kotlin, Rust, Python, Ruby). Uses SCIP/LSIF code graph data to deliver compiler-accurate results with no false positives. Supports cross-repository navigation, transitive dependency navigation, and Find implementations for interface types.Precise code navigation requires uploading SCIP or LSIF data to Sourcegraph. Auto-indexing can generate and upload this data automatically.

Code Navigation docs

Set up precise code navigation and explore all navigation features.

Cody AI

Cody is Sourcegraph’s AI code assistant. Because Cody has access to your entire codebase as context, its answers are grounded in your actual code rather than general programming knowledge.
Ask Cody questions about your codebase in natural language:
  • “Where is the authentication middleware defined and how does it work?”
  • “Explain the retry logic in the payments service”
  • “What does this function return when the input is empty?”
Cody cites the specific files it used to answer, so you can verify and navigate to the source.

Cody overview

Learn about all Cody capabilities and supported clients.

Cody quickstart

Install Cody in your editor and get started.

Deep Search is an agentic AI tool that answers complex questions about your codebase. It explores your code autonomously, running multiple searches and synthesizing the results into a comprehensive answer. Unlike Cody chat, Deep Search is designed for open-ended investigative questions where the answer requires exploring many files and understanding broad patterns:
  • “How does authentication work across all our services?”
  • “Which repositories are still using the deprecated v1 API?”
  • “Walk me through how a request flows from the frontend to the database”
Use @-mentions to scope Deep Search to specific repositories, directories, files, or symbols for faster, more focused results.

Deep Search docs

Learn how Deep Search agents work and how to get the best results.

Code Insights

Code Insights turns any Sourcegraph search query into a time-series visualization. Use dashboards to track engineering metrics, migration progress, and codebase health over time. Example insights:
  • Track how many repositories still use an old version of a library (and watch the number decrease as migrations land)
  • Monitor the adoption of a new logging framework across all repos
  • Track the number of TODO comments or type: ignore annotations over time
  • Measure vulnerability remediation progress after a CVE disclosure

Code Insights docs

Learn how to create insights and build dashboards.

Batch Changes

Batch Changes automates large-scale code changes across many repositories. You write a changeset specification describing what to change, Sourcegraph applies it, and you manage the resulting pull requests from a single interface. Common use cases:
  • Update an API after a library major version bump
  • Apply a security patch to hundreds of repositories
  • Rename a configuration key across all services
  • Add required license headers to source files

Batch Changes docs

Learn how to create and manage large-scale code changes.

Build docs developers (and LLMs) love