# Enable AI CodeFix

*AI features are only available in SonarQube Cloud Team and Enterprise plans*. See the [subscription-plans](https://docs.sonarsource.com/sonarqube-cloud/administering-sonarcloud/managing-subscription/subscription-plans "mention") page for more detail&#x73;*.*

SonarQube Cloud’s AI CodeFix is a feature that uses <code class="expression">space.vars.SQC\_Supported\_LLM\_version</code> to suggest fixes for a select set of rules in Java, JavaScript, TypeScript, Python, HTML, CSS, C#, and C++. See the [Sonar AI CodeFix terms](https://www.sonarsource.com/legal/ai-codefix-terms/) for details about the terms of access.

To learn more about which rules are eligible for AI CodeFix, please see the list of [#ai-codefix-rules](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-rules/rules-for-ai-codefix#ai-codefix-rules "mention").

## Sharing your code with Sonar <a href="#sharing-your-code-with-sonar" id="sharing-your-code-with-sonar"></a>

If you use Sonar’s AI CodeFix LLM, the affected code snippet will be sent by the AI CodeFix service to the selected LLM. Service agreements with Sonar’s LLMs prevent your code from being used to train those models.

For details about terms and conditions, please refer to the [AI CodeFix terms](https://www.sonarsource.com/legal/ai-codefix-terms/) in our [Legal Documentation](https://www.sonarsource.com/legal/).

## Enabling AI-generated fix suggestions <a href="#enabling-ai-generated-fix-suggestions" id="enabling-ai-generated-fix-suggestions"></a>

*AI CodeFix is a feature that generates AI-generated fix suggestions in SonarQube Cloud Team and Enterprise plans. It must be activated by an Organization Admin.*

As an Organization Admin, you can activate or deactivate AI-generated fix suggestions in your organization. This allows developers to get AI-based fix suggestions for the issues detected in their projects. To enable AI CodeFix:

1. Go to *Your Organization* > **Administration** > **AI capabilities** > **AI CodeFix** tab and select **Enable AI CodeFix**.
2. Select your provider:
   * <code class="expression">space.vars.SQC\_Supported\_LLM\_version</code>
3. Once AI CodeFix is enabled, select either **All projects** or **Only selected projects** to activate the feature.

Note that if you choose **Only selected projects**, new projects will not be automatically enabled.

{% hint style="warning" %}
Sonar recommends choosing Claude Sonnet 4 as your provider because it produces the best results. Using other models may produce unexpected fix suggestions that have undesirable effects.
{% endhint %}

## Getting AI-generated fix suggestions <a href="#getting-ai-generated-fix-suggestions" id="getting-ai-generated-fix-suggestions"></a>

Once AI CodeFix is enabled, users will be able to select **Generate AI Fix** on eligible issues and copy/paste the fix into their IDE with the **Open in IDE** feature when using [connected-mode](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/connected-mode "mention").

The easiest way to use AI CodeFix is by using AI CodeFix in your IDE. When SonarQube for [VS Code](https://app.gitbook.com/o/2ibCvzwZt86Nlk2zloB7/s/6LPRABg3ubAJhpfR5K0Y/ "mention") or SonarQube for [IntelliJ](https://app.gitbook.com/o/2ibCvzwZt86Nlk2zloB7/s/NvI4wotPmITyM0mnsmtp/ "mention") is set up in connected mode with with SonarQube Cloud, select an issue marked with the ![$ai-icon-sparkle](https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2Fgit-blob-975a17de7ce8ae3b164dd9f9db9c791adb294bbb%2F4be9087a2b059c269f15df202838af7a74e71a96.svg?alt=media) icon, open the **Rule description** > ![$ai-icon-sparkle](https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2Fgit-blob-975a17de7ce8ae3b164dd9f9db9c791adb294bbb%2F4be9087a2b059c269f15df202838af7a74e71a96.svg?alt=media)**AI CodeFix** tab, and select ![$ai-icon-sparkle](https://2223713658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FB4UT2GNiZKjtxFtcFAL7%2Fuploads%2Fgit-blob-975a17de7ce8ae3b164dd9f9db9c791adb294bbb%2F4be9087a2b059c269f15df202838af7a74e71a96.svg?alt=media)**Generate Fix**. A fix will be generated in the code editor and you’ll have a chance to **Apply** or **Decline** the suggestion.

See the [connected-mode](https://docs.sonarsource.com/sonarqube-cloud/analyzing-source-code/connected-mode "mention") page for information about connected mode.

* See the IntelliJ page for [AI CodeFix #AI CodeFix in your IDE](https://app.gitbook.com/s/NvI4wotPmITyM0mnsmtp/ai-capabilities/ai-codefix#ai-codefix "mention")
* See the VS Code page for [AI CodeFix #AI CodeFix in your IDE](https://app.gitbook.com/s/6LPRABg3ubAJhpfR5K0Y/ai-capabilities/ai-codefix#ai-codefix "mention")

For complete details about using AI CodeFix to fix your issues in SonarQube Cloud, see the article on [#getting-ai-generated-fix-suggestions](https://docs.sonarsource.com/sonarqube-cloud/managing-your-projects/issues/fixing#getting-ai-generated-fix-suggestions "mention").

## Usage limits <a href="#limits" id="limits"></a>

Limits are placed on the AI CodeFix feature to manage abuse. Developers will be notified directly when the monthly allocation is reached for your organization. If the instance is blocked due to reaching the allowance, users attempting to generate a fix will see an error message. Usage quotas are reset on the first day of each month.

## Marking a project as containing AI-generated code <a href="#marking-a-project-as-containing-ai-generated-code" id="marking-a-project-as-containing-ai-generated-code"></a>

Sonar recognizes that AI-generated code should be monitored with additional quality standards and offers administrators a series of project labels and custom quality gate certifications described on the [overview](https://docs.sonarsource.com/sonarqube-cloud/standards/ai-code-assurance/overview "mention") page.

## Related pages <a href="#related-pages" id="related-pages"></a>

* SonarQube Cloud's [ai-capabilities](https://docs.sonarsource.com/sonarqube-cloud/ai-capabilities "mention")
* [#ai-codefix-rules](https://docs.sonarsource.com/sonarqube-cloud/standards/managing-rules/rules-for-ai-codefix#ai-codefix-rules "mention")
* To learn about AI Code Assurance:
  * [overview](https://docs.sonarsource.com/sonarqube-cloud/standards/ai-code-assurance/overview "mention")
  * [#marking-a-project-as-containing-ai-generated-code](https://docs.sonarsource.com/sonarqube-cloud/ai-capabilities/ai-code-assurance#marking-a-project-as-containing-ai-generated-code "mention")
  * and use [quality-gates-for-ai-code](https://docs.sonarsource.com/sonarqube-cloud/standards/ai-code-assurance/quality-gates-for-ai-code "mention")
