# AI Code Assurance

SonarQube Cloud’s AI Code Assurance features help you set appropriate standards for projects containing AI-generated code. A combination of tools, including project labels, a default quality gate, and the availability of externally published project badges, lets you ensure that your AI projects are protected for security and code quality.

## Assuring your AI code <a href="#assuring-your-ai-code" id="assuring-your-ai-code"></a>

Sonar recognizes that AI-generated code should be monitored with additional quality standards. Recommended checks include high standards to reduce code complexity, remove bugs, and eliminate injection vulnerabilities. SonarQube’s AI Code Assurance features bring confidence that your AI-generated code is being reviewed to avoid any accountability crisis.

These objectives are achieved with three features that allow Quality Standard administrators to qualify projects as AI Code Assured:

1. [Set your AI standards](/sonarqube-cloud/standards/ai-code-assurance/overview.md#label-projects-with-ai-code)
2. [Set your AI standards](/sonarqube-cloud/standards/ai-code-assurance/overview.md#apply-a-quality-gate-for-ai-code-assurance)
3. Publish an AI Code Assurance badge externally to your websites. See the [Set your AI standards](/sonarqube-cloud/standards/ai-code-assurance/overview.md#monitor-projects-containing-ai-code) page for instructions.

The full details to setting up AI Code Assurance are outlined on the [Set your AI standards](/sonarqube-cloud/standards/ai-code-assurance/overview.md) page.

## Quality gates for AI code <a href="#quality-gates-for-ai-code" id="quality-gates-for-ai-code"></a>

Quality gates designed for projects containing AI-generated code are an important part of the quality control and review process. The [Quality gates for AI code](/sonarqube-cloud/standards/ai-code-assurance/quality-gates-for-ai-code.md) page outlines the important control measures that help protect against the buildup of new issues as you leverage AI assistance in your coding process, and adds an extra layer of protection helps catch vulnerabilities and critical reliability issues that could be lurking in your project.

## Quality profiles for AI code <a href="#quality-profiles-for-ai-code" id="quality-profiles-for-ai-code"></a>

When AI Code Assurance is enabled on a project, it should protect the AI-generated code by applying a suitable quality standard for developers to follow. Therefore, it’s important to define a set of rules that will offer the necessary protection to AI-generated code. To ensure protection of a project with AI code, the project should not only have a strict quality gate, but also a strict quality profile. The [Quality profiles for AI code](/sonarqube-cloud/standards/ai-code-assurance/quality-profiles-for-ai-code.md) page helps you define, for a given language, the set of coding rules to be applied during analysis.

## Autodetecting AI code <a href="#autodetecting-ai-code" id="autodetecting-ai-code"></a>

{% hint style="warning" %}
Autodetect AI code has been deprecated in SonarQube Cloud and will be dropped in a subsequent release.
{% endhint %}

Knowing if your project contains AI-generated code helps raise awareness of code ownership and code security. To help build this awareness, SonarQube Cloud can autodetect AI-generated code in projects on GitHub using GitHub Copilot. See the page about [Autodetect AI code](/sonarqube-cloud/ai-capabilities/autodetect-ai-code.md) for an overview.

If your SonarCloud Organization is integrated with GitHub and you’re using GitHub Copilot, your project is eligible for automatically detecting AI-generated code. For more information, see [Autodetect AI code](/sonarqube-cloud/administering-sonarcloud/ai-features/autodetect-ai-code.md).

## Monitoring your projects <a href="#monitoring-your-projects" id="monitoring-your-projects"></a>

If you’ve completed the steps above to apply AI Code Assured quality gates to your projects, a series of external badges are available to publish on your websites. For more details, please see the [Monitor projects with AI code](/sonarqube-cloud/standards/ai-code-assurance/monitor-projects-with-ai-code.md) page.

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

* Administering your [AI features](/sonarqube-cloud/administering-sonarcloud/ai-features.md) as an Organization Admin
* Learn about [AI CodeFix](/sonarqube-cloud/ai-capabilities/ai-codefix.md) to get AI-generated fix suggestions


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-cloud/ai-capabilities/ai-code-assurance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
