SonarQube CLI

Code verificationwherever generated

Verify agent-written code where it's generated, at agent speed, before your pipeline.

Install:
Channel:
brew install sonarqube-cli
Authenticate to your SonarQube account and set the same security standards for your agents
zsh
⋯
What we verify

What verification the SonarQube CLI offers

01

Prevent secrets in files and AI prompts to be exposed to agent context

02

Give AI agents more relevant context and guardrails to save tokens

03

Automatically run dependency checks after a changeset

Already a SonarQube user

Fix your quality gate with a few commands

1

Connect to your project

# Sign in to SonarQube Cloud or Server sonar auth login # Find your project’s key sonar list projects --format table # Replace these values with your project key and PR number PROJECT_KEY="your-project-key" PR_NUMBER="123"
2

Find what’s failing

# Show failing conditions sonar quality-gate status --project "$PROJECT_KEY" --pull-request "$PR_ID"

Use the breakdown to decide what to change: add tests for uncovered code, refactor duplication, address reported issues, or resolve dependency risks.

3

Inspect the issues behind the failure

# List open and confirmed issues on the PR’s new code sonar list issues --project "$PROJECT_KEY" --pull-request "$PR_NUMBER" --new-code --format table

Fix the relevant code yourself or with your coding agent, then run your project’s tests. An issue list won’t explain every failure; use the quality gate breakdown for coverage, duplication, and dependency conditions too.

Templates

Integrate SonarQube with your agent, right now

Seamlessly integrate SonarQube with your preferred agent via dedicated SonarQube plugins. Guide your agents and Verify their output with Sonar Vortex in the agentic loop.

Integrate SonarQube in your agent session or directly in your terminal with sonar integrate claude

Open a Claude Code session

Prerequisite: Vortex requires a prior CI analysis of the project. It restores the latest stored analysis context for the selected branch, so analyze the project in CI before relying on Vortex.
1

Install the SonarQube plugin from Anthropic's marketplace

/plugin install sonarqube@claude-plugins-official
2

Integrate SonarQube with Claude Code with the plugin's integrate skill

/sonarqube:sonar-integrate

The integrate command installs or updates the SonarQube CLI, prompts for authentication to SonarQube, starts the SonarQube MCP Server, and configures Vortex when available (and secrets detection too).

3

Guide your agent and Verify its output

Start a fresh Claude Code session to unlock Vortex.

Open a Codex CLI session

Prerequisite: Vortex requires a prior CI analysis of the project. It restores the latest stored analysis context for the selected branch, so analyze the project in CI before relying on Vortex.
1

Add SonarSource/sonarqube-agent-plugins as a plugin marketplace

codex plugin marketplace add SonarSource/sonarqube-agent-plugins
2

Install the SonarQube plugin from that catalog

codex plugin add sonarqube@sonar
3

Integrate SonarQube with Codex CLI with the plugin's integrate skill

sonar integrate codex

The integrate command installs or updates the SonarQube CLI, prompts for authentication to SonarQube, starts the SonarQube MCP Server, and configures Vortex when available (and secrets detection too).

4

Guide your agent and Verify its output

Start a fresh Codex CLI session to unlock Vortex.

Open a GitHub Copilot CLI session

Prerequisite: Vortex requires a prior CI analysis of the project. It restores the latest stored analysis context for the selected branch, so analyze the project in CI before relying on Vortex.
1

Install the SonarQube plugin from the pre-packaged awesome-copilot catalog

/plugin install sonarqube@awesome-copilot
2

Integrate SonarQube with GitHub Copilot CLI with the plugin's integrate skill

/sonarqube:sonar-integrate

The integrate command installs or updates the SonarQube CLI, prompts for authentication to SonarQube, starts the SonarQube MCP Server, and configures Vortex when available (and secrets detection too).

3

Guide your agent and Verify its output

Start a fresh GitHub Copilot CLI session to unlock Vortex.

Open an Antigravity session

Prerequisite: Vortex requires a prior CI analysis of the project. It restores the latest stored analysis context for the selected branch, so analyze the project in CI before relying on Vortex.
1

Install the SonarQube plugin bundle

agy plugin install https://github.com/SonarSource/sonarqube-agent-plugins
2

Integrate SonarQube with Antigravity with the plugin's integrate skill

/sonarqube:sonar-integrate

The integrate command installs or updates the SonarQube CLI, prompts for authentication to SonarQube, starts the SonarQube MCP Server, and configures Vortex when available (and secrets detection too).

