Delv
Sourcegraph Cody
Getting Started Guide

How to Use Sourcegraph Cody

A practical guide to get you up and running with Sourcegraph Cody. Written by Delv Editorial, Delv Team.

Getting started with Sourcegraph Cody

With Sourcegraph Cody, you’ll quickly learn how to enhance your coding experience by getting answers, writing code snippets, and fixing bugs using your entire repository. After this guide, you’ll be set up to leverage Cody's capabilities to boost your productivity.

Step 1: Sign up and set up

  1. Go to the Sourcegraph Cody website.
  2. Click on the Get Started for Free button.
  3. Sign up using your email or GitHub account.
  4. Once signed in, follow the prompts to set up your workspace, including connecting your code repository.

Step 2: Your first coding task

  1. Open your Sourcegraph workspace where Cody is integrated.
  2. In the search bar, type a question about your code, such as “How does this function work?” or “What does this error mean?”
  3. Cody will provide an answer based on your codebase context.
  4. To generate code, type a prompt like “Write a function that calculates the factorial of a number.”
  5. Review the generated code snippet and click Insert to add it directly into your project.

Step 3: Get better results

  1. Be specific with your prompts. Instead of asking vague questions, provide context, like the file or function name.
  2. Use comments in your code to guide Cody, such as “// Fix this bug” before asking for a bug fix.
  3. Experiment with different phrasing if the initial answer isn't satisfactory; sometimes a slight rewording can yield better results.

Pro tip

Cody can understand code comments, so always include them when asking questions or requesting code snippets. This helps Cody provide more accurate and context-aware responses.

Common mistake to avoid

Avoid asking overly broad questions like “Explain my code.” Instead, focus on specific functions or sections of your codebase to get meaningful answers.