salesforce-code-analyzer
Skill0 starsChanged 6 months agoMITView on GitHub
Static analysis skills for animuscrm — run PMD via Salesforce Code Analyzer, interpret violations, prioritise fixes, and enforce rules in CI.
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- architecture-decision-recordsSkill
- salesforce-adminSkill
- salesforce-developer-apexSkill
- salesforce-devopsSkill
- salesforce-test-overwatchSkill
- skillsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
If no specific target is provided, scan all Apex classes and triggers:
- Distinctive: line 29
If a specific file or folder is provided as an argument, scan only that target:
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Salesforce Code Analyzer Skill — animuscrm
Covers running PMD static analysis, interpreting results, and managing the ruleset.
skill: scan (default workflow)
Trigger phrase: "run code analyzer" / "run pmd" / "scan for violations" / "static analysis"
Step 1 — Run the scan
If no specific target is provided, scan all Apex classes and triggers:
sf scanner run \
--target "force-app/main/default/classes,force-app/main/default/triggers" \
--engine pmd \
--pmdconfig pmd-ruleset.xml \
--format table \
--normalize-severityIf a specific file or folder is provided as an argument, scan only that target:
sf scanner run \
--target "<target>" \
--engine pmd \
--pmdconfig pmd-ruleset.xml \
--format table \
--normalize-severityStep 2 — Summarise results
Group violations by severity and category:
Severity 1 (High): X violations
Severity 2 (Medium): X violations
Severity 3 (Low): X violations
By category:
Security: X
Performance: X
Error Prone: X
Best Practices: XList each violation with: file path, line number, rule name, description.
Step 3 — Prioritise
Focus on Severity 1 (High) violations first:
ApexSharingViolations— missingwith sharing/without sharingApexSOQLInjection— dynamic SOQL with unsanitised inputApexCRUDViolation— missing FLS/CRUD enforcementAvoidHardCodedId— hardcoded record/org IDsAvoidSoqlInLoops— SOQL inside a for loopAvoidDmlStatementsInLoops— DML inside a for loop
Step 4 — Fix plan (with approval gate)
For each High violation, propose a specific fix:
Violation: <RuleName> in <file>:<line>
Issue: <one sentence>
Fix: <specific code change>Present the plan and wait for user approval before implementing any changes.
skill: scan-security-only
Trigger phrase: "scan for security issues" / "security analysis"
sf scanner run \
--target "force-app/main/default/classes,force-app/main/default/triggers" \
--engine pmd \
--category "Security" \
--format table \
--normalize-severityskill: scan-single-file
Trigger phrase: "scan <ClassName>" / "analyze <ClassName>"
sf scanner run \
--target "force-app/main/default/classes/<ClassName>.cls" \
--engine pmd \
--pmdconfig pmd-ruleset.xml \
--format table \
--normalize-severityRuleset reference
The project ruleset is at pmd-ruleset.xml in the project root.
Enforced rules (CI blocks on Severity ≤ 2)
| Rule | Category | Why |
| ApexSharingViolations | Security | Missing sharing model allows data leaks |
| ApexSOQLInjection | Security | String-concatenated queries allow injection |
| ApexCRUDViolation | Security | Missing FLS/CRUD enforcement |
| ApexDangerousMethods | Security | Unsafe crypto/exec patterns |
| ApexInsecureEndpoint | Security | HTTP instead of HTTPS |
| AvoidSoqlInLoops | Performance | Governor limit risk |
| AvoidDmlStatementsInLoops | Performance | Governor limit risk |
| AvoidHardCodedId | Error Prone | Breaks across environments |
| EmptyCatchBlock | Error Prone | Swallows exceptions silently |
| AvoidLogicInTrigger | Best Practices | Logic must live in handler classes |
Excluded rules (too noisy)
| Rule | Reason |
| AvoidDebugStatements | Dev-time debugging is acceptable |
| ApexAssertionsShouldIncludeMessage | Existing test baseline doesn't follow this |
| QueueableWithoutFinalizer | Informational only |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

