agentleFS
animuscrmsfdcanimuscrmsfdc/salesforce-vibe-coding/.claude/skills/salesforce-code-analyzer/SKILL.md

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.

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
  1. Distinctive:

    If no specific target is provided, scan all Apex classes and triggers:

    line 18
  2. Distinctive:

    If a specific file or folder is provided as an argument, scan only that target:

    line 29

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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-severity

If 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-severity

Step 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: X

List each violation with: file path, line number, rule name, description.

Step 3 — Prioritise

Focus on Severity 1 (High) violations first:

  • ApexSharingViolations — missing with sharing / without sharing
  • ApexSOQLInjection — dynamic SOQL with unsanitised input
  • ApexCRUDViolation — missing FLS/CRUD enforcement
  • AvoidHardCodedId — hardcoded record/org IDs
  • AvoidSoqlInLoops — SOQL inside a for loop
  • AvoidDmlStatementsInLoops — 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-severity

skill: 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-severity

Ruleset reference

The project ruleset is at pmd-ruleset.xml in the project root.

Enforced rules (CI blocks on Severity ≤ 2)

RuleCategoryWhy
ApexSharingViolationsSecurityMissing sharing model allows data leaks
ApexSOQLInjectionSecurityString-concatenated queries allow injection
ApexCRUDViolationSecurityMissing FLS/CRUD enforcement
ApexDangerousMethodsSecurityUnsafe crypto/exec patterns
ApexInsecureEndpointSecurityHTTP instead of HTTPS
AvoidSoqlInLoopsPerformanceGovernor limit risk
AvoidDmlStatementsInLoopsPerformanceGovernor limit risk
AvoidHardCodedIdError ProneBreaks across environments
EmptyCatchBlockError ProneSwallows exceptions silently
AvoidLogicInTriggerBest PracticesLogic must live in handler classes

Excluded rules (too noisy)

RuleReason
AvoidDebugStatementsDev-time debugging is acceptable
ApexAssertionsShouldIncludeMessageExisting test baseline doesn't follow this
QueueableWithoutFinalizerInformational only

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.