forcedotcom/sf-skills / plugins/builder/salesforce-code-quality/skills/dx-code-analyzer-configure
dx-code-analyzer-configure
FlaggedSet up, configure, and troubleshoot Salesforce Code Analyzer for any project. Handles installation, prerequisite checks, diagnosing broken setups, creating and editing code-analyzer.yml overrides, engine-specific settings, ignore patterns, severity overrides, and CI/CD pipeline setup. TRIGGER when: user says 'set up code analyzer', 'configure code analyzer', 'install code analyzer', 'code analyzer not working', 'fix my setup', 'scan failing', 'check my setup', 'enable/disable engine', 'exclude files', 'change severity', 'set up GitHub Actions', 'set up CI/CD', 'add to pipeline', 'pipeline fail', 'update my workflow', 'quality gate', 'fail on violations', 'scan changed files only', 'add SARIF', 'code-analyzer.yml', 'ESLint config', 'increase SFGE memory', or reports errors running Code Analyzer. DO NOT TRIGGER when: user wants to run a scan (use dx-code-analyzer-run), fix violations, explain rules, create custom rules (use dx-code-analyzer-custom-rule-create), or suppress violations.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 22.0 KB |
| examples/apex-project-config.yml | config | 1.2 KB |
| examples/ci-github-actions.yml | config | 2.5 KB |
| examples/fullstack-project-config.yml | config | 1.3 KB |
| examples/lwc-project-config.yml | config | 772 B |
| references/ci-cd-templates.md | markdown | 23.4 KB |
| references/config-schema.md | markdown | 6.7 KB |
| references/diagnostic-flow.md | markdown | 3.1 KB |
| references/engine-prerequisites.md | markdown | 5.1 KB |
| references/rule-name-resolution.md | markdown | 3.1 KB |
| references/troubleshooting.md | markdown | 7.3 KB |
| scripts/check-prerequisites.shexecutable | script | 6.2 KB |
| scripts/generate-config.shexecutable | script | 3.7 KB |
| scripts/validate-config.shexecutable | script | 5.1 KB |
references/diagnostic-flow.md
View on GitHub# Diagnostic Flow: Fix a Broken Setup
**TRIGGER:** User says "not working", "broken", "getting errors", "scan fails", "help me fix", etc.
## NEVER DO THESE (anti-patterns that waste time)
- ❌ NEVER run `which sfdx`, `which sf`, `find`, `ls /opt/homebrew/bin/` or search for binaries
- ❌ NEVER use an old `sfdx` binary as a workaround — it is NOT a substitute for `sf`
- ❌ NEVER create symlinks (`ln -s`) to work around missing commands
- ❌ NEVER check PATH, inspect Cellar directories, or search for alternative installations
- ❌ NEVER proceed to Layer 2 if Layer 1 failed — fix Layer 1 first
- ❌ NEVER give the user a list of manual steps — fix it yourself or give ONE command
## Diagnostic Flow (follow this EXACTLY, no deviation)
Run **ONLY** this one command first:
```bash
sf --version 2>&1
```
**If output contains "command not found":**
→ STOP. Do not run any other commands. Tell user: "sf CLI is not installed. I'll install it now."
→ Ask user for permission, then run: `npm install -g @salesforce/cli`
→ After install, re-run `sf --version 2>&1` to verify. If it works, continue to next layer.
**If sf works**, run ONLY:
```bash
sf plugins --core 2>&1 | grep -i "code-analyzer"
```
**If output is empty or shows "JIT" but not a real version:**
→ STOP. Run: `sf plugins install @salesforce/plugin-code-analyzer`
→ After install, re-check. If it works, continue to next layer.
**If plugin is installed**, check engine deps:
```bash
java -version 2>&1
node --version 2>&1
```
**If all pass**, verify with a scan:
```bash
sf code-analyzer run --rule-selector Recommended 2>&1 | tail -20
```
## Fix Table
| Error Pattern | The ONE Fix |
|--------------|-------------|
| `sf: command not found` | `npm install -g @salesforce/cli` |
| Plugin missing / JIT error | `sf plugins install @salesforce/plugin-code-analyzer` |
| `Cannot find module` | `sf plugins uninstall @salesforce/plugin-code-analyzer && sf plugins install @salesforce/plugin-code-analyzer` |
| `java: command not found` | Install Java 11+ (see `<skill_dir>/references/engine-prerequisites.md`) |
| `OutOfMemoryError` (SFGE) | Add `engines.sfge.java_max_heap_size: "4g"` to `code-analyzer.yml` |
| `YAMLException` | Read the config file, fix YAML syntax |
| `EPERM` / npm permission error | Tell user to run: `sudo chown -R $(whoami) ~/.npm` — then wait for them to confirm, then retry the SAME install command that failed. Do NOT dump next steps. |
## After Fix: Verify and Hand Off
Re-run the check for the fixed layer. Once a scan succeeds, tell the user what was fixed and **proceed to run the full scan**.
## When a fix requires user action (sudo, manual step)
Tell the user ONLY the ONE command they need to run and WHY. Then STOP and WAIT for them to confirm it's done. Do NOT:
- ❌ List the remaining steps ("after that, do X, then Y, then Z")
- ❌ Tell them what to run next after the manual step
- ❌ Provide a multi-step recovery plan
- ❌ Ask "would you like me to attempt with sudo or do it yourself"
Just say: "Run this command: `<command>`. It fixes [reason]. Let me know when it's done and I'll continue."
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |