A CLI application for interacting with SonarQube products.
Beta Notice: This product is currently in Beta, and we are actively collecting feedback on it. Please share your thoughts via this form!
Linux/Mac OS:
curl -o- https://raw.githubusercontent.com/SonarSource/sonarqube-cli/refs/heads/master/user-scripts/install.sh | bashWindows (from PowerShell):
irm https://raw.githubusercontent.com/SonarSource/sonarqube-cli/refs/heads/master/user-scripts/install.ps1 | iexBelow is an example of a setup which will work for SonarQube Cloud. The authentication step is optional. With authentication, more types of secrets can be detected.
sonar auth login
sonar install secrets
sonar integrate claude -g
Manage authentication tokens and credentials
Save authentication token to keychain
Options:
| Option | Type | Required | Description | Default |
|---|---|---|---|---|
--server, -s |
string | No | SonarQube URL (default is SonarQube https://sonarcloud.io) | - |
--org, -o |
string | No | SonarQube Cloud organization key (required for SonarQube Cloud) | - |
--with-token, -t |
string | No | Token value (skips browser, non-interactive mode) | - |
Examples:
Interactive login for SonarQube Cloud with browser
sonar auth loginNon-interactive login with direct token
sonar auth login -o my-org -t squ_abc123Non-interactive login for custom server with token
sonar auth login -s https://my-sonarqube.io --with-token squ_def456Remove authentication token from keychain
Options:
| Option | Type | Required | Description | Default |
|---|---|---|---|---|
--server, -s |
string | No | SonarQube server URL | - |
--org, -o |
string | No | SonarQube Cloud organization key (required for SonarQube Cloud) | - |
Examples:
Remove token for SonarQube Cloud organization
sonar auth logout -o my-orgRemove token for custom SonarQube server
sonar auth logout -s https://my-sonarqube.ioRemove all authentication tokens from keychain
Examples:
Interactively remove all saved tokens
sonar auth purgeShow active authentication connection with token verification
Examples:
Show current server connection and token status
sonar auth statusInstall Sonar tools
Install sonar-secrets binary from https://binaries.sonarsource.com
Options:
| Option | Type | Required | Description | Default |
|---|---|---|---|---|
--force |
boolean | No | Force reinstall even if already installed | - |
--status |
boolean | No | Check installation status instead of installing | - |
Examples:
Install latest sonar-secrets binary
sonar install secretsReinstall sonar-secrets (overwrite existing)
sonar install secrets --forceCheck if sonar-secrets is installed and up to date
sonar install secrets --statusSetup SonarQube integration for AI coding agents, git and others.
Examples:
Integrate Claude Code with interactive setup
sonar integrate claude -s https://sonarcloud.io -p my-projectIntegrate globally and install hooks to ~/.claude which will be available for all projects
sonar integrate claude -gSetup SonarQube integration for Claude Code. This will install secrets scanning hooks, and configure SonarQube MCP Server.
Options:
| Option | Type | Required | Description | Default |
|---|---|---|---|---|
--server, -s |
string | No | SonarQube server URL | - |
--project, -p |
string | No | Project key | - |
--token, -t |
string | No | Existing authentication token | - |
--org, -o |
string | No | Organization key (for SonarQube Cloud) | - |
--non-interactive |
boolean | No | Non-interactive mode (no prompts) | - |
--global, -g |
boolean | No | Install hooks and config globally to ~/.claude instead of project directory | - |
List Sonar resources
Search for issues in SonarQube
Options:
| Option | Type | Required | Description | Default |
|---|---|---|---|---|
--project, -p |
string | Yes | Project key | - |
--severity |
string | No | Filter by severity | - |
--format |
string | No | Output format | json |
--branch |
string | No | Branch name | - |
--pull-request |
string | No | Pull request ID | - |
--page-size |
number | No | Page size (1-500) | 500 |
--page |
number | No | Page number | 1 |
Examples:
List issues in a project
sonar list issues -p my-projectOutput issues in TOON format for AI agents
sonar list issues -p my-project --format toonSearch for projects in SonarQube
Options:
| Option | Type | Required | Description | Default |
|---|---|---|---|---|
--query, -q |
string | No | Search query to filter projects by name or key | - |
--page |
number | No | Page number | 1 |
--page-size |
number | No | Page size (1-500) | 500 |
Examples:
List first 500 accessible projects
sonar list projectsSearch projects by name or key
sonar list projects -q my-projectPaginate through projects
sonar list projects --page 2 --page-size 50Analyze code for security issues
Scan a file or stdin for hardcoded secrets
Options:
| Option | Type | Required | Description | Default |
|---|---|---|---|---|
--file |
string | No | File path to scan for secrets | - |
--stdin |
boolean | No | Read from standard input instead of a file | - |
Examples:
Scan a file for hardcoded secrets
sonar analyze secrets --file src/config.tsScan stdin for hardcoded secrets
cat .env | sonar analyze secrets --stdinConfigure CLI settings
Configure telemetry settings
Options:
| Option | Type | Required | Description | Default |
|---|---|---|---|---|
--enabled |
boolean | No | Enable collection of anonymous usage statistics | - |
--disabled |
boolean | No | Disable collection of anonymous usage statistics | - |
Examples:
Enable collection of anonymous usage statistics
sonar config telemetry --enabledDisable collection of anonymous usage statistics
sonar config telemetry --disabledstring— text value (e.g.--server https://sonarcloud.io)boolean— flag (e.g.--verbose)number— numeric value (e.g.--page-size 100)array— multiple values (e.g.--tags tag1 tag2)
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (validation, execution, etc.) |
See State Management for more information.
Please be aware that we are not actively looking for feature contributions. The truth is that it's extremely difficult for someone outside SonarSource to comply with our roadmap and expectations. Therefore, we typically only accept minor cosmetic changes and typo fixes.
See CONTRIBUTING.md for setup instructions, coding guidelines, and how to run tests.
Copyright 2026 SonarSource Sàrl.
SonarQube CLI is released under the GNU Lesser General Public License, Version 3.0,.
Generated from src/cli/command-tree.ts — do not edit manually