Command Palette

Search for a command to run...

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

sonar-duplication

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

Find files with code duplications in a SonarQube project and inspect duplication blocks for a file (project key optional when MCP integration already defines…

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

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

SonarQube — Duplication

List files that contain duplicated code in a SonarQube project, then drill into duplication blocks for a specific file when needed.

Usage

sonar-duplication                              # all duplicated files in the current project (auto-paginated)
sonar-duplication my-project                   # duplicated files in a specific project
sonar-duplication my-project --pr 42           # same, on a pull request
sonar-duplication my-project --page-size 100 --page 2   # single page of results (manual pagination)
sonar-duplication my-project --file src/auth/login.py   # duplication detail for one file

Prerequisites

This skill requires the SonarQube MCP Server to be configured and the tools mcp__sonarqube__search_duplicated_files and mcp__sonarqube__get_duplications to be available in your session.

Before proceeding, verify the tools are accessible. If they are not, try the sonar api CLI fallback in Step 3 before giving up — don't invent other CLI commands (e.g. sonar mcp call or sonar duplication do not exist).

If the CLI fallback also fails (for example sonar not installed/authenticated, or no project key can be resolved), 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, or project key not found.

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 is wrong or no default project in MCP config — pass an explicit key, or verify sonar-project.properties / 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 the project key (only when needed)

MCP tools sometimes do not require projectKey after the sonar-integrate skill has stored the default project for this workspace. Resolve a key only when you must pass it (tool schema requires it, or the user targets another project):

  • If the user provided a project key, use it.
  • Otherwise look for sonar.projectKey in sonar-project.properties at the repo root.
  • If still not found, omit projectKey in MCP calls and rely on the integration default.

Step 2: Parse optional flags from the user-provided arguments

Flag Meaning
--pr <id> Pull request context (maps to pullRequest)
--page-size <n> Results per page for manual pagination only; integer 1–500 (maps to pageSize)
--page <n> Page number for manual pagination; starts at 1 (maps to pageIndex)
--file <key> Skip the duplicated-files list; fetch duplication blocks for this file (maps to key in get_duplications)

Pagination rule: By default, call search_duplicated_files without pageSize or pageIndex so the MCP server auto-fetches every page of duplicated files (up to 10,000 files). Use pageSize and pageIndex only when the user asks for a specific page or wants to limit page size. If the user supplies `--pa

Полный SKILL.md на GitHub

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

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

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

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

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

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

Read
Grep
Bash(docker ps:*)
Bash(podman ps:*)
Bash(nerdctl ps:*)
Bash(sonar:*)

FAQ

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

Find files with code duplications in a SonarQube project and inspect duplication blocks for a file (project key optional when MCP integration already defines the default project)

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

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

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

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

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

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