> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-server/8.9/project-administration/defining-new-code.md).

# Defining New Code

Define what counts as new code in SonarQube Server 8.9 to apply consistent quality and security standards to the code you add or change.

{% hint style="info" %}
**For AI agents:** You're in the SonarQube Server 8.9 documentation. For a list of all 8.9 pages, see the [SonarQube Server 8.9 page index](https://4108688904-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FG0n8jfxwZN8LmyH08dMa%2Fuploads%2F8WN59Z2YOHCj6T8O2i2L%2Fsonarqube-server-8.9-llms.txt?alt=media). For the whole site, see the [page index](https://docs.sonarsource.com/llms.txt) or the [full text](https://docs.sonarsource.com/llms-full.txt). For another version, replace 8.9 in the URL with that version. The [latest version](https://docs.sonarsource.com/sonarqube-server/) has no version number in its URL.
{% endhint %}

Defining what is considered *new code* helps you apply consistent quality and security standards to the code you add or change. By focusing on code that’s been added or changed since your new code definition, you can set clear quality requirements and expectations. Your new code should meet those standards, and you’ll improve older code as you touch it. For more information on new code and why it’s important, check out [Quality standards and new code](/sonarqube-server/8.9/user-guide/clean-as-you-code.md).

## Setting your New Code definition <a href="#setting-your-new-code-definition" id="setting-your-new-code-definition"></a>

You can define new code at the global, project, or branch level.

* **Global level**\
  You can set a global new code definition at **Administration > Configuration > General Settings > New Code**. What you define as new code at the global level will be the default for your projects.
* **Project level**\
  You can set a new code definition for your project at **Project Settings > New Code**. What you define as new code at the project level will be the default for the project’s branches if you’re using an edition that supports multiple branches (starting in [Developer Edition](https://www.sonarsource.com/plans-and-pricing/developer/)).
* **Branch level**\
  You can define New Code for each branch from the **Actions** column of the branches table on the project’s **New Code** settings page if you’re using an edition that supports multiple branches (starting in [Developer Edition](https://www.sonarsource.com/plans-and-pricing/developer/)).

## New code definitions <a href="#new-code-definitions" id="new-code-definitions"></a>

You can define new code as changes from a previous version, a specific analysis, a reference branch, or within a specific period (number of days):

* **Previous Version** – Define new code as any changes made in your project’s current version. This works well for projects with regular versions or releases. Available at the global, project, and branch level.
* **Specific analysis** – Choose a previous analysis as your new code definition. Any changes made since that analysis are considered new code. Available at the branch level starting in [Developer Edition](https://www.sonarsource.com/plans-and-pricing/developer/) and the project level for community edition.

{% hint style="info" %}
For SonarQube Community Build, past analysis is available at the project-level because SonarQube Community Build doesn’t support multiple branches. Starting in [**Developer Edition**](https://www.sonarsource.com/plans-and-pricing/developer/), you can do this at the branch level, and each branch can be set to one of the branch’s specific past analyses.
{% endhint %}

* **Reference Branch** – Choose a specific branch to define your new code. Any changes made from your reference branch are considered new code. Available at the project and branch level. See the [Analysis parameters](/sonarqube-server/8.9/analyzing-source-code/analysis-parameters.md).
* **Number of days** – Specify a number of days for a floating new code period. For example, setting **Number of Days** to 30 creates a floating new code period beginning 30 days from the current date. Available at the global, project, and branch level.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sonarsource.com/sonarqube-server/8.9/project-administration/defining-new-code.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
