Code verificationwherever generated
Verify agent-written code where it's generated, at agent speed, before your pipeline.
What verification the SonarQube CLI offers
Prevent secrets in files and AI prompts to be exposed to agent context
Give AI agents more relevant context and guardrails to save tokens
Automatically run dependency checks after a changeset
Fix your quality gate with a few commands
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"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.
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 tableFix 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.
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
Install the SonarQube plugin from Anthropic's marketplace
/plugin install sonarqube@claude-plugins-officialIntegrate SonarQube with Claude Code with the plugin's integrate skill
/sonarqube:sonar-integrateThe 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).
Guide your agent and Verify its output
Start a fresh Claude Code session to unlock Vortex.
Open a Codex CLI session
Add SonarSource/sonarqube-agent-plugins as a plugin marketplace
codex plugin marketplace add SonarSource/sonarqube-agent-pluginsInstall the SonarQube plugin from that catalog
codex plugin add sonarqube@sonarIntegrate SonarQube with Codex CLI with the plugin's integrate skill
sonar integrate codexThe 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).
Guide your agent and Verify its output
Start a fresh Codex CLI session to unlock Vortex.
Open a GitHub Copilot CLI session
Install the SonarQube plugin from the pre-packaged awesome-copilot catalog
/plugin install sonarqube@awesome-copilotIntegrate SonarQube with GitHub Copilot CLI with the plugin's integrate skill
/sonarqube:sonar-integrateThe 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).
Guide your agent and Verify its output
Start a fresh GitHub Copilot CLI session to unlock Vortex.
Open an Antigravity session
Install the SonarQube plugin bundle
agy plugin install https://github.com/SonarSource/sonarqube-agent-pluginsIntegrate SonarQube with Antigravity with the plugin's integrate skill
/sonarqube:sonar-integrateThe 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).
Guide your agent and Verify its output
Start a fresh Antigravity session to unlock Vortex.
Open a Cursor session
Install the SonarQube plugin through Cursor's marketplace
/add-plugin sonarqubeIntegrate SonarQube with Cursor with the plugin's integrate skill
/sonarqube:sonar-integrateThe 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).
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_TOOLSETSincludingvortex, the unified toolset covering both Vortex context and Vortex analysis tools. Addissues,quality-gates,rulesto 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.
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 codeAlways, before writing anything:
get_guidelines— coding standards drawn from this project's own SonarQube issue history, filtered to the task at hand. Requiresmode:project_based(default),category_based, orcombined. Narrow withcategories,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 signaturessearch_by_body_patterns— find usages by regex inside method bodiesget_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.depthis required; start at0for a top-level view, then drill in withpath_prefix.get_intended_architecture— the constraints you've defined, so the agent stays inside themget_upstream_call_flow/get_downstream_call_flow— trace callers and callees byfqnget_references— every file referencing a typeget_type_hierarchy— implementors and subtypes
Before adding or updating any dependency:
check_dependency— passpurl(e.g.pkg:npm/lodash@4.17.21). Refuse the dependency outright if it comes backmalicious. Block on BLOCKER or HIGHriskSeverity, and propose a version fromfixedVersions. 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 editCall run_advanced_code_analysis on each new or modified file:
projectKey— falls back toSONARQUBE_PROJECT_KEYif configuredbranch— required. The branch used to retrieve the latest stored analysis context.filePath— required. Project-relative, e.g.src/main/java/MyClass.javafileScope—"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 findingsshow_rulewith 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.- Fix every finding on lines you touched this turn. Leave pre-existing findings on untouched lines alone unless you were asked to address them.
- Re-run
run_advanced_code_analysison the same files to confirm the fix landed and introduced nothing new. Repeat until clean. - 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 theresearch_dependency_risks— the dependency risks already recorded against the project, as opposed tocheck_dependency, which vets a package before you add itget_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 gateA 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.
Get SonarQube CLI running with your agents
Step-by-step guides for setting up and using SonarQube CLI and its agent integrations