3

Guide your agent and Verify its output

Start a fresh Antigravity session to unlock Vortex.

Open a Cursor session

Prerequisite: Vortex requires a prior CI analysis of the project. It restores the latest stored analysis context for the selected branch, so analyze the project in CI before relying on Vortex.
1

Install the SonarQube plugin through Cursor's marketplace

/add-plugin sonarqube
2

Integrate SonarQube with Cursor with the plugin's integrate skill

/sonarqube:sonar-integrate

The integrate command installs or updates the SonarQube CLI, prompts for authentication to SonarQube, starts the SonarQube MCP Server, and configures Vortex when available (and secrets detection too).

3

Guide your agent and Verify its output

Start a fresh Cursor session to unlock Vortex.

No plugin for your agent?

Use this when your agent has no dedicated SonarQube plugin and reaches SonarQube through the SonarQube MCP Server. If a plugin exists for your agent, install that instead — it wires the same capabilities through the SonarQube CLI and needs no directive file.

Set this up before the directives file does anything:

  • The local (stdio) MCP server, not the SonarQube-hosted one. Vortex analyzes files on disk, and the hosted server has no filesystem access.
  • Your workspace mounted into the container at /app/mcp-workspace.
  • SONARQUBE_TOOLSETS including vortex, the unified toolset covering both Vortex context and Vortex analysis tools. Add issues,quality-gates,rules to get the Solve-stage tools.
  • A prior CI analysis of the project. Vortex restores the latest stored analysis context for the selected branch rather than recomputing it, so the project needs to have been analyzed in CI first.

Drop this file in your repo root as your agent's instructions file.

AGENTS.md

Tool names are written bare. Some agents namespace MCP tools as mcp__<server-name>__<tool> — if yours does, prefix accordingly using your own server name from your MCP config.

Guide

before generating or editing code

Always, before writing anything:

  • get_guidelines — coding standards drawn from this project's own SonarQube issue history, filtered to the task at hand. Requires mode: project_based (default), category_based, or combined. Narrow with categories, languages, file_paths.

To find and read existing code, use these instead of grep and find. They resolve symbols through abstract syntax trees and control flow rather than text matching:

  • search_by_signature_patterns — find declarations by regex on signatures
  • search_by_body_patterns — find usages by regex inside method bodies
  • get_source_code — read a symbol's source by fully qualified name

When changing architecture or touching shared code:

  • get_current_architecture — the actual module dependency graph. depth is required; start at 0 for a top-level view, then drill in with path_prefix.
  • get_intended_architecture — the constraints you've defined, so the agent stays inside them
  • get_upstream_call_flow / get_downstream_call_flow — trace callers and callees by fqn
  • get_references — every file referencing a type
  • get_type_hierarchy — implementors and subtypes

Before adding or updating any dependency:

  • check_dependency — pass purl (e.g. pkg:npm/lodash@4.17.21). Refuse the dependency outright if it comes back malicious. Block on BLOCKER or HIGH riskSeverity, and propose a version from fixedVersions. Requires SonarQube Advanced Security.

Semantic navigation covers Java, C#, JavaScript, TypeScript, Python, and Rust. Guidelines cover every SonarQube Cloud language.

Verify

after every file you write or edit

Call run_advanced_code_analysis on each new or modified file:

  • projectKey — falls back to SONARQUBE_PROJECT_KEY if configured
  • branch — required. The branch used to retrieve the latest stored analysis context.
  • filePath — required. Project-relative, e.g. src/main/java/MyClass.java
  • fileScope — "MAIN" or "TEST". A plain string, not an array. Defaults to "MAIN".

This uses the latest stored analysis context for the branch rather than recomputing it, which is why it returns CI-depth results in seconds.

Do not report a file as done until its analysis comes back clean.

Solve

when analysis returns findings
  1. show_rule with the rule key (e.g. python:S7608) to get the rationale, the noncompliant example, and the recommended fix. Fix from the rule's guidance, not from a guess about what it wants.
  2. Fix every finding on lines you touched this turn. Leave pre-existing findings on untouched lines alone unless you were asked to address them.
  3. Re-run run_advanced_code_analysis on the same files to confirm the fix landed and introduced nothing new. Repeat until clean.
  4. Surface findings to the user verbatim. Do not summarize them away or silently drop them.

