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/rule-name-resolution.md
View on GitHub# Rule Name Resolution (Fuzzy Matching)
**⚠️ CRITICAL:** The `rules` section in `code-analyzer.yml` requires the EXACT full rule name as it appears in Code Analyzer's rule registry. A misspelled or partial name will be silently ignored — the override won't apply, and no error is shown.
## Why This Matters
Unlike `--rule-selector` (which returns 0 results on mismatch), a wrong name in `code-analyzer.yml` is SILENTLY ignored. The config validates fine, but the override simply doesn't apply. This makes typos and partial names dangerous.
## Common Fuzzy → Exact Mappings
Users will often refer to rules by approximate, partial, or descriptive names:
| User Says | Exact Rule Name | Engine |
|-----------|----------------|--------|
| "the ApexDoc rule" | `ApexDoc` | `pmd` |
| "no-console" | `no-console` | `eslint` |
| "CRUD violation" | `ApexCRUDViolation` | `pmd` |
| "hardcoded values" | `@salesforce-ux/slds/no-hardcoded-values-slds2` | `eslint` |
| "unused variables" | `no-unused-vars` | `eslint` |
| "soql injection" | `ApexSOQLInjection` | `pmd` |
| "global modifier" | `AvoidGlobalModifier` | `pmd` |
| "empty catch" | `EmptyCatchBlock` | `pmd` |
## Lookup Procedure
When you are NOT 100% certain of the exact full rule name:
1. **Do NOT guess** — a wrong name silently fails (the override is ignored with no error)
2. **Look up the rule first** using the `sf code-analyzer rules` command with grep:
```bash
sf code-analyzer rules --rule-selector all 2>&1 | grep -i "<USER_KEYWORD>"
```
3. **If grep returns exactly one match** → use that exact rule name in the YAML
4. **If grep returns multiple matches** → present them to the user and ask which one they meant
5. **If grep returns 0 matches** → try broader keywords or tell the user no rule matched
## When You CAN Skip the Lookup
Skip only when confident in the exact name:
- User provides the full exact name (e.g., "ApexCRUDViolation", "no-unused-vars")
- The rule is extremely common AND unambiguous (e.g., "ApexDoc", "no-console")
## Matching Strategies for Ambiguous Input
| User Says | Grep Command | Notes |
|-----------|-------------|-------|
| "the doc rule" | `grep -i "doc"` | May match ApexDoc, JSDoc, etc. — ask user if multiple |
| "CRUD" | `grep -i "crud"` | Likely matches ApexCRUDViolation |
| "hardcoded" | `grep -i "hardcoded"` | May match multiple SLDS/custom rules |
| "console" | `grep -i "console"` | Likely matches no-console |
| "security rules" | Use `--rule-selector all:Security` | Category-based, not name-based |
| "the injection rule" | `grep -i "injection"` | May match ApexSOQLInjection, ApexXSSFromURLParam, etc. |
| "unused" | `grep -i "unused"` | May match no-unused-vars, UnusedLocalVariable, etc. |
## Identifying the Engine
The YAML structure requires nesting under the correct engine. Always extract BOTH the engine and rule name from the `sf code-analyzer rules` output:
```yaml
rules:
<engine>: # ← must match the engine that owns the rule
<rule_name>:
severity: ...
disabled: ...
```
The output of `sf code-analyzer rules` shows engine name alongside each rule. Use that to determine the correct YAML path.
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 |