* This blog post is a summary of this video.

Introduction to Cody - Sourcegraph's New AI-Powered Coding Assistant

Table of Contents

What is Cody and How Does it Work?

Cody is an AI-powered programming assistant created by Sourcegraph. It works by understanding programming intents and questions posed in natural language, retrieving relevant code contexts and documentation, and generating answers in code using machine learning models trained on public code repositories.

Cody integrates with Sourcegraph's code search and intelligence platform to access code contexts specific to a developer's codebase. Rather than hallucinating responses like ChatGPT, Cody can validate its responses against real code.

Key capabilities provided by Cody include code auto-complete, documentation generation, code search, and code summarization. Under the hood, it combines large language models like Anthropic's Claude with Sourcegraph's knowledge graph of code to produce relevant, contextual responses.

Integrating Sourcegraph for Code Context

A key differentiator of Cody compared to general chatbots like ChatGPT is its tight integration with Sourcegraph. This gives Cody access to code examples and documentation from a developer's specific codebase to inform its responses. Developers can ask questions about their code and Cody will retrieve relevant snippets to provide contextually accurate answers. This prevents responses from being mere hallucinations like a general chatbot would provide.

Leveraging Large Language Models like Claude

Cody uses large language models like Claude under the hood to generate natural language responses. Claude was created by Anthropic to be especially adept at logical reasoning compared to other language models. Training language models like Claude on public code repositories gives them the unique ability to reason through problems and explain themselves logically. The open source ecosystem has been crucial for developing these thoughtful language models.

Validating Responses Against the Codebase

Cody takes the responses produced by Claude and validates them against the developer's actual codebase. This allows it to catch any hallucinations or inaccuracies in the raw language model output. By linking symbols and file names back to real code, Cody can verify the correctness of responses and improve them through this post-processing validation step.

Using Cody to Understand Itself

As an example of Cody in action, we can use it to understand how Cody itself works by pointing it at its own source code that was recently open sourced.

Cody can provide high-level summaries of its key files and functions by reading through the codebase. It can also generate things like unit tests and documentation stubs as a starting point for developers to build on.

By keeping up with recent commits, Cody can summarize code changes to quickly get developers up to speed with the latest updates.

Querying Relevant Files

Developers can ask Cody which files implement a certain feature, and it will search its own codebase to retrieve the relevant results. This saves developers time from having to grep through the code manually to find what they need.

Generating Suggestions

In addition to answering developer questions, Cody can proactively make suggestions like generating unit tests or documentation stubs for existing code. This gives developers a head start on improving code quality and maintaining the codebase.

Summarizing Recent Changes

By parsing recent commit logs, Cody can provide bullets summarizing the latest code changes to quickly get developers up to speed. This saves developers time from having to read through raw commit logs and pull request descriptions.

Open Sourcing Cody

Cody is 100% open source under the Apache 2 license. The code lives on GitHub alongside the core Sourcegraph repository.

Contributing instructions are provided to make it easy for developers to pitch in. Cody can be installed via Sourcegraph or directly from GitHub.

The Benefits of Open Source Tools

Open sourcing Cody fits with Sourcegraph's mission of empowering developers. Developers tend to prefer open tools that they can inspect and modify. Having the ability to contribute features and improvements makes for a more engaging, collaborative developer experience.

Contributing Back to the Open Source Ecosystem

Since language models like Claude were trained on open source code, open sourcing Cody represents giving back to that community. The open source ecosystem was crucial for developing thoughtful, logical language models. Releasing Cody's code publicly helps contribute back to that ecosystem.

Getting Started with Cody

Cody can be installed on Sourcegraph or directly via its GitHub repository. Simply fill out a request form to get access.

Feedback and suggestions are welcomed through the Cody Discord channel. The team is rapidly iterating to improve Cody based on user feedback.

Provide Feedback to Improve Cody

Cody is under active development and feedback is critical to improving it quickly. Bug reports, feature requests, and other comments can be provided via:

  • Cody's GitHub Discussions page

  • The #cody channel on Sourcegraph Discord

  • Tweeting at @srcclr

FAQ

Q: What code editors support Cody currently?
A: Cody is currently available as a plugin for Visual Studio Code. Support for more editors is planned for the future.

Q: Is Cody free to use?
A: Yes, Cody is 100% free and open source under the Apache 2 license.

Q: What programming languages does Cody support?
A: As of launch, Cody supports Python, JavaScript, TypeScript, Java, and Go, with more languages planned.

Q: Can Cody run code?
A: No, Cody does not execute code - it is intended for code comprehension, assistance, and suggestions rather than execution.

Q: Does Cody require access to private code?
A: No, Cody can provide value even without access to private proprietary code. However, it works best when integrated with Sourcegraph for code context.

Q: Is Cody based on GPT or other foundation models?
A: Cody utilizes Claude, an open source foundation model created by Anthropic.

Q: Can I contribute code to Cody?
A: Yes! As part of open sourcing Cody, contributions and pull requests are welcome.

Q: Who created Cody?
A: Cody was created by Sourcegraph, led by CEO Quinn Slack and CTO Beyang Liu.

Q: What's the benefit of Cody over AI assistants like ChatGPT?
A: Cody is specialized for code, integrating tightly with Sourcegraph for code context. This allows more accurate, relevant suggestions.

Q: Does Cody replace the need to understand code?
A: No - Cody is intended as an assistant, not a replacement for coding knowledge and skills.