Optional, for wider context:

  • search_sonar_issues_in_projects — the existing issue backlog, to see whether a finding is yours or was already there
  • search_dependency_risks — the dependency risks already recorded against the project, as opposed to check_dependency, which vets a package before you add it
  • get_project_quality_gate_status — the project's gate state

There is no MCP tool that invokes the SonarQube Remediation Agent. That agent works the main-branch backlog and open pull requests from SonarQube Cloud and opens its own PRs. It is the Solve stage outside the coding loop; the loop above is the Solve stage inside it.

Key principle

the in-loop gate

A task is not complete until run_advanced_code_analysis returns clean for every file you changed.

That is the in-loop gate, and it is the only one that sees code you have not pushed yet. get_project_quality_gate_status reports the gate from the last CI analysis of the project, so it is blind to uncommitted work and cannot confirm the file in front of you. Check it before declaring a branch ready to merge, never as the exit criterion for an edit.

Full reference on docs.sonarsource.com
How-to guides

Get SonarQube CLI running with your agents

Step-by-step guides for setting up and using SonarQube CLI and its agent integrations

CLI guide
SonarQube CLI

SonarQube CLI | How to Set Up and Use the SonarQube CLI

Written guide
Read guide
CLI guide
SonarQube CLI

SCA pre-commit hook with the SonarQube CLI

Written guide
Read guide
CLI guide
SonarQube CLI

The Agent Centric Development Cycle with the SonarQube CLI

Written guide
Read guide
CLI guide
SonarQube CLI

SonarQube CLI brings multilayered verification to agentic development

Written guide
Read guide
CLI guide
SonarQube CLI

SonarQube CLI: Code Analysis and AI Agent Setup From The Terminal

CLI guide
SonarQube CLI

SonarQube CLI + SonarQube Remediation Agent: Find and Solve Issues From the Terminal

Agent integration guide
Sonar Vortex

How to set up Sonar Vortex in Claude Code

Written guide
Read guide
Agent integration guide
SonarQube plugin

Set up the SonarQube plugin for Claude Code

Written guide
Read guide
Agent integration guide
Sonar Vortex

How to set up Sonar Vortex in Codex

Written guide
Read guide
Agent integration guide
SonarQube plugin

Set up the SonarQube plugin for Codex

Written guide
Read guide
Agent integration guide
Sonar Vortex

How to set up Sonar Vortex in GitHub Copilot CLI

Written guide
Read guide
Agent integration guide
SonarQube plugin

Set up the SonarQube Plugin for GitHub Copilot CLI

Written guide
Read guide
Agent integration guide
Sonar Vortex

How to set up Sonar Vortex in VS Code with GitHub Copilot

Written guide
Read guide
Agent integration guide
SonarQube plugin

How to set up the SonarQube plugin for GitHub Copilot in VS Code

Written guide
Read guide
Agent integration guide
SonarQube plugin

Set up the SonarQube plugin for Antigravity

Written guide
Read guide
Agent integration guide
SonarQube plugin

Set up the SonarQube Plugin for Cursor

Written guide
Read guide
Agent integration guide
Sonar Vortex

Setup Sonar Vortex In GitHub Copilot CLI For AI Code Verification

Agent integration guide
Sonar Vortex

Sonar Vortex In Codex | Verify AI-Generated Code In Real Time

Agent integration guide
Sonar Vortex

Sonar Vortex in Claude Code: Verifying AI-Generated Code in Real Time

Agent integration guide
SonarQube

Agentic Workflow Demo: Use SonarQube to Verify & Review AI Code

Agent integration guide
SonarQube

GitHub Copilot CLI + SonarQube: AI Agentic Analysis for Quality Code

Agent integration guide
SonarQube plugin

Introducing SonarQube Plugin For Cursor

Agent integration guide
SonarQube plugin

Introducing SonarQube Plugin for Codex | Automated Code Fixes for High-Quality Code

Agent integration guide
SonarQube plugin

SonarQube Plugin for Antigravity: Real-Time Verification With Taylor Luttrell-Williams & Steve Chen

More guides coming Devin · GitLab Duo · Azure DevOps auto-analysis.
More dev guides

Gartner® names Sonar a Magic Quadrant™ Leader

AI is generating code faster than teams can govern it. Sonar was named a Leader, and placed highest on Ability to Execute. We built the verification layer the AI development cycle actually needs.

Download the report
A G2 Leader for 6 years running
4.6 / 5

Safe, reliable, and auditable agentic development