Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

sonar-analyze

БесплатноБез исполняемых скриптовНе проверен

Analyze a file for quality and security issues using SonarQube

SonarSourceот SonarSource★ 118 звёзд на GitHub

Об этом скилле

SonarQube — Code Analysis

Analyze code for quality and security issues using the SonarQube MCP Server.

Usage

sonar-analyze                        # analyze the file currently in context
sonar-analyze src/auth/login.py      # analyze a specific file

Prerequisites

This skill requires the SonarQube MCP Server to be configured and at least one of the tools mcp__sonarqube__run_advanced_code_analysis, mcp__sonarqube__analyze_file_list, or mcp__sonarqube__analyze_code_snippet 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.

  • Not enabled / not registered → recommend running the sonar-integrate skill.
  • Enabled but its tools are still unavailable → configuration is correct but the server failed to start. The most common cause is that the container runtime is not running — the MCP server launches inside Docker/Podman/Nerdctl via sonar run mcp, so a correctly configured server still produces no tools if the daemon is stopped. Run docker ps yourself (falling back to podman ps / nerdctl ps) to confirm which cause applies: if it errors, the runtime is down; after the user starts it, confirm the same command succeeds before asking them to restart the agent session.

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.

Instructions

Step 1: Resolve what to analyze

Analyze one file at a time. Resolve a single file path:

  • If the user provided a file path, use it.
  • If no path was provided, look at the current conversation context for a recently mentioned or edited file.
  • If nothing is clear, ask: "Which file would you like me to analyze?"

Do not accept a directory as input. If the user provides one, ask them to specify a single file.

Step 2: Read the file and determine its scope

  1. Read the file's full content for analysis tools whose schema requires fileContent (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.

Step 3: Call the appropriate analysis tool

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.

Try mcp__sonarqube__run_advanced_code_analysis first if available. On Cloud stdio, its presence does not prove that the selected organization is entitled to Vortex; entitlement is checked on each call.

Cloud stdio selects one analysis path at startup, so an advanced-analysis session may have no local fallback. SONARQUBE_FORCE_LOCAL_ANALYSIS=true selects analyze_code_snippet directly, bypassing the IDE bridge; the analysis toolset must be enabled.

Use the vortex toolset for advanced analysis; keep analysis enabled when configuring the local snippet recovery path.

Before calling it, detect the current branch name using git branch --show-current. If git is unavailable, use main as a fallback.

Use the tool's published schema and call with:

  • organization — when the Cloud tool exposes it, pass the selected organization if one was chosen; otherwise use the server default
  • projectKey — omit unless the tool requires it (initial MCP configuration usually supplies the default project); if required, use the value from the user's arguments if provided, otherwise
Полный SKILL.md на GitHub

Установить sonar-analyze в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Glob
Bash(git branch:*)
Bash(docker ps:*)
Bash(podman ps:*)
Bash(nerdctl ps:*)
Bash(sonar:*)

FAQ

Что делает скилл sonar-analyze?

Analyze a file for quality and security issues using SonarQube

Как установить скилл sonar-analyze?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл sonar-analyze запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить sonar-analyze с