Claude Skills Guide

Claude Code SonarQube Code Quality Workflow

Integrating Claude Code with SonarQube creates a powerful code quality pipeline that catches issues before they reach production. This workflow combines Claude’s AI-assisted development capabilities with SonarQube’s static analysis engine, giving you automated quality gates that improve codebases systematically.

Setting Up SonarQube for Your Project

Before integrating with Claude, ensure SonarQube is running and accessible. You can use the community edition via Docker:

docker run -d --name sonarqube -p 9000:9000 sonarqube:latest

Once SonarQube is running, generate an authentication token from your user profile in the web interface. You’ll need this token for CLI authentication.

Basic SonarQube Scanner Integration

The most straightforward approach uses the SonarQube Scanner CLI directly in your workflow. First, install the scanner:

npm install -g sonarqube-scanner

Create a sonar-project.properties file in your project root:

sonar.projectKey=my-project
sonar.sources=src
sonar.host.url=http://localhost:9000
sonar.token=your-sonar-token-here

Run the scanner to analyze your codebase:

sonarqube-scanner

Integrating with Claude Code Sessions

When working in Claude Code, you can invoke analysis at specific points in your development workflow. While Claude doesn’t have a dedicated sonarqube skill, you can create a custom skill or simply describe your workflow needs directly.

For example, after writing new code, ask Claude to run analysis:

Run SonarQube analysis on the recent changes and explain any new issues flagged.

Claude will execute the scanner, parse the results, and help you address quality issues. This creates a feedback loop where AI assistance and static analysis work together.

Automated Quality Gates in CI/CD

For automated pipelines, create a shell script that combines analysis with quality gate enforcement:

#!/bin/bash
set -e

echo "Running SonarQube analysis..."
sonar-scanner \
  -Dsonar.projectKey=$PROJECT_KEY \
  -Dsonar.sources=src \
  -Dsonar.host.url=$SONAR_HOST \
  -Dsonar.token=$SONAR_TOKEN

# Wait for results
sleep 5

# Check quality gate status
QUALITY_GATE=$(curl -s -u $SONAR_TOKEN: \
  "$SONAR_HOST/api/qualitygates/project_status?projectKey=$PROJECT_KEY" \
  | jq -r '.projectStatus.status')

if [ "$QUALITY_GATE" != "OK" ]; then
  echo "Quality gate failed! Issues found."
  curl -s -u $SONAR_TOKEN: \
    "$SONAR_HOST/api/issues/search?componentKeys=$PROJECT_KEY&statuses=OPEN" \
    | jq -r '.issues[] | "\(.rule)\n\(.message)\n"'
  exit 1
fi

echo "Quality gate passed!"

This script runs analysis, retrieves quality gate status, and fails the build if standards aren’t met. Integrate it into GitHub Actions, GitLab CI, or Jenkins pipelines.

Claude Code Workflow Patterns

Several Claude Code skills complement SonarQube analysis effectively:

The tdd skill helps you write tests before implementation, reducing the bugs SonarQube might later flag. Using test-driven development alongside static analysis creates a robust development cycle where issues are caught at multiple stages.

The pdf skill proves useful when generating code quality reports. After SonarQube analysis, ask Claude to create a PDF summary of the findings for stakeholder reviews or documentation archives.

For frontend projects, combining frontend-design skill guidance with SonarQube ensures your React, Vue, or Angular code meets both design standards and quality thresholds.

The supermemory skill helps track recurring code quality issues across your projects. When SonarQube repeatedly flags similar problems, use supermemory to document patterns and prevention strategies for future development.

Practical Example: Fixing Technical Debt

Suppose SonarQube flags duplicated code across your codebase. Here’s how the combined workflow works:

  1. Run sonar-scanner to identify duplication hotspots
  2. In Claude Code, ask: “Review the duplication issues from SonarQube and suggest refactoring approaches”
  3. Claude analyzes the flagged code sections
  4. Implement the refactoring with Claude’s guidance
  5. Re-run SonarQube to verify the issues are resolved

This cycle continues until your quality gates pass. Over time, your codebase improves systematically rather than accumulating technical debt indefinitely.

Customizing Quality Profiles

SonarQube allows you to customize which rules apply to your project. Access Quality Profiles from the administration menu and activate or deactivate rules based on your team’s standards.

For JavaScript/TypeScript projects, consider these commonly adjusted rules:

After customizing profiles, sync the settings with your CI/CD pipeline to ensure consistent enforcement across all environments.

SonarQube’s web interface provides dashboards showing quality trends over time. Key metrics to track include:

Review these metrics during sprint retrospectives. Use the data to identify areas requiring focused improvement in upcoming development cycles.

Conclusion

Combining Claude Code with SonarQube creates a comprehensive code quality workflow. Claude handles the intelligent aspects—understanding context, suggesting solutions, and assisting with refactoring—while SonarQube provides objective, automated analysis. Together, they form a quality pipeline that improves codebases systematically without slowing development velocity.

The key is establishing the workflow early in project setup, running analysis consistently, and treating quality gates as non-negotiable checkpoints. Over weeks and months, you’ll see measurable improvements in code quality metrics.

Built by theluckystrike — More at zovo.one