원클릭으로
sonar-analyze
Analyze a file or code snippet for quality and security issues using SonarQube
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Analyze a file or code snippet for quality and security issues using SonarQube
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | sonar-analyze |
| description | Analyze a file or code snippet for quality and security issues using SonarQube |
| argument-hint | [file-path] |
Analyze code for quality and security issues using the SonarQube MCP Server.
This skill drives one of two MCP tools depending on what your org is entitled to. Exactly one of them is exposed in a given session — pick whichever is available:
mcp__sonarqube__run_advanced_code_analysis (preferred when present). Runs SonarQube Cloud's server-side engine with the full project analysis context, so it performs deeper, cross-file detection. The MCP server reads the file directly from the mounted workspace — you pass a relative path, not the file contents. Available only for entitled organizations (the agent mounts the workspace into the server for this).mcp__sonarqube__analyze_code_snippet (fallback). Analyzes only a single file at a time with no project context, so results may be less complete than a full project scan. You pass the file contents inline.Determine availability by checking which tool exists in your session. If run_advanced_code_analysis is available, analyze_code_snippet will not be — and vice versa. Use the one that is present; do not ask the user to switch tooling.
analyze_code_snippet: results cover a single file with no project context and may not match a full SonarQube project scan. Mention this limitation when presenting results if the user might expect exhaustive coverage.run_advanced_code_analysis: results leverage full project context, so no single-file caveat is needed.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 one of the following tools to be available in your session:
mcp__sonarqube__run_advanced_code_analysis, ormcp__sonarqube__analyze_code_snippet.If the tool call fails, surface the tool error verbatim and stop. Auth, credentials, entitlement, and MCP server configuration are runtime infrastructure concerns and are not user-fixable from chat — do not ask the user to verify env vars or to install or run any CLI.
Both tools analyze 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.
Use the project-relative path (e.g. src/auth/login.py), not an absolute path.
Determine the file scope: "TEST" or "MAIN".
run_advanced_code_analysis (preferred)The server reads the file itself from the mounted workspace, so do not read the file or pass its contents. Provide the relative path, the branch, and the scope:
{
"projectKey": "<only-if-required>",
"branchName": "<current branch or PR source branch>",
"filePath": "src/auth/login.py",
"fileScope": ["MAIN"]
}
branchName selects which analysis context to use. Pass the currently checked-out branch (or, in a PR context, the PR's source branch). If you cannot determine it, omit it and let the server default to the main branch.SONARQUBE_PROJECT_KEY), so omit projectKey unless the tool requires it or the user targets another project.analyze_code_snippet (fallback)Read the file's full content first (required for codeSnippet and language detection), then detect the language from the file extension:
| Extension | Language key |
|---|---|
.py | py |
.js .jsx | js |
.ts .tsx | ts |
.java | java |
.go | go |
.php | php |
.cs | cs |
.rb | rb |
.swift | swift |
.kt | kotlin |
.c .cpp .cc .h | cpp |
{
"projectKey": "<only-if-required>",
"filePath": "src/auth/login.py",
"codeSnippet": "<full file content>",
"language": "py",
"scope": "MAIN"
}
Omit projectKey when the integration default applies.
If issues are found, present them as a table sorted by line number:
## SonarQube Analysis — `src/auth/login.py`
Found **3 issue(s)**:
| Line | Severity | Rule | Message |
| ---- | ---------- | ------------ | ----------------------------------------------------- |
| 12 | 🔴 Blocker | python:S2077 | Make sure that executing this SQL query is safe here. |
| 34 | 🟠 Major | python:S1481 | Remove the unused local variable "token". |
| 67 | 🟡 Minor | python:S1135 | Complete the task associated to this "TODO" comment. |
Severity icons (the label depends on the server version):
If no issues are found:
## SonarQube Analysis — `src/auth/login.py`
✅ No issues found.
After the results, always add:
<rule> <file>:<line> to fix a specific issue, or ask me to fix them all."Search for software composition analysis (SCA) dependency risks in a SonarQube project (project key optional when MCP integration already defines the default project)
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)
Fix a specific SonarQube issue in code by rule key and location
Search and filter SonarQube issues for a project, branch, or pull request via the SonarQube MCP Server (project key optional when MCP integration already defines the default project)
List SonarQube projects accessible to the current user via the SonarQube MCP Server
Show SonarQube quality gate status for a project — pass/fail and each condition (metric key, threshold, actual value). Project key optional when MCP integration already defines the default project.