> 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

`sonar system reset` returns the CLI to a factory-like state in one command. It removes saved tokens, auxiliary binaries, integration state, and cached files under `~/.sonar/sonarqube-cli`. Your telemetry preference in `state.json` is preserved.

> **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
```

You'll see a warning, then a prompt to type `RESET` to confirm. 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
```

## What gets removed

The command runs four phases and prints a summary for each:

| 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.     |
| **Filesystem**     | Clears CLI logs, the SCA scanner cache, and globally installed Git hook scripts under `~/.sonar/sonarqube-cli/`.                             |

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.

## 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).
* Your telemetry enabled/disabled preference in `state.json`.

## 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 couldn't 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. You can 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 <a href="#related-pages" id="related-pages"></a>

* [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)
* [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 dynamically by asking a question.

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

```
GET https://docs.sonarsource.com/sonarqube-cli/administration/system-reset.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
