Code Suggestions

CodiumAI is an advanced tool that goes beyond merely generating test suites for your code. One of the features that CodiumAI provides us is "Code Suggestions," and it can thoroughly analyze your code and provide valuable insights for potential improvements.

It uses TestGPT to power up this feature, and its expertise extends to various aspects of code quality.

Note: Currently available only on VS Code editor.

Code <span class="gradient-text">Suggestions<span>


The Code Suggestions feature can identify potential logical or syntactical errors in your code and suggest modifications to rectify them. It carefully examines the code structure, variable usage, and control flow to ensure your program functions as intended.

Best Practices:

Regarding best practices, CodiumAI leverages its extensive knowledge of coding conventions and industry standards to provide suggestions that align with established guidelines. It can recommend improvements such as using consistent naming conventions, following modular and maintainable code structures and employing efficient algorithms and data structures.


Enhancing security is another vital aspect addressed by this feature. It has been trained on security practices and vulnerability patterns, allowing it to identify potential weaknesses in your code that malicious actors could exploit. It can suggest security measures like input validation, proper handling of sensitive data, and protection against common security vulnerabilities, such as injection attacks or cross-site scripting.

Vulnerability detection and removal:

Furthermore, CodiumAI excels at detecting and eliminating vulnerabilities that could pose a risk to your codebase. It scans your code for potential security flaws, deprecated functions, or outdated libraries and provides suggestions to address these issues effectively.

Proactively identifying and resolving vulnerabilities helps fortify your code against potential threats.

Getting Started


Code Suggestion feature

To get started with the Code Suggestion feature, navigate to the "Code Suggestion" tab next to the Code Analysis tab.

VS Code
Codium - VS Code

Different components of a suggestion.


Code Suggestions section

Once you enter the Code Suggestions section, you can see all the suggestions the TestGPT model provides. If you explore the recommendations individually, you can see that each consists of standard components such as Suggestion, Reason (Why), Tag, Base code, and Suggested code.


This section includes the task you should do to improve the quality of our code.

Reason (Why):

By reading the content of this section, you can have a clear idea about the importance of the suggestion.


By looking at the tag, you can determine whether the provided suggestion is a best practice, Correctness, etc. Therefore, you can prioritize them as you need.

Base code:

This shows your existing code.

Suggested code:

In this section, you will get an updated version of your code. It includes the changes required for the suggestion. The base and Suggested codes are located next to each other so you can compare your existing code with the suggested code.

Example: A suggestion generated by the "Code Suggestions" feature for a function that will take two numbers and return their sum.

VS Code
Codium - VS Code

Applying Suggestions

After going through the provided suggestions, you can now choose the suggestions you need and apply them to your code. There are several ways to add these changes.


Method 1: Select one or more suggestions.

You can manually select the suggestions you only need by following these steps.

  1. Select the suggestion(s) to be applied (Use the check box above the suggestion to select).
  2. Click the "Prepare Code Changes" button.
  3. Click the "Apply to my code" button or view it separately by selecting the "Open in a new file" option.
  4. Close the CodiumAI panel and generate the tests again. Refer to “Generate Tests” feature for more details.
VS Code
Codium - VS Code

Method 2: Select all suggestions.

If you want all the suggestions in your code, follow the steps below.

  1. Click the "Select all" option.
  2. Click the "Prepare Code Changes" button to merge the changes.
  3. Click the "Apply to my code" button or view it separately by selecting the "Open in a new file" option.
  4. Click the "Regenerate Tests and Code Suggestions" button to regenerate the tests and code suggestions.

Method 3: Use the copy icon.

Instead of applying the suggested code automatically, you can,

  1. Click the copy button of your desired suggestion.
  2. Paste it to replace your code with it.
  3. Regenerate the test suite.

Each suggestion has a copy button located at the bottom right corner.

VS Code
Codium - VS Code

Now you have quality, improved code that includes best practices, improved security and Correctness, and vulnerability free for testing. This will assist you in upholding the code's quality and ensuring its optimal performance.


Check out other features

Gain insights into the range of innovative features that CodiumAI brings to your development toolkit, all designed to ensure superior code integrity and efficiency.