Using Sourcegraph

Welcome to Sourcegraph docs!

What is Sourcegraph?

Sourcegraph is a code intelligence platform that helps devs answer questions in their code by searching and understanding across their organization's codebase.

Who should use Sourcegraph?

In addition to the companies listed on sourcegraph.com, companies with a few hundred developers all the way up to those with more than 40,000 use Sourcegraph daily.

More specifically, Sourcegraph is great for all developers, except:

  • those on smaller teams with a small amount of code
  • those that rarely search, read, or review code

Both Facebook and Google provide an in-house Sourcegraph-like code search and intelligence tool to their employees. A published research paper from Google and a Google developer survey showed that 98% of developers surveyed consider their Sourcegraph-like internal tool to be critical. Developers use it on average for 5.3 sessions each day. (Facebook's and Google's in-house tools are not available to other companies; use Sourcegraph instead.)

What do I use Sourcegraph for?

Sourcegraph helps you:

  • Find example code
  • Explore/read code (including during a code review)
  • Debug issues
  • Locate a specific piece of code
  • Determine the impact of changes
  • And more!

Sourcegraph makes it faster and easier to perform these tasks, for you and everyone else at your organization.

What does Sourcegraph do?

Sourcegraph's main features are:

  • Code navigation: jump-to-definition, find references, and other smart, IDE-like code browsing features on any branch, commit, or PR/code review
  • Code search: fast, up-to-date, and scalable, with regexp support on any branch or commit without an indexing delay (and diff search)
  • Notebooks: pair code and markdown to create powerful live and persistent documentation
  • Cody: read and write code with the help of a context-aware AI code assistant
  • Code Insights: reveal high-level information about your codebase at its current state and over time, to track migrations, version usage, vulnerability remediation, ownership, and anything else you can search in Sourcegraph
  • Batch Changes: make large-scale code changes across many repositories and code hosts
  • Integrations with code hosts, code review tools, editors, web browsers, etc.

How do I start using Sourcegraph?

  1. Deploy and Configure Sourcegraph inside your organization on your internal code, if nobody else has yet
  2. Install and configure the web browser code host integrations (recommended)
  3. Start searching and browsing code on Sourcegraph by visiting the URL of your organization's internal Sourcegraph instance
  4. Personalize Sourcegraph with themes, quick links, and badges!

You can also try Sourcegraph.com, which is a public instance of Sourcegraph for use on open-source code only.

How is Sourcegraph licensed?

Sourcegraph Enterprise is Sourcegraph’s primary offering and includes all code intelligence platform features. Sourcegraph Enterprise is the best solution for enterprises who want to use Sourcegraph with their organization’s code.

Sourcegraph extensions are also OSS licensed (Apache 2), such as:

Sourcegraph code search is fast, works across all your repositories at any commit, and has minimal indexing delay. Code search also includes advanced features, including:

Read the code search documentation to learn more and discover the full feature set. Here's a video to help you get started:

Code navigation

Sourcegraph gives your development team cross-repository IDE-like features on your code:

  • Hover tooltips
  • Go-to-definition
  • Find references
  • Symbol search

Sourcegraph gives you code navigation in:

  • code files in Sourcegraph's web UI

Hover tooltip

GitHub pull request integration

GitHub file integration

Read the code navigation documentation to learn more and to set it up.

Cody

Cody is an AI code assistant that uses Sourcegraph code search, the code graph, and LLMs to provide context-aware answers about your codebase. Cody can explain code, refactor code, and write code, all within the context of your existing codebase.

Learn more about about Cody.

Notebooks

Note: GA in version 3.39 or later

Increase dev collaboration and self-service through live documentation covering best practice, shared code and processes.

Read the Notebooks documentation to learn more, and check out these publicly available notebooks.

Batch Changes

Note: Enterprise feature

Automate changes to your codebase. Reduce effort, reduce errors and enable developers to focus on high value work.

Read the batch changes documentation to learn more, including useful how-to guides. Want a video tutorial? Check out this batch change tutorial

Code Insights

Note: Enterprise feature

Sourcegraph lets you understand and analyze code trends by visualizing how the codebase is changing over time. Measure and act on engineering goals such as migration and component deprecation.

Read the code insights documentation to learn more, including useful how-to guides.

Integrations

Sourcegraph allows you to get code navigation and code search on code files and code review diffs in your code host and review tool or from your IDE.

IDE integration

Sourcegraph’s editor integrations allow you search and navigate across all of your repositories without ever leaving your IDE or checking them out locally. Learn more about how to set them up here.

Browser extension

Our browser extension add code navigation within your code hosts (GitHub, GitLab, Bitbucket, and Phabricator) directly via Chrome, Safari, and Firefox browsers. Learn more about how to set up the browser extension here.