sonar-analyze
Analyze a file for quality and security issues using SonarQube
Installs sonarqube-cli if not already installed, authenticates, and integrates SonarQube with the current agent (installs analysis hooks & SonarQube MCP Server). Use when the user wants to set up SonarQube integration or asks to configure SonarQube.
$ npx -y skills add SonarSource/sonarqube-agent-plugins --skill sonar-integrate --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/sonar-integrateContext preview
The summary Claude sees to decide when to auto-load this skill.
Installs sonarqube-cli if not already installed, authenticates, and integrates SonarQube with the current agent (installs analysis hooks & SonarQube MCP Server). Use when the user wants to set up SonarQube integration or asks to configure SonarQube.
name: sonar-integrate description: "Installs sonarqube-cli if not already installed, authenticates, and integrates SonarQube with the current agent (installs analysis hooks & SonarQube MCP Server). Use when the user wants to set up SonarQube integration or asks to configure SonarQube." allowed-tools: Bash(which:*), Bash(Get-Command:*), Bash(sonar:*), Bash(agy:*), Bash(curl:*), Bash(irm:*), Bash(iex:*), Bash(brew:*), Bash(mise:*), Bash(docker ps:*), Bash(podman ps:*), Bash(nerdctl ps:*)
Guide the user through installing **sonarqube-cli** (if needed), **updating it to the latest version** when already installed, authenticating, and completing agent-specific integration. Assume SonarQube itself is already set up; this skill only wires the assistant.
Interaction rule: for every finite decision, always present predefined selector options (single-choice or multi-choice as appropriate) instead of asking for free-form text. If the user gives an invalid answer, re-show the same selector.
Check if `sonar` is available on the PATH by running `which sonar` (macOS/Linux) or `Get-Command sonar` (Windows) yourself.
**If found:** first determine how it was installed, because the upgrade path differs:
**If not found:** pick an install command from the table below, show it to the user, and ask for explicit confirmation **before running it**. Do **not** execute the command until the user confirms.
The shell/PowerShell script is the default and works everywhere. If the user already manages CLIs with **Homebrew** or **mise**, prefer that route so future upgrades stay managed by the tool — the Step 1 update above then defers to the manager.
| Platform / method | Install command | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------ | | macOS / Linux (script) | `curl -o- https://raw.githubusercontent.com/SonarSource/sonarqube-cli/refs/heads/master/user-scripts/install.sh \| bash` | | macOS / Linux (Homebrew) | `brew install --cask sonarqube-cli` | | Any OS (mise) | `mise use -g aqua:SonarSource/sonarqube-cli` | | Windows (PowerShell) | `irm https://raw.githubusercontent.com/SonarSource/sonarqube-cli/refs/heads/master/user-scripts/install.ps1 \| iex` |
**If the user confirms:** run the command yourself using a shell command. After it finishes, re-run the PATH check (`which sonar` or `Get-Command sonar`) yourself to verify before continuing.
**If the user declines:** stop the skill and ask the user to install `sonarqube-cli` manually and then re-invoke the sonar-integrate skill.
---
Run `sonar auth status` yourself using a shell command.
**If already authenticated:** note the connected server and organisation from the output, then skip directly to Step 4.
**If not authenticated:** proceed to Step 3.
---
This step requires user interaction — do **not** run it yourself.
First determine the connection type using a single-choice selector with these options:
1. SonarQube Cloud - EU (default) 2. SonarQube Cloud - US 3. Self-hosted SonarQube Server
Do not ask an open-ended text question for this decision.
Collect:
| Scenario | Information needed | | ------------------------------ | ------------------------------------------------------------- | | SonarQube Cloud — EU (default) | organization key (e.g. `my-org`) | | SonarQube Cloud — US | organization key + confirm US region (`https://sonarqube.us`) | | SonarQube Server | server URL (e.g. `https://sonarqube.yourcompany.com`) |
Build the login command and show it to the user:
| Scenario | Command | | -------------------- | ------------------------------------------------------- | | SonarQube Cloud — EU | `sonar auth login -o <org-key>` | | SonarQube Cloud — US | `sonar auth login -o <org-key> -s https://sonarqube.us` | | SonarQube Server | `sonar auth login -s <server-url>` |
Tell the user:
> "Run the command below — it will open your browser to log in. The token is stored > securely in your system keychain and never appears in this chat."
Wait for the user to confirm they logged in, then run `sonar auth status` yourself to verify before continuing.
---
> **Container runtime requirement:** The SonarQube MCP Server run
Made by Sonar SonarQube is the AI code quality and security verification platform used by millions of developers to catch bugs, vulnerabilities, and leaked secrets.
Analyze a file for quality and security issues using SonarQube
Find files with low test coverage and inspect uncovered lines in a SonarQube project (project key optional when MCP integration…
Search for software composition analysis (SCA) dependency risks in a SonarQube project (project key optional when MCP integration…
Find files with code duplications in a SonarQube project and inspect duplication blocks for a file (project key optional when MCP…
Fix a specific SonarQube issue in code by rule key and location
Search and filter SonarQube issues for a project, branch, or pull request via sonarqube-cli (`-p` is always required on the CLI;…