agentleFS
Mi9-LLCMi9-LLC/agent-skills/skills/sonar-issue-check/SKILL.md

sonar-issue-check

Skill2 starsChanged 5 months agoMITView on GitHub

Use this skill to look up and REPORT SonarCloud or SonarQube findings already analyzed for the current repo — list, pull, show, summarize, or dump the issues, without changing any code. By default report the NEW issues in the current branch's or PR's new code (the pre-commit / pre-PR "did I introduce a bug, vulnerability, or code smell?" check); report the full backlog on that branch/PR on request. Trigger for ANY read-only ask to see Sonar results, even when phrased "just give me the list" or "just tell me what Sonar found, don't fix anything": e.g. "what did sonarcloud flag on my branch", "pull the sonar bugs for PR 412", "did I introduce any new code smells", "check sonar before I push", or the quality-gate status on a branch/PR. Do NOT trigger when the user wants to FIX or clear the issues (that edits code — use sonar-issue-fix), run the Sonar scan itself, set up SonarLint in the editor, or configure quality-gate thresholds.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    --all: every unresolved issue on the analyzed branch/PR, not just the new-code period — use this for a full backlog export.

    line 33
  2. Very specific:

    Run with -h to see every option.

    line 102
  3. Very specific:

    If the user asks to see the full JSON after a run with --out, Read that file directly rather than re-running the script.

    line 118
  4. Distinctive:

    After running, give the user a short verdict, not a raw dump: lead with whether the branch is clean, then call out the highest-severity new …

    line 120

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Sonar issue check

This skill runs a bundled Node script that reads SonarCloud (or self-hosted SonarQube) issues for the current repository and prints a terminal summary — no Sonar web UI needed, and no MCP server or extra install required. The script has zero npm dependencies (it uses Node's built-in fetch), so it runs anywhere Node is available. Each person just needs their own Sonar token.

What it reports

  • Default: unresolved issues introduced in the new code of the current git branch. This is the "did I just introduce a problem?" check you run before committing or opening a pull request.
  • --all: every unresolved issue on the analyzed branch/PR, not just the new-code period — use this for a full backlog export.

Prerequisites — the token

Requires Node.js 18 or later (the script uses Node's built-in fetch).

The script reads SONAR_TOKEN from the environment first (handy in CI), then from a local .env file (.env, then env/.env, or whatever --env-file points at). Keep the token out of git — .env files are conventionally git-ignored, so each person keeps their own token private. If it is missing, tell the user to:

  1. Sign in to their Sonar instance (e.g. https://sonarcloud.io) → avatar (top right) → My Account → Security.
  2. Generate a User Token, copy it (shown only once).
  3. Set it as an environment variable, or add it to .env:
    • bash: export SONAR_TOKEN=<token>
    • PowerShell: $env:SONAR_TOKEN = "<token>"
    • .env file: add a line SONAR_TOKEN=<token>

Configuration — how it finds the project

The script auto-detects everything from the repo, so the common case needs no arguments:

  • Project key & organization — read from sonar-project.properties (sonar.projectKey, sonar.organization), the canonical file the SonarScanner itself uses. If that file is absent it falls back to the SonarLint binding in .vscode/settings.json (projectKey). Override with --project / --org (or SONAR_ORG).
  • Host — sonar.host.url from sonar-project.properties, else SONAR_HOST_URL, else https://sonarcloud.io. Override with --host.
  • Branch / PR — the current git branch by default.

SonarCloud vs self-hosted SonarQube: the organization parameter is sent only when targeting SonarCloud (or when you pass --org), because self-hosted SonarQube has no organizations concept. For a self-hosted server just point --host at it. On SonarCloud, if no organization is configured anywhere, the script derives it from the project-key prefix (keys are conventionally <org>_<repo>) and notes "derived from key" in its header — pass --org if that guess is wrong.

How to run

node ${CLAUDE_SKILL_DIR}/scripts/extract-sonar-issues.mjs

Pick the variant that matches what the user asked for:

User intentCommand
New issues before commit/PR (default)(no extra flags)
A specific pull request--pull-request <id>
A specific branch--branch <name>
Full unresolved backlog on the branch/PR--all
Only bugs & vulnerabilities--types BUG,VULNERABILITY
Only high-severity issues--severities BLOCKER,CRITICAL<br>(legacy severity names — Sonar deprecated severities and types in Aug 2023 for MQR impact severities/qualities, but the API still honors both flags; the script also reports each issue's MQR impacts)
Quality-gate status (OK / ERROR / NONE) + failed conditions--quality-gate
Include resolved/closed issues too--include-resolved
Target a different project than auto-detected--project <key>
Target a different organization than auto-detected--org <org>
Read the token from a custom .env file--env-file <path>
Self-hosted SonarQube--host https://sonar.mycompany.com
Save full results to a file--out sonar-issues.json
Print more (or fewer) than the default 150 issues--max-print 400
Use as a hard gate (non-zero exit on findings)--fail-on-issues

Run with -h to see every option.

Interpreting the result

  • The script prints the host, project, the target (branch or PR), the scope, counts by severity and type, and one line per issue as file:line + message + rule. The JSON dump (--out) also carries each issue's MQR impacts array (software quality + severity) when the server provides it.
  • The per-issue listing is capped at 150 lines (worst severities first) so a large backlog cannot flood the terminal; anything beyond that prints as … and N more. The cap is terminal-only — --out always writes every fetched issue. Raise or lower it with --max-print <n>.
  • With --quality-gate, the script first prints the gate verdict — OK, ERROR, or NONE (no gate computed yet) — and one line per failed condition with its metric, the measured value, and the threshold that failed it. Lead your verdict with the gate status when the user asked about it.
  • If the user asks to see the full JSON after a run with --out, Read that file directly rather than re-running the script.
  • After running, give the user a short verdict, not a raw dump: lead with whether the branch is clean, then call out the highest-severity new issues and where they are. If there are many, group by severity and summarize the rest.
  • Important timing note — Sonar only knows about code that its scan has already analysed. Right after a local git commit (before the branch is pushed and the CI scan runs), this check still reflects the previous push. For truly live, in-editor feedback as you type, SonarLint connected mode is the right tool; this skill is best run after pushing a branch or once a pull request exists.

When NOT to use this skill

  • Running the actual Sonar scan (that happens in your CI pipeline, not here) — this skill only reads results.
  • Local lint / type / test gates — those are your project's own commands (e.g. npm run lint, npm test), not this skill.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.