Salesforce Skills for Claude Code | Production-Ready Code from One Prompt with Zero Violations




▶ Watch on YouTube — Full Build and Demo
Salesforce Skills for Claude Code — Production Ready Code from One Prompt | SF Bolt
⚡ SalesforceBolt — Source Code
batra-kapil / salesforcebolt-lwc — salesforce-skills-case-escalation
Case Escalation app built with Salesforce Skills + Claude Code

AI code generation for Salesforce has always had one big problem: the output breaks governor limits, fails Code Analyzer, skips test coverage, and misses the with sharing keyword. Salesforce Skills for Claude Code fix all of that. They're specialized AI capabilities embedded directly into Claude Code that understand Salesforce architecture, governor limits, and deployment requirements — and generate code that's actually ready to deploy.

What Are Salesforce Skills?

Salesforce Skills are specialized AI capabilities that understand Salesforce architecture, governor limits, security patterns, and deployment requirements. Think of them as expert developers embedded directly into your development workflow.

When you ask Claude Code to create something, Skills don't just generate generic code. Behind the scenes, the relevant skill discovers your project conventions and generates production-grade code with proper error handling and governor-safe queries. It enforces guardrails like preventing SOQL in loops and validates bulkification patterns. It creates test classes with 75%+ coverage using TestDataFactory patterns. And before marking the task complete, it runs Salesforce Code Analyzer and executes your test suites automatically.

💡 60+ skills and growingThe official sf-skills repository currently contains 60+ skills covering Apex, LWC, flows, OmniStudio, Data Cloud, B2B commerce, debugging, and more. They are open source — you can fork and customise them for your team's conventions.

Installing Salesforce Skills

Setting up Salesforce Skills takes a single command in your Salesforce project directory:

Bash — install Salesforce Skills
# Navigate to your Salesforce DX project first
cd your-salesforce-project

# Install from the official Salesforce GitHub repository
npx skills forcedotcom/sf-skills

# Or install ALL available skills at once
npx skills forcedotcom/sf-skills --all

The interactive installer lets you select individual skills with the spacebar. You can install at project scope (committed with your project) or global scope (available across all your projects). Installed skills are tracked in skills-lock.json in your project root.

The Four Skills You'll Use Most

generating-apex
Generates bulkified Apex classes with the correct sharing keyword, no SOQL in loops, and proper error handling
generating-apex-test
Generates test classes with 75%+ coverage, Given/When/Then structure, and TestDataFactory patterns
generating-lwc-components
Generates LWC with HTML, JS, and meta.xml, validates pattern formatting on client and server sides
debugging-apex-logs
Parses debug logs for SOQL/DML violations, CPU time, heap consumption, and suggests optimisations

How Skills Work Under the Hood

When you submit a prompt to Claude Code, the system follows a four-stage workflow:

  1. Skill matching — Claude analyses your prompt and activates the relevant skills. "Lightning Web Component" triggers generating-lwc-components, "Apex class" triggers generating-apex, "test class" triggers generating-apex-test.
  2. Skill execution — each skill discovers your project conventions including naming patterns and existing classes, chooses the correct architecture pattern (Service, Controller, Batch, etc.), and generates code with built-in guardrails — enforcing with sharing, rejecting SOQL in loops, and creating required metadata files.
  3. Guardrail enforcement — Skills reject code that violates best practices automatically. They won't complete without test classes. For LWC, they validate pattern formatting on both client and server sides. Every generated class includes its .cls-meta.xml file.
  4. Validation — before reporting success, Skills run sf code-analyzer to catch security violations, execute sf apex run test to verify functionality, and confirm 75%+ coverage is achieved.

Example: Building a Case Escalation Component

Here's an example of the kind of prompt that produces fully deployment-ready code in a single pass. This is similar to the case escalation build in the SF Bolt video above:

Claude Code prompt — Case Escalation
Create a Lightning Web Component named CaseEscalation that:
- Displays open Cases for the current user with Subject, Status, and Priority
- Has an Escalate button on each row that updates Status to 'Escalated'
- Shows a success or error toast after each action
- Uses an Apex controller named CaseEscalationController with an @AuraEnabled method
- Enforces with sharing and bulkifies all DML operations
- Generates a test class with 90%+ coverage using TestDataFactory
- Adds the component to the App Builder for Record pages

