For the complete documentation index, see llms.txt. This page is also available as Markdown.
Developer

GitHub Copilot CLI

Install the SonarQube plugin in GitHub Copilot CLI to bring SonarQube code quality and security analysis into your AI coding sessions.

The SonarQube plugin for GitHub Copilot CLI connects your AI coding agent to SonarQube's code quality and security features. The plugin works with SonarQube Cloud or SonarQube Server.

This page covers the GitHub Copilot CLI terminal agent. For GitHub Copilot Chat in VS Code, see GitHub Copilot in VS Code.

Features

The plugin installs:

  • Secrets detection: a secrets detection hook that blocks Copilot CLI from reading or writing files containing exposed credentials. The plugin also installs custom instructions that tell the agent to refuse working with exposed tokens, since GitHub Copilot CLI doesn't currently support a prompt-time hook.

  • Vortex analysis (available with a Vortex subscription: SonarQube Cloud Team (annual) or Enterprise plan, or SonarQube Server 2026.5 or newer Enterprise and Data Center editions): instructions that tell Copilot CLI to verify the files it edits.

  • Vortex context (available with a Vortex subscription: SonarQube Cloud Team (annual) or Enterprise plan, or SonarQube Server 2026.5 or newer Enterprise and Data Center editions): hooks that inject project guidelines, architecture, semantic-navigation, and dependency context when a session starts and when a subagent starts.

The plugin gives the Copilot CLI 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.

  • A container runtime (Docker, Podman, or nerdctl) to run the SonarQube MCP Server image.

Install

Install the SonarQube plugin from the awesome-copilot marketplace, which is registered by default in GitHub Copilot CLI:

  • From your shell, run copilot plugin install sonarqube@awesome-copilot.

  • Or inside an interactive Copilot CLI session, run /plugin install sonarqube@awesome-copilot.

For details on plugin marketplaces and installation, see Finding and installing plugins for GitHub Copilot CLI.

Configuration

After installing the plugin, finish setup by running the guided integration skill:

The skill does the following:

  1. Install the SonarQube CLI if not already present, or update it with sonar self-update.

  2. 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.

  3. Run sonar integrate copilot, which shows these recommended components and asks you to install them or customize the selection: the secrets-detection hook, the prompt-secrets instructions, the SonarQube MCP Server, and, with a Vortex subscription, the Vortex analysis instructions and Vortex context session-start hooks.

Sonar Vortex: analysis and context features

When you run sonar integrate copilot, the command configures Copilot CLI to use the What is Sonar Vortex? features. They run through the SonarQube CLI:

  • Vortex analysis: instructions tell Copilot CLI to check the files it edits and return any findings in its response. Unlike the Claude Code and Codex hooks, Copilot CLI can't inject findings back into the conversation. If no project is configured, the instructions tell Copilot CLI to stay silent for the rest of the session instead of repeating a skip notice.

  • Vortex context: hooks inject your project's coding guidelines, dependency health, architecture, and semantic-navigation context when a session starts and when a subagent starts.

Both features install when you set up the integration.

Note: If a previous install wrote .github/skills/sonar-context-augmentation/SKILL.md, update to SonarQube CLI 1.8.0 or newer, then re-run sonar integrate copilot to replace that leftover skill with the session-start hooks. Re-running does not remove a leftover file inside a project folder. To remove one, see Orphaned integration files in the SonarQube CLI docs.

Verify that it works

Test the secrets hook

  1. Create a file with a fake-looking but secret-shaped value:

  2. Ask Copilot CLI to read it: "Read secrets.js."

  3. Copilot CLI should block the read and explain that the file contains a secret.

Once you've confirmed the hook is active, delete the test file.

Test the MCP server

Ask Copilot CLI to list your SonarQube projects via the MCP server. If the call fails, run sonar auth status to confirm the underlying token is healthy and restart Copilot CLI.

Test Sonar Vortex

To confirm that Vortex analysis and context are both 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 does not prompt. It wires up the SonarQube MCP Server, the secrets-detection hook, and installs Vortex analysis and context features. Run sonar auth status afterward to confirm the integration is wired up. See GitHub Copilot CLI in the SonarQube CLI docs for full details.

Usage

After setup, invoke SonarQube skills in GitHub Copilot CLI using slash commands or natural language. Both options are shown for each skill.

List projects

Or in natural language:

  • "List my SonarQube projects."

  • "Search for projects with auth in 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-project on branch main."

Fix an issue

Or in natural language:

  • "Fix the issue java:S1481 in src/main/java/MyClass.java."

  • "Help me fix python:S2077 on line 34 of src/auth/login.py."

Quality gate

Or in natural language:

  • "Check the quality gate status for my-project."

  • "Show me the quality gate for my-project on pull request 42."

Analyze a file

Or in natural language:

  • "Analyze src/auth/login.py for code quality and security issues."

  • "Run analysis on the current file."

Coverage

Or in natural language:

  • "What files in my-project have 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-project on 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

Security hotspots are surfaced through the same sonar-list-issues skill:

Or in natural language:

  • "Search security hotspots in my-project."

  • "Show hotspots in my-project that are still to review."

For the full reference of what the agent can call, see the Tools page.

Uninstall

To remove the SonarQube plugin from GitHub Copilot CLI:

  • From your shell, run copilot plugin uninstall sonarqube.

  • Or inside an interactive Copilot CLI session, run /plugin uninstall sonarqube.

Uninstalling the plugin removes the MCP wiring the plugin registered with Copilot CLI. To also remove the underlying CLI integration files written by the sonar-integrate skill (the SonarQube MCP server entry, state record), see Uninstall on the SonarQube CLI integration page.

GitHub Copilot in VS Code

GitHub Copilot Chat in VS Code is a separate product from GitHub Copilot CLI. The GitHub Copilot Chat extension runs inside VS Code and integrates directly with the SonarQube VS Code extension, with no plugin installation, MCP server, or Docker required. For the full SonarQube MCP Server integration with Copilot in Agent mode, see VS Code with GitHub Copilot in the MCP Server docs.

The SonarQube VS Code extension exposes Copilot tools that give Copilot Chat per-file diagnostic access in agent mode:

  • #sonarqube_analyzeFile: analyze a file for code quality and security issues

  • #sonarqube_getPotentialSecurityIssues: list security issues and taint vulnerabilities in a file

  • #sonarqube_setUpConnectedMode: guided connected mode setup with SonarQube Server or Cloud

  • #sonarqube_excludeFiles: exclude files and folders from analysis

To add instruction-file-based guidance on top of these tools (secrets scanning rules, issue querying, and SonarQube CLI commands), run sonar integrate copilot inside your project. This generates instruction files similar to those installed by the SonarQube plugin for GitHub Copilot CLI. Note that the pre-tool secrets-scanning hook does not fire in Copilot Chat; it is wired for the Copilot CLI terminal agent only.

More information about using the Use GitHub Copilot tools in VS Code is available in the SonarQube for VS Code documentation.

Last updated

Was this helpful?