sonar-coverage
Find files with low test coverage and inspect uncovered lines in a SonarQube project (project key optional when MCP integration…
Analyze a file for quality and security issues using SonarQube
$ npx -y skills add SonarSource/sonarqube-agent-plugins --skill sonar-analyze --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/sonar-analyzeContext preview
The summary Claude sees to decide when to auto-load this skill.
Analyze a file for quality and security issues using SonarQube
name: sonar-analyze description: Analyze a file for quality and security issues using SonarQube argument-hint: "[file-path]" allowed-tools: Read, Glob, Bash(git branch:*), Bash(docker ps:*), Bash(podman ps:*), Bash(nerdctl ps:*), Bash(sonar:*)
Analyze code for quality and security issues using the SonarQube MCP Server.
sonar-analyze # analyze the file currently in context sonar-analyze src/auth/login.py # analyze a specific file
This skill requires the SonarQube MCP Server to be configured and at least one of the tools `mcp__sonarqube__run_advanced_code_analysis` or `mcp__sonarqube__analyze_file_list` to be available in your session.
**Before proceeding**, verify at least one of these tools is accessible. If none are, try the CLI fallback in Step 3 before giving up — don't invent other CLI commands (e.g. `sonar mcp call` does not exist).
**If the CLI fallback also fails or doesn't apply, narrow down the cause** — check whether the `sonarqube` MCP server is enabled in this agent's configuration.
Either way, show the user:
> Unable to reach the SonarQube MCP Server. > > **Possible causes:** > - MCP server not registered — invoke the sonar-integrate skill to configure the SonarQube MCP Server, then restart the agent session > - Container runtime not running — the SonarQube MCP Server runs inside a container (Docker, Podman, or Nerdctl); start your container runtime, then restart the agent session > - Credentials not configured — invoke the sonar-integrate skill > - Project key missing or invalid — pass an explicit key if needed, verify `sonar-project.properties`, or re-run the sonar-integrate skill for this project
Then ask the user (yes/no) whether to run the sonar-integrate skill now. Briefly explain what it does: it checks the SonarQube setup on their machine — installing or updating `sonarqube-cli` and verifying authentication — and re-configures the integration for this agent, including the SonarQube MCP server and secrets-scanning hooks. If they confirm, invoke the sonar-integrate skill yourself and follow it end-to-end in this session, then ask the user to ensure a container runtime (Docker, Podman, or Nerdctl) is running and to restart the agent session so the new MCP tools become available; if they decline, stop.
Both analysis tools work on **one file at a time**. Resolve a single file path:
Do not accept a directory as input. If the user provides one, ask them to specify a single file.
1. Read the file's full content — only needed as a fallback for `run_advanced_code_analysis`'s `fileContent` parameter (see Step 3). 2. Determine the file scope: `"TEST"` or `"MAIN"`. Use the file path to deduce the scope. For example, if the file path contains `test`, `spec`, or `__tests__`, it's likely `"TEST"` scope.
After running the sonar-integrate skill, the SonarQube MCP Server often has a **default project** for this workspace, so **`projectKey` is sometimes unnecessary** — pass it only when the tool schema requires it or the user targets another project.
Two tools may be available depending on whether the connected organization is eligible for Vortex analysis:
**Try `mcp__sonarqube__run_advanced_code_analysis` first** (available when the organization is eligible for Vortex analysis).
Before calling it, detect the current branch name using `git branch --show-current`. If git is unavailable, use `main` as a fallback.
Then call with:
**If that tool is unavailable, fall back to `mcp__sonarqube__analyze_file_list`** (requires a running SonarQube for IDE instance bridged to this session):
**If neither MCP tool is available, fall back to the CLI's Vortex analysis:**
sonar analyze agentic --file <file-path> [--file <other-file-path> ...] --format json [--branch <branch-name>] [-p <project-key>]
Same backend as `run_advanced_code_analysis` (repeatable `--file` covers multi-file too), and the practical fallback for `analyze_file_list` as well — it has no direct CLI equivalent, but this achieves the same goal.
Requires a Vortex analysis-eligible organization. If the org isn't eligible, or `sonar` isn't
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.
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
Installs sonarqube-cli if not already installed, authenticates, and integrates SonarQube with the current agent (installs…
Search and filter SonarQube issues for a project, branch, or pull request via sonarqube-cli (`-p` is always required on the CLI;…