Submitting a prompt like this causes Claude Code to automatically activate the right skills, discover your project patterns, and generate all required files in one pass:

  • caseEscalation.html — LWC template
  • caseEscalation.js — component logic with imperative Apex calls
  • caseEscalation.js-meta.xml — metadata for App Builder exposure
  • CaseEscalationController.cls — Apex controller with error handling
  • CaseEscalationController.cls-meta.xml — Apex metadata
  • CaseEscalationControllerTest.cls — test class with bulk testing for 251+ records
  • CaseEscalationControllerTest.cls-meta.xml — test metadata

Advanced Patterns Skills Can Handle

Skills handle complex scenarios well beyond a basic CRUD component:

PatternWhat to ask forWhat Skills generate
Batch jobs"Create a batch Apex class to archive Cases older than two years"Database.Stateful, governor-safe queries, start/execute/finish methods, test class with 251+ record bulk testing
Service layer"Create an AccountService class using the Service-Selector-Domain pattern"AccountService.cls with sharing, AccountSelector.cls for queries, List<Database.SaveResult> for partial success, TestDataFactory test class
Screen flows"Create a screen flow for lead qualification with decision routing"Flow metadata following Salesforce best practices with decision elements and queue assignments
Debug analysis"Analyse Apex logs in debug.log to find governor limit issues"SOQL/DML violation report, CPU time and heap analysis, specific optimisation suggestions

Best Practices for Prompting Skills

The quality of your output improves significantly with more specific prompts:

  • Include field API names — instead of "save account data", say "save Account Name, Phone, and BillingCity fields"
  • Name the architecture explicitly — "using Service-Selector-Domain pattern" or "as a Queueable with Finalizer"
  • Specify coverage targets — "test class with 90%+ coverage" gives Skills a goal to hit, not just the 75% default
  • Be conversational — if the first pass isn't right, just say "Add bulk error handling" or "Change the test class to use TestDataFactory patterns". Skills maintain context.
⚠️ Always review before deploying to productionThe official blog is explicit on this: verify field API names match your org schema, check custom objects and fields exist in your target org, review sharing rules and field-level security, test in sandbox first, and run Salesforce Code Analyzer manually as an extra safety check.

Skills as a Learning Tool

The official blog makes an interesting observation: even experienced developers can use Skills to discover best practices. The generated test classes show the correct Given/When/Then structure, the Apex classes show which Code Analyzer flags matter most for security and performance, and batch jobs show the correct use of Database.Stateful. Skills aren't just automation — they're a teaching tool built from Salesforce's own best practice library.

Key Takeaways

🚀 Salesforce Skills for Claude Code — Quick Reference
  • Install: npx skills forcedotcom/sf-skills from your Salesforce DX project directory
  • Install all 60+ skills at once with the --all flag
  • Skills activate automatically based on your prompt keywords — no manual configuration
  • Guardrails enforced automatically: with sharing on all classes, no SOQL in loops, required metadata files generated
  • Code Analyzer and Apex tests run automatically before Skills report success
  • Test coverage target: 75%+ by default, specify higher in your prompt
  • Skills are open source — fork and customise for your team's naming conventions
  • Skills are NOT an npm package — npx skills installs from GitHub
  • Always review generated code and test in sandbox before production deploy

If you've been using Claude Code or GitHub Copilot for Salesforce development and spending half your time fixing governor limit violations and writing test classes manually, Salesforce Skills are worth trying this week. One prompt. Production-ready code. Zero Code Analyzer violations.

📄 Sources: Build Production-Ready Apps in Claude Code with Salesforce Skills — Salesforce Developer Blog  |  forcedotcom/sf-skills — Official GitHub Repository  |  Agent Skills Specification — agentskills.io

Watch Complete Video on YouTube

#ClaudeCode #Agentforce #SalesforceDeveloper

Post a Comment

0 Comments