> 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-cli/administration/system-reset.md).

# Reset the CLI

Reset the SonarQube CLI to factory defaults with sonar system reset, removing tokens, binaries, integrations, and cached files.

`sonar system reset` returns the CLI to a factory-like state in one command. It removes saved tokens, auxiliary binaries, integration state, cached files, and the local stats database under `~/.sonar/sonarqube-cli`. `sonar config` settings, including `telemetry.enabled` and `stats.enabled`, are kept unless you pass `--all`.

> **Warning:** Reset removes local credentials and breaks active integrations. Server-side user tokens may still exist until you revoke them in SonarQube.

## Interactive reset

```bash
sonar system reset
sonar system reset --all
```

You'll see a warning, then a prompt to type `RESET` to confirm. With `--all`, the warning also says that `sonar config` settings will be removed. If you cancel or mistype the confirmation, the command exits without making changes.

## Non-interactive reset

Non-interactive environments have no TTY, so the confirmation prompt is skipped unless you pass `--force`:

```bash
sonar system reset --force
sonar system reset --force --all
```

## What gets removed

The command runs five phases and prints a summary for each. Pass `--all` to add a Config phase:

| Phase          | What it does                                                                                                                                                                                                                                                                              |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Authentication | Removes every saved connection from the keychain and best-effort revokes server-side user tokens when the CLI knows the token name.                                                                                                                                                       |
| Binaries       | Uninstalls auxiliary binaries under `~/.sonar/sonarqube-cli/bin/` (for example, the secrets engine and SCA scanner) that the CLI downloaded.                                                                                                                                              |
| Integrations   | Tears down declarative installs from `sonar integrate` (hooks, MCP entries, patches, and related config) for all supported integrations. Deletes config files that held only Sonar-managed content; keeps files when your own or other content remains.                                   |
| Filesystem     | Clears CLI logs, the SCA scanner cache, temporary files under `cli-tmp/` (for example, converted MCP client keystores), and globally installed Git hook scripts under `~/.sonar/sonarqube-cli/`.                                                                                          |
| Stats          | Deletes the local stats database under `~/.sonar/sonarqube-cli/db/stats/`.                                                                                                                                                                                                                |
| Config         | Runs only with `--all`. Removes the CLI configuration file, including `telemetry.enabled` and `stats.enabled`, and sensitive configuration values in the keychain (network proxy and client-certificate settings). Prints that there is nothing to clear when no configuration is stored. |

Reset updates `state.json` to match what was removed. Legacy entries in `agents` and `agentExtensions` are cleared from state; artifacts from CLI versions before the declarative integration framework are not guaranteed to be removed from disk. The same applies to any project-level integration files the CLI has no record of, such as files inherited by cloning a repository. See [Orphaned integration files](/sonarqube-cli/integrations/orphaned-integrations.md).

## What reset keeps

* The `sonar` binary installed by the [install script](https://github.com/SonarSource/sonarqube-cli) (`~/.local/share/sonarqube-cli` on macOS/Linux, `%LOCALAPPDATA%\sonarqube-cli` on Windows).
* `sonar config` settings, including `telemetry.enabled` and `stats.enabled`, unless you pass `--all`. `--all` removes `cli-config.properties`, so collection is enabled again until you set the keys.

## Exit codes

`sonar system reset` exits `0` once it finishes, whether or not every phase succeeded. If a phase reports a warning (for example, a keychain entry that could not be deleted), the CLI prints "System reset completed with warnings" and still exits `0`. Review the summary and clean up the remaining items manually.

`sonar system reset` does not require authentication. Run it when `sonar auth login` is broken or tokens are invalid.

## Reset versus uninstall

| Goal                                                                  | Command / approach                                                        |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| Clear credentials, tools, and integrations but keep `sonar` on `PATH` | `sonar system reset`                                                      |
| Remove the CLI binary, PATH entry, and all data                       | [Uninstalling](/sonarqube-cli/administration/uninstall.md) (manual steps) |

## Related pages

* [Check system status](/sonarqube-cli/administration/system-status.md)
* [State and storage](/sonarqube-cli/administration/state-and-storage.md)
* [Uninstalling](/sonarqube-cli/administration/uninstall.md)
* [Orphaned integration files](/sonarqube-cli/integrations/orphaned-integrations.md)
* [Commands reference](/sonarqube-cli/using-sonarqube-cli/commands.md)


---

# 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-cli/administration/system-reset.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.
