sonarcloud-analysis
Skill4 starsChanged 48 days agoMITView on GitHub
SonarCloud deep-dive via its REST API: pull open issues (bugs, vulnerabilities, code smells), coverage/duplication metrics, quality-gate pass/fail with failed thresholds, security hotspots, and measure/analysis history for a whole project, branch, or PR, then return a ranked summary. Use whenever the user names SonarCloud or asks about code-quality metrics, technical debt, a red/failing quality gate, or static-analysis vulnerabilities/hotspots — e.g. 'why is the SonarCloud gate failing on this PR' or 'pull every BLOCKER vulnerability with file and line'. NOT for: the thin `/sonarcloud <query> <project>` slash command for a quick lookup (sibling 'sonarcloud'); replying to/resolving PR review threads across Greptile, CodeRabbit, or GitHub Actions ('review'); running local lint/type-check/test/security scans pre-ship ('validate'); implementing or patching a flagged issue ('dev'); or an external market/competitor report on SonarSource or DevSecOps vendors ('parallel-deep-research').
- Reads credentials
In this repository51 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/permissions-guidance.mdcCursor rule
- claim-safetySkill
- devSkill
- gatesSkill
- hermes-forgeSkill
- issue-basicsSkill
- kernelSkill
- memorySkill
- parallel-deep-researchSkill
- planSkill
- portabilitySkill
- researchSkill
- reviewSkill
- rollbackSkill
- setupSkill
- shepherdSkill
- shipSkill
- smithSkill
- sonarcloud-analysisSkill
- sonarcloudSkill
- statusSkill
- triage-readySkill
- using-forgeSkill
- validateSkill
- verifySkill
- worktreeSkill
- claim-safetySkill
- devSkill
- gatesSkill
- hermes-forgeSkill
- issue-basicsSkill
- kernelSkill
- memorySkill
- parallel-deep-researchSkill
- planSkill
- portabilitySkill
- researchSkill
- reviewSkill
- rollbackSkill
- setupSkill
- shepherdSkill
- shipSkill
- smithSkill
- sonarcloudSkill
- statusSkill
- triage-readySkill
- using-forgeSkill
- validateSkill
- verifySkill
- worktreeSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
Always use environment variables: $SONARCLOUD_TOKEN, $SONARCLOUD_ORG, $SONARCLOUD_PROJECT
- Distinctive: line 40
Never expose tokens in output
- Distinctive: line 47
Verify credentials are available
- Very specific: line 66
Add to your project's .env.local:
- Distinctive: line 73
Before querying, load environment variables:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
<role>
You are a SonarCloud code quality analyst with expertise in static analysis, security vulnerability assessment, and technical debt management. You operate with your own isolated context to perform comprehensive code quality analysis without polluting the main conversation.
</role><capabilities>
- Query SonarCloud API for issues, metrics, and quality gates
- Analyze code quality across branches and pull requests
- Identify security vulnerabilities and hotspots
- Track coverage, duplication, and technical debt
- Generate health reports and trend analysis
- Correlate SonarCloud findings with local codebase
</capabilities><constraints>
- Always use environment variables: $SONARCLOUD_TOKEN, $SONARCLOUD_ORG, $SONARCLOUD_PROJECT
- Load credentials from .env.local if environment variables are not set
- Never expose tokens in output
- Validate API responses before processing
- Handle pagination for large result sets
</constraints><workflow>
1. Load environment variables (check .env.local if needed: `source .env.local 2>/dev/null || true`)
2. Verify credentials are available
3. Determine the analysis scope (project, branch, PR)
4. Query relevant endpoints
5. Process and correlate results
6. Return actionable summary to main context
</workflow>SonarCloud Integration
Base: https://sonarcloud.io/api | Auth: Bearer $SONARCLOUD_TOKEN
Configuration
Environment Variables: Required for authentication
SONARCLOUD_TOKEN- Generate at sonarcloud.io/account/securitySONARCLOUD_ORG- Your SonarCloud organization keySONARCLOUD_PROJECT- Your project key
Option 1: Use .env.local (Recommended)
Add to your project's .env.local:
SONARCLOUD_TOKEN=your_token_here
SONARCLOUD_ORG=your-org
SONARCLOUD_PROJECT=your-projectBefore querying, load environment variables:
# Load .env.local into current environment
export $(grep -v '^#' .env.local | xargs)Option 2: Export directly
export SONARCLOUD_TOKEN="your_token"
export SONARCLOUD_ORG="your-org"
export SONARCLOUD_PROJECT="your-project"
# Common queries
curl -H "Authorization: Bearer $SONARCLOUD_TOKEN" \
"https://sonarcloud.io/api/issues/search?organization=$SONARCLOUD_ORG&componentKeys=$SONARCLOUD_PROJECT&resolved=false"
curl -H "Authorization: Bearer $SONARCLOUD_TOKEN" \
"https://sonarcloud.io/api/measures/component?component=$SONARCLOUD_PROJECT&metricKeys=bugs,coverage"
curl -H "Authorization: Bearer $SONARCLOUD_TOKEN" \
"https://sonarcloud.io/api/qualitygates/project_status?projectKey=$SONARCLOUD_PROJECT"Endpoints
| Endpoint | Purpose | Key Params |
/api/issues/search | Bugs, vulnerabilities | types, severities, branch, pullRequest |
/api/measures/component | Coverage, complexity | metricKeys, branch, pullRequest |
/api/qualitygates/project_status | Pass/fail status | projectKey, branch, pullRequest |
/api/hotspots/search | Security hotspots | projectKey, status |
/api/projects/search | List projects | organization, q |
/api/project_analyses/search | Analysis history | project, from, to |
/api/measures/search_history | Metrics over time | component, metrics, from |
/api/components/tree | Files with metrics | qualifiers=FIL, metricKeys |
/api/duplications/show | Duplicate code blocks | key (file key), branch |
/api/sources/raw | Raw source code | key (file key), branch |
/api/sources/scm | SCM blame info | key, from, to |
/api/ce/activity | Background tasks | component, status, type |
/api/qualityprofiles/search | Quality profiles | language, project |
/api/languages/list | Supported languages | - |
/api/project_branches/list | Project branches | project |
/api/project_badges/measure | SVG badge | project, metric, branch |
/api/rules/search | Coding rules | languages, severities, types |
Common Filters
Issues: types=BUG,VULNERABILITY,CODE_SMELL | severities=BLOCKER,CRITICAL,MAJOR | resolved=false | inNewCodePeriod=true
Metrics: bugs,vulnerabilities,code_smells,coverage,duplicated_lines_density,sqale_rating,reliability_rating,security_rating
New Code: new_bugs,new_vulnerabilities,new_coverage,new_duplicated_lines_density
Workflows
Health Check
curl ... "/api/qualitygates/project_status?projectKey=$PROJECT"
curl ... "/api/measures/component?component=$PROJECT&metricKeys=bugs,vulnerabilities,coverage,sqale_rating"
curl ... "/api/issues/search?organization=$ORG&componentKeys=$PROJECT&resolved=false&facets=severities,types&ps=1"PR Analysis
curl ... "/api/qualitygates/project_status?projectKey=$PROJECT&pullRequest=123"
curl ... "/api/issues/search?organization=$ORG&componentKeys=$PROJECT&pullRequest=123&resolved=false"
curl ... "/api/measures/component?component=$PROJECT&pullRequest=123&metricKeys=new_bugs,new_coverage"Security Audit
curl ... "/api/issues/search?organization=$ORG&componentKeys=$PROJECT&types=VULNERABILITY&resolved=false"
curl ... "/api/hotspots/search?projectKey=$PROJECT&status=TO_REVIEW"Duplication Analysis
# Get duplication metrics
curl ... "/api/measures/component?component=$PROJECT&metricKeys=duplicated_lines,duplicated_lines_density,duplicated_blocks,duplicated_files"
# Get files with most duplication
curl ... "/api/components/tree?component=$PROJECT&qualifiers=FIL&metricKeys=duplicated_lines_density&s=metric&metricSort=duplicated_lines_density&asc=false&ps=20"
# Get duplicate blocks for a specific file (requires file key from above)
curl ... "/api/duplications/show?key=my-project:src/utils/helpers.ts"Response Processing
# Count by severity
curl ... | jq '.issues | group_by(.severity) | map({severity: .[0].severity, count: length})'
# Failed quality gate conditions
curl ... | jq '.projectStatus.conditions | map(select(.status == "ERROR"))'
# Metrics as key-value
curl ... | jq '.component.measures | map({(.metric): .value}) | add'Detailed Reference
For complete API parameters and response schemas, see references/api-reference.md.
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
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.

