Codex CLI
Install the SonarQube plugin for the Codex CLI or Codex IDE extension to bring code analysis, issue management, and secrets detection into your AI coding sessions.
The SonarQube plugin for Codex CLI connects your AI coding agent to SonarQube's code quality and security features. It works with SonarQube Cloud or SonarQube Server.
Use the plugin from both the Codex CLI and the Codex IDE extension.
Features
Through the SonarQube CLI integration it sets up, the plugin adds:
Secrets detection: a hook that scans prompts for secrets before they are sent to Codex, plus secrets-on-read instructions in
.codex/AGENTS.mdthat tell Codex to refuse working with exposed tokens when it reads files.Vortex analysis (project-level installs with a Vortex subscription: SonarQube Cloud Team or Enterprise plan, or SonarQube Server 2026.5 Enterprise and Data Center editions): a hook that runs after Codex edits files.
Vortex context (project-level installs with a Vortex subscription: SonarQube Cloud Team or Enterprise plan, or SonarQube Server 2026.5 Enterprise and Data Center editions): a skill that tells Codex to pull project guidelines before editing code, check dependencies before changing a manifest, and use SonarQube's architecture and semantic-navigation context as it works.
The plugin also gives the Codex agent access to the full set of Tools exposed by the SonarQube MCP Server, including:
Code analysis: analyze code snippets and files in the agent context.
Issues: search, review, and update code issues.
Quality gates: check the quality gate status for a project.
Security hotspots: search and review security hotspots.
Coverage: find under-covered files and review line-by-line coverage.
Dependencies: check third-party dependencies for SCA issues.
Prerequisites
A SonarQube Cloud organization or SonarQube Server instance.
OpenAI Codex installed.
A container runtime (Docker, Podman, or nerdctl) to run the SonarQube MCP Server image.
Install
The SonarQube plugin is distributed through SonarSource's Codex plugin marketplace. Add that marketplace as a source in Codex, then install the plugin:
From your shell, register the marketplace:
Start a Codex session, run
/plugins, search forsonarqube, and install it.
Configuration
After installing the plugin, finish setup by running the guided integration skill:
The skill does the following:
Install the SonarQube CLI if not already present, or update it with
sonar self-update.Authenticate with SonarQube Cloud or your SonarQube Server instance via
sonar auth login. Your browser opens to complete login; the token is stored in your system keychain.Run
sonar integrate codex, which prompts you to install each component: the secrets-detection hook, the secrets-on-read instructions in.codex/AGENTS.md, the SonarQube MCP Server, and, for project installs with a Vortex subscription, the Vortex analysis hook and Vortex context skill.
Sonar Vortex: analysis and context features
When you run sonar integrate codex, the command configures Codex to use the What is Sonar Vortex? features. They run through the SonarQube CLI:
Vortex analysis: a hook runs after Codex edits files and surfaces findings inline.
Vortex context: gives Codex your project's coding guidelines, dependency health, architecture, and semantic-navigation context as it works.
Both features are project-scoped and skipped on a global install. Run sonar integrate codex --project <YourProjectKey> from a project directory to install them, or pass --skip-context to opt out of Vortex context.
Verify that it works
Test the secrets hook
Restart Codex so the newly installed secrets-detection hook is active.
Compose a prompt to Codex that contains a fake-looking but secret-shaped value:
Send the prompt.
Codex should block or refuse the operation and explain that the prompt contains a secret.
Test the MCP server
In Codex, ask: "List my SonarQube projects." Codex should call the SonarQube MCP server and return your project list. If it doesn't, run sonar auth status to confirm the underlying token is healthy and restart Codex.
Test Sonar Vortex
Vortex adds Vortex analysis and Vortex context. To confirm both are working, see Checking that Vortex works properly.
Non-interactive install
For provisioning scripts and onboarding automation, skip the interactive skill and run the SonarQube CLI directly:
In non-interactive mode the CLI doesn't prompt. A --global install wires up the SonarQube MCP Server, the secrets-detection hook, and the secrets-on-read instructions, but skips the project-scoped Vortex analysis hook and Vortex context skill. Run sonar auth status afterward to confirm the integration is wired up. See OpenAI Codex in the SonarQube CLI docs for full details.
Usage
After setup, invoke SonarQube skills in Codex with $ commands or in natural language. Both options are shown for each skill.
List projects
Or in natural language:
"List my SonarQube projects."
"Search for projects with
authin the name."
List issues
Or in natural language:
"List the issues in
my-project.""Show me critical issues in
my-project.""Search issues in
my-projecton branchmain."
Fix an issue
Or in natural language:
"Fix the issue
java:S1481insrc/main/java/MyClass.java.""Help me fix
python:S2077on line 34 ofsrc/auth/login.py."
Quality gate
Or in natural language:
"Check the quality gate status for
my-project.""Show me the quality gate for
my-projecton pull request 42."
Analyze a file
Or in natural language:
"Analyze
src/auth/login.pyfor code quality and security issues.""Run analysis on the current file."
Coverage
Or in natural language:
"What files in
my-projecthave less than 50% coverage?""Show me line-by-line coverage for
src/auth/login.py."
Duplication
Or in natural language:
"Find duplicated files in
my-project.""Show duplications in
my-projecton pull request 42."
Dependency risks
Dependency risks require SonarQube Advanced Security.
Or in natural language:
"List dependency risks in
my-project.""Show me SCA issues on pull request 42."
Security hotspots
Access security hotspots through the same sonar-list-issues skill:
Or in natural language:
"Search security hotspots in
my-project.""Show hotspots in
my-projectthat are still to review."
Uninstall
To remove the SonarQube plugin from Codex CLI, start a Codex session, run /plugins, and remove the SonarQube plugin.
Uninstalling the plugin removes the skills and MCP wiring it registered. To also remove the underlying CLI integration files written by sonar integrate codex (the SonarQube MCP server entry, secrets-detection hook, and Vortex analysis hook), see OpenAI Codex in the SonarQube CLI docs.
Related pages
Set up the SonarQube MCP Server in Codex
Last updated
Was this helpful?

