neuron-explorer
Qwen3.5‑4B 전용 조향형 뉴런 탐색기, 모든 MLP 뉴런을 밀어 결과를 보관·탐색
SonarQube CLI로 터미널에서 코드 품질·보안을 관리, 비밀 스캔·Claude Code 연동·문제 관리 가능
SonarQube CLI — code quality and security in your terminal. Scan for secrets, integrate Claude Code, and manage SonarQube issues from the command line.
개발 도구TypeScript · ShellGitHub @SonarSource온라인운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
Command-line interface for SonarQube with AI agent integration. Scan for secrets and get fast feedback on code quality and security from your terminal.
저장소 README에서 가져옴
README 전체를 불러오는 중입니다. 아래는 저장된 발췌입니다.
Catch code quality and security issues in your terminal—before they reach production.
The SonarQube CLI integrates enterprise-grade static analysis into your development workflow:README 전문 보기 ↗Catch code quality and security issues in your terminal—before they reach production.
The SonarQube CLI integrates enterprise-grade static analysis into your development workflow:
Use it standalone or integrate with: Git hooks, Claude Code, GitHub Copilot CLI, Codex, Cursor, Antigravity, OpenCode, Devin, Pi, CI/CD pipelines, custom automation
🤖 For AI Agents: If you are an AI agent reading this, navigate to docs/llms.txt for machine-readable command documentation optimized for LLM consumption.
We are actively collecting feedback on this product. Please share your thoughts via this form!
The SonarQube CLI is designed for three distinct use cases:
🤖 Agentic Use — Built-in support for AI coding agents (Claude Code, GitHub Copilot CLI, Codex, Cursor, Antigravity, OpenCode, Devin, and Pi) with safeguards that prevent secrets from being sent to LLM providers
sonar integrate claude
# Now Claude Code will automatically scan for secrets before processing your code
🖥️ Interactive CLI — Run commands directly in your terminal to scan code, check issues, and manage SonarQube projects manually
sonar list issues --project my-app
sonar analyze --file file.ext
⚙️ Scripting & Automation — Integrate into scripts for reporting, dashboards, or automated quality gates
# Generate a report of issues across all projects:
sonar list projects | jq -r '.projects[].key' | while read project; do
echo "Project: $project"
sonar list issues --project "$project" | jq -r '.issues[].severity' | sort | uniq -c
done
Before installing, you need:
SonarQube Access (choose one):
Operating System: Linux (x86-64, ARM64), macOS (ARM64), or Windows (x86-64)
Optional:
First time with SonarQube? Create a free SonarQube Cloud account — no credit card required for open source projects.
Choose the install channel that fits your setup:
Homebrew (macOS/Linux):
brew install sonarqube-cli
Mise (macOS, Linux, or Windows):
mise use -g sonarqube-cli@latest
Install script (Linux/macOS):
curl -o- https://raw.githubusercontent.com/SonarSource/sonarqube-cli/refs/heads/master/user-scripts/install.sh | bash
Install script (Windows, from PowerShell):
irm https://raw.githubusercontent.com/SonarSource/sonarqube-cli/refs/heads/master/user-scripts/install.ps1 | iex
Verify installation:
sonar --version
# Example output: 1.0.0
Note: Restart your terminal after using the install scripts so your updated PATH is reloaded. Homebrew manages PATH automatically, and Mise assumes its shell activation is already configured.
Connect to SonarQube Cloud EU (default):
sonar auth login
# Opens your browser to sign in to SonarQube and generates a user token
# Returns to terminal when complete
For SonarQube Cloud US:
sonar auth login --server https://sonarqube.us
For self-hosted SonarQube Server:
sonar auth login --server https://sonarqube.mycompany.com
Verify authentication:
sonar auth status
# Verifying token......
# [✓ Connected]
# Server https://sonarcloud.io
# Org my-org
# Source OS Keychain
For automation, CI/CD, and AI agents, pass the token via environment variables. The CLI reads them at command time, so nothing is written to disk or the OS keychain.
Generate a token first: SonarQube → My Account → Security → Generate Token.
Then define the following environment variables before invoking sonar (use your runner's secret store in CI, or your preferred local mechanism — direnv, an untracked .env file,
a password manager CLI, etc.):
SONARQUBE_CLI_TOKEN + SONARQUBE_CLI_ORGSONARQUBE_CLI_TOKEN + SONARQUBE_CLI_SERVERWith those exported, any command works without further configuration:
sonar list projects
Set both variables — if only SONARQUBE_CLI_TOKEN is present, the CLI prints a warning on stderr and falls back to keychain credentials, which is rarely what automation wants.
Never commit the token or pass it as a CLI argument.
List your projects:
sonar list projects
# {"projects":[{"key":"my-org_my-app","name":"my-app"},
# {"key":"my-org_demo","name":"demo-project"}],
# "paging":{"pageIndex":1,"pageSize":500,"total":2,"hasNextPage":false}}
Output is JSON by default. Pipe through jq for ad-hoc filtering, e.g. sonar list projects | jq -r '.projects[].key'.
Scan a file for secrets:
cat > test.js <<'EOF'
const STRIPE_KEY = "sk_live_<PASTE_A_REAL_STRIPE_KEY_HERE>";
EOF
sonar analyze secrets test.js
# Sonar Secrets CLI - BETA (2.43.0.11106)
# Trying to authenticate to SonarQube Server or Cloud, in order to enable complete functionality
# Authentication successful
# Running analysis...
# Found 1 secret
# Stripe API Key
# File: test.js
# Location: [1:21-1:53]
# Secret: sk_*****************************
# ❌ Secrets found (227ms)
# 💡 Remove the reported secret, then rerun the scan.
When a secret is found, the command exits with code 51.
Check issues in a project:
sonar list issues --project my-org_my-app --format table --page-size 3
# SEVERITY | RULE | MESSAGE | FILE
# ---------------------------------------------------------------------------------------------------------------
# CRITICAL | typescript:S3776 | Refactor this function to reduce its Cognitive Complexity | src/preview.tsx:17
# CRITICAL | typescript:S2004 | Refactor this code to not nest functions more than 4... | src/Preview.tsx:235
# CRITICAL | typescript:S3776 | Refactor this function to reduce its Cognitive Complexity | src/Description.tsx:43
Supported formats: json (default), table, toon, csv.
💡 Tip: The
--projectflag is often optional—if your working directory contains asonar-project.propertiesfile or a SonarLint connected-mode binding under.sonarlint/, the CLI picks the project key up from there.
cd your-project-directory
sonar analyze --file file.ext
# Analyzes uncommitted changes for new issues
# Only shows issues YOU introduced in your changes
Common options:
sonar analyze --file src/myfile.ts # Analyze a specific file
sonar analyze --base main # Analyze changes vs main branch
sonar analyze --branch feature-xyz # Set branch context
Hooks apply to all Claude Code sessions on this machine:
sonar auth login
sonar integrate claude
This installs:
Hooks apply to all repositories on this machine:
Pre-commit hook (scan staged files before each commit):
sonar integrate git --hook pre-commit
Pre-push hook (scan committed files before each push):
sonar integrate git --hook pre-push
For CI/CD or automation (non-interactive mode):
sonar integrate git --hook pre-commit --non-interactive
# Skips all prompts, fails fast on errors
Hooks apply to all Copilot CLI sessions on this machine:
sonar auth login
sonar integrate copilot
This installs:
$ sonar analyze secrets src/config.ts
sonar-secrets 2.43.0.11106 is already installed (latest)
Sonar Secrets CLI - BETA (2.43.0.11106)
Trying to authenticate to SonarQube Server or Cloud, in order to enable complete functionality
Authentication successful
Running analysis...
Found 1 secret
Stripe API Key
File: src/config.ts
Location: [5:20-5:52]
Secret: sk_*****************************
❌ Secrets found (227ms)
💡 Remove the reported secret, then rerun the scan.
Exit codes: 0 when no secrets are found, 51 when at least one is found.
sonar list issues emits JSON by default; pass --format table for the human-readable view shown below.
$ sonar list issues --project my-org_my-app --severities CRITICAL,BLOCKER --page-size 3 --format table
SEVERITY | RULE | MESSAGE | FILE
-------------------------------------------------------------------------------------------------------------------------
CRITICAL | typescript:S3776 | Refactor this function to reduce its Cognitive Complexity from 26 to the 15 allowed. | code/addons/a11y/src/preview.tsx:17
CRITICAL | typescript:S2004 | Refactor this code to not nest functions more than 4 levels deep. | code/addons/docs/src/blocks/components/Preview.tsx:235
CRITICAL | typescript:S3776 | Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed. | code/addons/vitest/src/components/Description.tsx:43
$ sonar analyze
SonarQube Agentic Analysis: no files in the change set to analyze.
When there are staged changes against a project configured for SonarQube Cloud Agentic Analysis, the analyzer reports new issues introduced by the change set in the same text/
json format selectable via --format.
For AI coding assistants, use --format toon — a token-efficient, YAML-flavored encoding of the same JSON payload:
$ sonar list issues --project my-org_my-app --severities BLOCKER --page-size 1 --format toon
total: 88
p: 1
ps: 1
paging:
pageIndex: 1
pageSize: 1
total: 88
issues[1]:
- key: AZ0avojpNWh-T1cKsujg
rule: "typescript:S3516"
severity: BLOCKER
component: "my-org_my-app:src/ConfigFile.ts"
project: my-org_my-app
line: 377
message: "Refactor this function to not always return the same value."
type: CODE_SMELL
This format is designed for parsing by LLMs and can be used with Claude Code, GitHub Copilot CLI, Codex, Cursor, Antigravity, OpenCode, Devin, Pi, or custom AI workflows.
Symptom: Error: Project 'my-project' not found
Cause: Using the project display name instead of the project key.
Solution: Use the exact project key from the JSON output of sonar list projects:
# Find the correct key:
sonar list projects -q my-project
# {"projects":[{"key":"my-org_my-project","name":"my-project"}],
# "paging":{"pageIndex":1,"pageSize":500,"total":1,"hasNextPage":false}}
# Or, for just the keys:
sonar list projects -q my-project | jq -r '.projects[].key'
# Use the key value (not the name) for subsequent commands:
sonar list issues --project my-org_my-project
Cause: Project hasn't been scanned yet, or you're checking the wrong branch.
Solution:
sonar auth status
sonar list issues --project my-org_my-app --branch feature-xyz
Symptom: Error: Invalid token or browser authentication fails
Solution: Use token-based authentication:
SONARQUBE_CLI_TOKEN=YOUR_TOKEN
SONARQUBE_CLI_SERVER=https://sonarcloud.io # or your SonarQube Server URL
SONARQUBE_CLI_ORG=your-org-key # SonarQube Cloud only
For SonarQube Cloud, ensure you're using the correct region:
https://sonarcloud.iohttps://sonarqube.ussonar analyze says "Not a git repository"Cause: sonar analyze requires git to detect changes.
Solution:
cd your-project
sonar analyze
sonar analyze --file src/myfile.ts
Symptom: Installed pre-commit hook but it doesn't execute on git commit
Solution:
Check the hook file exists and is executable:
ls -la .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
Test the hook manually:
.git/hooks/pre-commit
For global hooks, verify git configuration:
git config --global core.hooksPath
# Should show: ~/.sonar/git-hooks (or similar)
Symptom: After installing, terminal doesn't recognize sonar
Solution:
Restart your terminal if you used the install script, or if you just changed your shell setup.
If you installed with Homebrew, make sure Homebrew itself is already on your PATH, then retry brew install sonarqube-cli.
If you installed with Mise, make sure your shell is already configured for Mise and reopen your terminal.
If you used the install script and it still doesn't work, manually add it to PATH:
Linux/macOS — Add to ~/.bashrc or ~/.zshrc:
export PATH="$HOME/.local/share/sonarqube-cli/bin:$PATH"
Then reload: source ~/.bashrc (or ~/.zshrc)
Windows — The installer should have updated PATH automatically. Try:
Verify the binary exists:
# Install script on Linux/macOS:
ls -la ~/.local/share/sonarqube-cli/bin/sonar
# Install script on Windows (PowerShell):
ls $env:LOCALAPPDATA\sonarqube-cli\bin\sonar.exe
Symptom: sonar analyze secrets flags test data or example code
Solution:
Secrets scanning is intentionally sensitive to avoid missing real credentials. For test files:
Use obviously fake values:
// ✅ Won't be flagged:
const API_KEY = 'test_fake_key_for_unit_tests';
const TOKEN = 'dummy-token-12345';
// ❌ Might be flagged:
const API_KEY = 'sk_live_abc123xyz789';
Store test secrets in ignored files:
.env.test files are often excluded by defaultsrc/Include in your report:
sonar --versionSee State Management for more information.
brew uninstall sonarqube-cli
mise use -g --remove sonarqube-cli
mise uninstall --all sonarqube-cli
~/.local/share/sonarqube-cli/ folder.export PATH="$HOME/.local/share/sonarqube-cli/bin:$PATH" from your ~/.bashrc or ~/.zshrc files.%localappdata%\sonarqube-cli\ folder.PATH user-level environment variable.The SonarQube CLI collects anonymous usage data and error reports to help improve the product.
Telemetry: Anonymous command usage statistics are sent to SonarSource. See telemetry-sample.md for a sample of the data that is collected.
Error reporting: Unhandled exceptions are reported to Sentry to help us identify and fix crashes.
Both are enabled by default and share the same opt-out toggle. To disable all data collection:
sonar config set telemetry.enabled false
You can also set the DO_NOT_TRACK=1 environment variable to disable telemetry for a session without changing persisted configuration.
No personally identifiable information is transmitted.
We don't accept external pull requests on this project. This isn't about the quality of your change — keeping all changes in one place lets us properly track, plan, prioritize, and test everything that goes into the CLI.
That doesn't mean we don't want to hear from you — we do. If you've hit a bug or have an idea, please open a GitHub Issue and we'll take it from there.
The source is public, so you're welcome to fork it, read it, and experiment. See CONTRIBUTING.md if you'd like to build the CLI from source.
Copyright SonarSource Sàrl.
SonarQube CLI is released under the GNU Lesser General Public License, Version 3.0,.