running-code-analyzer

Run Salesforce Code Analyzer scans and summarize violations from natural-language requests.

803|289|Updated Nov 7, 2025
One-click install
npx skills add https://github.com/forcedotcom/sf-skills --skill running-code-analyzer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: running-code-analyzer
Source: https://github.com/forcedotcom/sf-skills/tree/main/skills/running-code-analyzer
Command: npx skills add https://github.com/forcedotcom/sf-skills --skill running-code-analyzer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill turns natural-language requests into repeatable Salesforce Code Analyzer scans, then summarizes violations so you can quickly focus on security, quality, and best-practice problems.

Core Features & Use Cases

  • Smart scan command construction: Selects engines (PMD, ESLint, CPD, RetireJS, Flow, SFGE, ApexGuru) and builds the correct sf code-analyzer run invocation with proper rule selectors and targets.
  • Deterministic report + parsing: Always writes results to timestamped files, then summarizes top findings by severity, rule frequency, and files.
  • Safe, engine-provided fixes workflow: Discovers fixable violations, asks for explicit confirmation, applies deterministic fixes, and produces a post-fix summary.
  • Diff-aware and format-flexible scanning: Supports scanning changed files (via git diff filtering logic) and emits JSON/HTML/SARIF/CSV/XML using --output-file extension.
  • Vendor-file handling: Filters likely third-party/vendor violations before applying fixes to reduce risk and avoid modifying libraries.

Quick Start

Ask the AI to scan your code for security and run deterministic auto-fixes when available by telling it: "Scan my code for security issues and apply the fixes you can."

Frequently Asked Questions about running-code-analyzer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a Salesforce static code analysis scan using natural language?

Salesforce static code analysis can be triggered from natural-language requests, which the tool translates into the correct `sf code-analyzer run` command with appropriate rule selectors and targets. It executes the scan via Bash and generates timestamped output files for your project.

Can I automatically fix security violations found during a Salesforce code scan?

Yes, security violations can be automatically fixed. The tool discovers deterministic fixes provided by engines like PMD or ESLint, asks for your explicit confirmation before applying any changes, and filters out likely third-party vendor files to prevent modifying external libraries.

How does git diff scanning work for Salesforce code quality checks?

Git diff scanning filters Salesforce code quality checks to only include changed files. This diff-aware logic limits the static analysis scope to your recent modifications, reducing scan time and focusing violation summaries strictly on newly introduced issues.

What static analysis engines are supported for Salesforce code reviews?

Supported static analysis engines include PMD, ESLint, CPD, RetireJS, Flow, SFGE, and ApexGuru. The tool automatically selects the appropriate engine and builds the correct invocation to scan for security vulnerabilities, code quality issues, and best-practice violations.

What output formats are available for Salesforce code-analyzer violation reports?

Violation reports are available in JSON, HTML, SARIF, CSV, and XML formats. The tool determines the output format based on the file extension specified in the `--output-file` flag, parsing results to summarize top findings by severity, rule frequency, and affected files.

Why does the auto-fix workflow filter out vendor files during a security scan?

The auto-fix workflow filters vendor files to reduce risk and avoid modifying third-party libraries. By excluding likely vendor violations before applying deterministic fixes, the tool ensures that automated code corrections only target your own Salesforce project source code.