Codeium Chat enables you to chat with your Codebase in natural language from inside your IDE itself. It leverages code snippets from the relevant parts of your codebase to provide the most accurate, and grounded answers. It's like ChatGPT if it had full context about your codebase. You can open Codeium Chat from the Codeium side panel or use the shortcut Shift + Cmd + A.
@mentions
Codeium Chat will automatically pull the relevant code snippets from your codebase in as context based on your request. However, Chat also allows you to @mention classes, files, and functions from your codebases in your prompt. Doing so explicitly tells Codeium to pull those snippets in as context and return the most relevant suggestions. This allows developers to deterministically set the context that Chat will use for its response to the prompt.
This is very useful when you are working with particular libraries as shown below:
You can also @mention classes as shown below:
Code Lenses
Code lenses will appear right above functions and class definitions and offer shortcuts to common tasks that developers want to accomplish such as Generate Docstrings, Explain Code, and Refactor code. Clicking on these shortcuts will automatically invoke Codeium Chat with the relevant prompt and context, giving developers a 1-click solution for common tasks.
Common Chat use cases
You can use Chat for a variety of situations:
- Writing boilerplate code. Often times you need to write some boilerplate code that either mirrors existing code in your database (ex: you are writing another API endpoint with a similar interface to existing endpoints) or create function headers. You can have Chat draft this for you through simple prompts such as "Write a function that takes in parameters X and Y, performs A,B,C operations and returns Z".
- Writing a unit test for a function. You can prompt Chat to do this by typing "Write a unit test for @function-name that tests all edge cases for X and Y".
- Writing good comments and doc strings. You can prompt Chat to do this by typing "Write a docstring for @function-name."
- Explaining code. Often times new or junior engineers will be ramping up on a codebase. Instead of asking senior engineers for explanation of how code works, they can instead ask Chat "Explain @function".
Best Practices
- There are 3 Components of a high quality prompt:
- Clear objective or outcome
- What are you asking the model to produce?
- A natural language plan? Code? Is it a refactor? Or is this net new code?
- All relevant context to perform the work
- Have you properly used @ mentions to point Codeium in the right direction?
- Given the context, is it actually clear what that code does? Is there anything JPMC specific about it?
- Necessary constraints
- Are there any specific frameworks or languages you need utilized?
- Any space or time complexity constraints? Security considerations?
- Clear objective or outcome
- Example #1:
- Bad: Write unit tests for all test cases for an Order Book object
- Good: Using @class:testing-module write unit tests for @func:divide-numbers testing for exceptions thrown when denominator is 0
- Example #2:
- Bad: Refactor rawDataTransform
- Good: Refactor @func:rawDataTransform by turning the while loop into a for loop and using the same data structure output as @func:otherDataTransformer
- Example #3:
- Bad: Create a new Button for the Contact Form.
- Good: Create a new Button component for the @class:ContactForm using the style guide in @repo:frontend-components that says “Continue”