Commands reference
A complete reference for SonarQube CLI commands, with arguments, options, defaults, and examples.
This page documents every SonarQube CLI command. Find the full SonarQube CLI command reference, including options and examples, at sonarsource.com/sonarqube/cli. A machine-readable version of the command reference is also available as JSON at sonarsource.com/sonarqube/cli/data/commands.json.
Each entry includes a description, the arguments and options it accepts (with types, defaults, and whether they are required), and runnable examples.
Commands at a glance
Authentication
sonar auth login, logout, status
Integrations
sonar integrate, integrate claude, copilot, codex, cursor, antigravity, git
Analysis
sonar analyze, analyze secrets, analyze agentic, analyze dependency-risks, remediate
Information
sonar list issues, list projects, api, context
Configuration
sonar config telemetry
Maintenance
sonar system status, system reset, self-update (standalone builds only)
sonar auth
Manage authentication tokens and credentials.
sonar api
Make authenticated API requests to SonarQube.
sonar integrate
Set up SonarQube integration for AI coding agents, git, and others.
sonar list
List issues and projects from SonarQube.
sonar context
Augment AI agents with context from your codebase.
sonar remediate
Trigger AI agent remediation for eligible issues (SonarQube Cloud only).
sonar analyze
Run secrets scanning and Sonar Vortex agentic analysis on the local change set (default when no subcommand is given); subcommands cover SCA and targeted scans.
sonar config
Configure CLI settings.
sonar system
System diagnostics and maintenance (status, reset).
sonar self-update
Update SonarQube CLI to the latest version (standalone builds only).
sonar auth
sonar authManage authentication tokens and credentials.
sonar auth login
sonar auth loginAuthenticate via browser and save credentials in the system keychain. Must be run manually; AI agents can't complete this flow. For CI/CD and automation, use environment variables instead.
Options:
--server, -s
string
No
Your SonarQube Server URL, SonarQube Cloud EU (https://sonarcloud.io), or SonarQube Cloud US (https://sonarqube.us). When omitted, the CLI prompts you to choose server and region.
-
--org, -o
string
No
Your SonarQube Cloud organization key. If omitted when authenticating to SonarQube Cloud, the CLI auto-selects your organization when you belong to exactly one, or prompts you to choose when you belong to multiple organizations.
-
Examples:
Interactive login (prompts for server type, region, and organization):
Interactive login with a pre-selected server (skips the server and region prompts):
For CI/CD pipelines and headless environments, use environment variables instead of sonar auth login.
sonar auth logout
sonar auth logoutRemove the active connection token from the keychain. The CLI also best-effort revokes the token server-side when it was created via the interactive browser flow.
Examples:
sonar auth status
sonar auth statusShow the active authentication connection and verify the token against the server. When the server cannot be reached, the command prints the underlying network or TLS error (for example, a connection timeout) alongside the remediation hint.
Examples:
sonar integrate
sonar integrateSet up SonarQube integration for AI coding agents, Git, and other tools. For step-by-step setup guides, see Overview.
Running sonar integrate with no subcommand prompts you to select one integration (Claude Code, Copilot, Codex, Cursor, Antigravity, or Git), then runs that integration's interactive setup flow. To configure another tool, run sonar integrate again. You can also call a subcommand directly (for example, sonar integrate claude).
Options:
--project, -p
string
No
Project key. Mutually exclusive with --global.
-
--global, -g
boolean
No
Install the selected integration globally instead of in the project directory.
-
Note:
--projectand--globalare mutually exclusive. Passing both fails with an invalid-options error (exit code2).
When neither --global nor --project is set, interactive runs prompt for install scope (project vs global) after you select a tool. Non-interactive runs default to project scope. See Project versus global scope.
Examples:
sonar integrate claude
sonar integrate claudeInstalls secrets-detection hooks and the SonarQube MCP server. On SonarQube Cloud, also sets up Sonar Vortex agentic analysis and context augmentation. See Claude Code.
Options:
--project, -p
string
No
Project key. Ignored when --global is used.
-
--non-interactive
boolean
No
Non-interactive mode (no prompts).
-
--global, -g
boolean
No
Install hooks and config globally to ~/.claude instead of project directory.
-
--skip-context
boolean
No
Skip the Sonar Vortex context augmentation install and skill setup.
-
Examples:
sonar integrate copilot
sonar integrate copilotSet up the SonarQube integration for GitHub Copilot. Installs secrets-detection hooks and the SonarQube MCP server. On SonarQube Cloud, also sets up Sonar Vortex agentic analysis and context augmentation.
Options:
--global, -g
boolean
No
Install hooks and config globally to ~/.copilot instead of project directory.
-
--project, -p
string
No
Project key. Mutually exclusive with --global.
-
--non-interactive
boolean
No
Non-interactive mode (no prompts).
-
--skip-context
boolean
No
Skip the Sonar Vortex context augmentation install and skill setup.
-
Examples:
sonar integrate codex
sonar integrate codexSet up the SonarQube integration for OpenAI Codex. Installs a UserPromptSubmit secrets hook, secrets-on-read instructions, and MCP configuration. On SonarQube Cloud with an active entitlement, also installs a Sonar Vortex agentic analysis PostToolUse hook and Sonar Vortex context augmentation. See OpenAI Codex.
Options:
--project, -p
string
No
Project key. Mutually exclusive with --global.
-
--global, -g
boolean
No
Install hook and config globally to ~/.codex instead of project directory.
-
--non-interactive
boolean
No
Non-interactive mode (no prompts).
-
--skip-context
boolean
No
Skip Sonar Vortex context augmentation install and skill setup.
-
Examples:
sonar integrate cursor
sonar integrate cursorSet up the SonarQube integration for Cursor. Installs beforeSubmitPrompt, beforeReadFile, and preToolUse secrets hooks, and MCP configuration. On SonarQube Cloud with an active entitlement, also installs Sonar Vortex agentic analysis instructions and Sonar Vortex context augmentation. See Cursor.
Options:
--project, -p
string
No
Project key. Mutually exclusive with --global.
-
--global, -g
boolean
No
Install hooks and config globally to ~/.cursor instead of project directory.
-
--non-interactive
boolean
No
Non-interactive mode (no prompts).
-
--skip-context
boolean
No
Skip Sonar Vortex context augmentation install and skill setup.
-
Examples:
sonar integrate antigravity
sonar integrate antigravitySet up the SonarQube integration for Google Antigravity. Installs a PreToolUse secrets hook, prompt-secrets rules, and MCP configuration. On SonarQube Cloud with an active entitlement, also installs Sonar Vortex agentic analysis rules and Sonar Vortex context augmentation. See Google Antigravity.
Options:
--project, -p
string
No
Project key. Mutually exclusive with --global.
-
--global, -g
boolean
No
Install hooks and config globally under ~/.gemini/config/ instead of the project directory.
-
--non-interactive
boolean
No
Non-interactive mode (no prompts).
-
--skip-context
boolean
No
Skip Sonar Vortex context augmentation install and skill setup.
-
Examples:
sonar integrate git
sonar integrate gitInstall a Git pre-commit hook that scans staged files for secrets and dependency risks before each commit, or a Git pre-push hook that scans committed files for secrets before each push. On project-scoped installs, auto-detects the SonarQube project key when you omit -p (see Git hooks). In an interactive terminal, prompts separately for each code scanning hook type.
Options:
--hook
string
No
Hook to install: pre-commit (scan staged files) or pre-push (scan files in unpushed commits).
-
--force
boolean
No
Overwrite an existing hook if it isn't from sonar integrate git.
-
--non-interactive
boolean
No
Non-interactive mode (no prompts).
-
--global
boolean
No
Install hook globally for all repositories (sets git config --global core.hooksPath).
-
--dependency-risks
boolean
No
Also install a pre-commit dependency-risks scan when SCA is available on the connection (requires a project key; not supported with --global).
-
--project, -p
string
No
SonarQube project key (overrides auto-detected project; required with --dependency-risks when no key is detected).
-
Examples:
Analysis
sonar analyze
sonar analyzeRun every analysis the CLI supports on your local change set: secrets scanning first, then agentic analysis (SonarQube Cloud only). This is the recommended command before a commit or pull request. See Analyzing local changes.
Options:
--file
string
No
Analyze specific file(s) instead of the git change set (repeatable).
-
--staged
boolean
No
Analyze staged files only (git diff --cached).
-
--base
string
No
Analyze files changed vs a branch or ref (e.g. main).
-
--depth
string
No
Analysis depth (STANDARD, DEEP). Default: STANDARD for one --file; DEEP otherwise.
-
--project, -p
string
No
SonarQube Cloud project key (overrides auto-detected project).
-
--force
boolean
No
Skip the large change-set confirmation prompt.
-
--format
string
No
Output format (text, json).
text
Note:
--branchis available onsonar analyze agenticbut not on the baresonar analyzecommand. Usesonar analyze agenticwhen you need to set branch context.
Examples:
sonar analyze secrets
sonar analyze secretsScan files or standard input for hardcoded secrets.
Arguments:
[paths…]
File or directory paths to scan for secrets.
Options:
--stdin
boolean
No
Read from standard input instead of paths.
-
Exit behavior: exits with code 51 when secrets are found, 0 when none are found. See Exit codes.
Examples:
Scan a file:
Scan a directory:
Scan stdin:
Custom secret rules from SonarQube Server
When the SonarQube CLI is authenticated, sonar analyze secrets automatically downloads and executes custom secret rules (instances of rule template S6784) defined on the connected SonarQube Server instance. Rules are cached locally and refreshed on each run. If the download fails, the SonarQube CLI falls back to a stale cache with a warning. No CLI flag is required. Custom secret rules are not yet available on SonarQube Cloud; support is planned.
sonar analyze agentic
sonar analyze agenticRun server-side Sonar Vortex agentic analysis on local changes (SonarQube Cloud only). Limitations apply; see Agentic analysis on sonarsource.com.
Options:
--file
string
No
Analyze specific file(s) instead of the git change set (repeatable).
-
--staged
boolean
No
Analyze staged files only (git diff --cached).
-
--base
string
No
Analyze files changed vs a branch or ref (e.g. main).
-
--branch
string
No
Branch name for analysis context.
-
--depth
string
No
Analysis depth (STANDARD, DEEP). Default: STANDARD for one --file; DEEP otherwise.
-
--project, -p
string
No
SonarQube Cloud project key (overrides auto-detected project).
-
--force
boolean
No
Skip the large change-set confirmation prompt.
-
--format
string
No
Output format (text, json).
text
Notes:
The CLI prompts for confirmation when the change set exceeds 50 files. Pass
--forceto skip the prompt, or use--format json(which suppresses the prompt automatically).Agentic analysis sends your change set in a single multi-file request so a
DEEPanalysis can catch cross-file issues. If the request is too large, the CLI splits the files into smaller batches and sends them automatically (which can reduce cross-file context for that run).
Exit behavior: exits with code 51 when issues are reported. See Exit codes.
Examples:
sonar analyze dependency-risks
sonar analyze dependency-risksRun Software Composition Analysis (SCA) against the project's dependencies and report unresolved dependency risks (vulnerabilities, malware, and prohibited licenses). This command is in beta and subject to change. Requires SonarQube Advanced Security with SCA enabled on the project (SonarQube Cloud). For the full workflow, see Software Composition Analysis (SCA).
Options:
--project, -p
string
No
Project key (auto-detected when omitted).
-
--statuses
string
No
Filter by status. Accepts presets (active → NEW,OPEN,CONFIRM; to_fix → NEW,OPEN,CONFIRM,ACCEPT; all → NEW,OPEN,CONFIRM,ACCEPT,SAFE,FIXED) and raw statuses (NEW, OPEN, CONFIRM, ACCEPT, SAFE, FIXED). Comma-separated; case-insensitive; result is the union of every token.
active
--min-severity
string
No
Minimum severity to include (BLOCKER, HIGH, MEDIUM, LOW, INFO). Risks below the threshold are excluded. Case-insensitive.
all severities
Exit behavior: exits with code 51 when unresolved risks are found, 1 on analysis errors, 0 otherwise. See Exit codes.
Note: First run downloads scanner binaries. SonarQube CLI fetches the
sca-scanner-cliandsonar-secretsbinaries frombinaries.sonarsource.comand caches them under~/.sonar/sonarqube-cli/bin/. Subsequent runs reuse the cached binaries.
Note: Dependency manifest files (for example,
package-lock.jsonorpom.xml) are uploaded to SonarQube for analysis. Before the SCA scan, manifest files are pre-scanned for hardcoded secrets; if any are found, the command aborts. Seesonar analyze dependency-risks --helpfor the upload notice and Supported languages and package managers in the SonarQube Advanced Security documentation.
Examples:
sonar remediate
sonar remediateTrigger AI-agent remediation for eligible issues (SonarQube Cloud only). Eligibility is determined server-side: only issues the Remediation Agent can fix are surfaced.
Options:
--project, -p
string
No
SonarQube Cloud project key (overrides auto-detected project).
-
--issues
string
No
Comma-separated issue keys to remediate non-interactively (max 20). Required when stdin is not a TTY.
-
Examples:
Pick issues interactively:
Non-interactively remediate specific issues (suitable for scripts):
Exit behavior: exits with code 0 when your organization is not eligible for or has not enabled the Remediation Agent (the CLI prints an informational message instead of failing). Exits with code 1 on other errors. See AI remediation and Exit codes.
Information
sonar list issues
sonar list issuesSearch for issues in a SonarQube project.
Options:
--project, -p
string
Yes
Project key.
-
--statuses
string
No
Filter by status (comma-separated list of: OPEN, CONFIRMED, FALSE_POSITIVE, ACCEPTED, FIXED).
-
--severities
string
No
Filter by severity. Valid values depend on the connected server's mode—Multi-Quality Rule (MQR) mode: INFO, LOW, MEDIUM, HIGH, BLOCKER; Standard Experience mode: INFO, MINOR, MAJOR, CRITICAL, BLOCKER.
-
--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:
Output issues in TOON format for AI agents:
sonar list projects
sonar list projectsSearch for projects the active token can access.
Options:
--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
Output is always JSON. Pipe through jq if you need to transform it.
Examples:
sonar api
sonar apiMake authenticated requests to any SonarQube Web API endpoint. Useful for advanced workflows that aren't covered by other commands.
Arguments:
<method>
HTTP method (get, post, patch, put, delete).
<endpoint>
API endpoint path. Must start with / and can contain query parameters.
Options:
--data, -d
string
No
JSON string for the request body. See request body encoding below.
-
--verbose, -v
boolean
No
Print request and response details for debugging.
-
Note: Request body encoding. The CLI picks an encoding based on the endpoint path:
Endpoints starting with
/api/v2/, or endpoints that don't start with/api/, receive a JSON body (Content-Type: application/json).All other endpoints (the SonarQube Web API v1, paths under
/api/) receive URL-encoded form data (Content-Type: application/x-www-form-urlencoded).This matches what each Web API endpoint expects. You don't need to override it.
Examples:
List favorite projects:
Search for rules in an organization:
Generate a new user token:
Accept an issue:
Debug a request:
Get the current analysis engine JAR info (V2 API):
Revoke a user token:
sonar context
sonar contextAugment AI agents with context from your codebase. Forwards all arguments to the locally-installed sonar-context-augmentation binary. Install the binary first via sonar integrate claude, sonar integrate copilot, or another sonar integrate command. If Sonar Vortex context augmentation is not installed, the CLI prints an error and points you back to sonar integrate.
Arguments:
[action]
Action forwarded to sonar-context-augmentation.
[args...]
Additional arguments forwarded to sonar-context-augmentation.
Examples:
Configuration
sonar config telemetry
sonar config telemetryEnable or disable the collection of anonymous usage statistics and crash reports. See Telemetry and privacy for what's collected.
Options:
--enabled
boolean
No
Enable collection of anonymous usage statistics.
-
--disabled
boolean
No
Disable collection of anonymous usage statistics.
-
Examples:
System
System diagnostics and maintenance commands for the SonarQube CLI installation. See Check system status and Reset the CLI for guides.
sonar system status
sonar system statusShow a diagnostic overview of authentication, resolved network configuration (proxy, custom CA certificate, and client certificate), installed binaries, cache directories, integrations, MCP server health, and Antigravity secrets hook health. Does not require authentication. See Check system status for details.
Options:
--json
boolean
No
Output as JSON for machine consumption.
-
Examples:
sonar system reset
sonar system resetReset the CLI to factory defaults: remove saved tokens, downloaded binaries, sonar integrate installs, and CLI caches. Telemetry preferences are preserved. Does not remove the sonar binary. See Reset the CLI for details.
Options:
--force
boolean
No
Skip the interactive confirmation prompt (required for scripts).
-
Examples:
Maintenance
sonar self-update
sonar self-updateUpdate SonarQube CLI to the latest version. Re-uses the install script that put sonar on your system; your saved state and credentials are preserved. See Updating the CLI for details.
Options:
--status
boolean
No
Check for a newer version without installing.
-
--force
boolean
No
Install the latest version even if already up to date.
-
Examples:
Related pages
Last updated
Was this helpful?

