This guide provides recommendations for first things to try once you have Cody up and running.
If you haven't yet enabled Cody for your Sourcegraph instance or installed the VS Code extension, go here first:
- Enabling Cody for Sourcegraph Enterprise customers
- Enabling Cody for Sourcegraph.com users
- Installing Cody for VS Code
- Installing the Cody app
Once you have access to Cody, we recommend:
- Trying the
Generate a unit test
recipe - Trying the
Summarize recent code changes
recipe - Asking Cody to pull information from documentation
- Asking Cody to write context-aware code
The Cody icon should now appear in the activity bar in VS Code. Clicking the icon will open the Cody side panel. The Chat
tab can be used to ask Cody questions and paste in snippets of code, and the Recipes
tab can be used to run premade functions over whatever code you currently have highlighted.
As one recipe example, let's generate a unit test:
- Open a code file in VS Code
- Open the
Recipes
tab in the Cody sidebar - Highlight a code snippet in your code that you'd like to test
- Click the
Generate a unit test
recipe button OR right click ->Ask Cody
->Ask Cody: Generate Unit Test
- Cody will provide a unit test as a code snippet in the sidebar
If you're using Cody with Sourcegraph Enterprise, Cody can utilize Sourcegraph's search and the code graph to understand your own codebase and provide context-aware answers. Using this, Cody can tell you about recent changes to your code and quickly provide a summary.
Imagine you've stepped away from a project for the last week. Let's see what's changed in that time:
- Open the
Recipes
tab in the Cody sidebar - Click the
Summarize recent changes
recipe button - A dropdown will appear. Click
Last week
- Cody will provide a summary of changes to your codebase that occurred in that time period
Cody can also directly reference documentation. If Cody has context of a codebase, and docs are committed within that codebase, Cody can search through the text of docs to understand documentation and quickly pull out information so that you don't have to search for it yourself.
In the Chat
tab of the VS Code extension, you can ask Cody examples like:
- "What happens when Service X runs out of memory?"
- "Where can I find a list of all experimental features and their feature flags?"
- "How is the changelog generated?"
One of Cody's strengths is writing code, especially boilerplate code or simple code that requires general awareness of the broader codebase.
One great example of this is writing an API call. Once Cody has context of a codebase, including existing API schemas within that codebase, you can ask Cody to write code for API calls.
For example, ask Cody:
- "Write an API call to retrieve user permissions data"
Cody can do many other things, including:
- Explain code snippets
- Refactor code and variable names
- Translate code to different languages
- Answer general questions about your code
- Suggest bugfixes and changes to code snippets