No slash command · from salesforce-claude-code
Deploys Apex, LWC, and metadata changes to Salesforce orgs using SF CLI, Metadata API, and package deployment. Covers validation-then-quick-deploy, rollback planning, and production best practices.
Ships in salesforce-claude-code. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Reference: @../_reference/DEPLOYMENT_CHECKLIST.md
| Method | Speed | Rollback | Best For | Tracking |
|---|---|---|---|---|
| Change Sets | Slow | Manual | Admin-managed, simple orgs | None |
| SF CLI (Source) | Fast | Manual | Developer workflow, CI/CD | Git |
| Metadata API | Medium | Manual | Automated scripts, complex manifests | External |
| Unlocked Package | Fast | Version | Modular orgs, ISV, internal products | Version |
| Managed Package | Slow | Version | AppExchange ISV, protected IP | Version |
# Deploy entire source directory
sf project deploy start \
--source-dir force-app \
--target-org myOrg \
--wait 30
# Deploy specific metadata types
sf project deploy start \
--metadata ApexClass \
--target-org myOrg
# Deploy specific components
sf project deploy start \
--metadata "ApexClass:AccountService,ApexClass:AccountServiceTest" \
--target-org myOrg
# Deploy using package.xml manifest
sf project deploy start \
--manifest manifest/package.xml \
--target-org myOrg \
--wait 60
# Deploy with test execution
sf project deploy start \
--source-dir force-app \
--test-level RunLocalTests \
--target-org myOrg \
--wait 60
# Deploy specific tests
sf project deploy start \
--source-dir force-app \
--test-level RunSpecifiedTests \
--tests AccountServiceTest,OpportunityServiceTest \
--target-org myOrg
| Flag | Description |
|---|---|
--source-dir | Local source directory to deploy |
--manifest | package.xml manifest file path |
--metadata | Specific metadata types or components |
--test-level | Test level: NoTestRun/RunSpecifiedTests/RunLocalTests/RunAllTestsInOrg |
--tests | Comma-separated test class names (with RunSpecifiedTests) |
--wait | Minutes to wait for async deploy (default: 33) |
--ignore-errors | Ignore deploy errors (use with caution) |
--ignore-conflicts | Ignore source tracking conflicts |
--async | Run deploy asynchronously, return job ID |
--verbose | Show detailed output |
Note: There is no
--dry-runondeploy start. Usesf project deploy validateinstead.
sf project deploy start --test-level NoTestRun --source-dir force-app --target-org sandbox
Use for sandbox deployments of non-Apex metadata. Allowed for production only when the deployment contains no Apex code.
sf project deploy start \
--test-level RunSpecifiedTests \
--tests AccountServiceTest,ContactTriggerTest \
--source-dir force-app \
--target-org myOrg
Runs only the named test classes. Sufficient for production if coverage >= 75% for deployed classes.
sf project deploy start \
--test-level RunLocalTests \
--source-dir force-app \
--target-org myOrg
Runs all tests in the org except managed package tests. Required standard for production deployments.
sf project deploy start \
--test-level RunAllTestsInOrg \
--source-dir force-app \
--target-org myOrg
Runs every test including managed package tests. Use for major releases or full org validation.
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>AccountService</members>
<members>AccountServiceTest</members>
<name>ApexClass</name>
</types>
<types>
<members>AccountTrigger</members>
<name>ApexTrigger</name>
</types>
<types>
<members>accountCard</members>
<name>LightningComponentBundle</name>
</types>
<types>
<members>Account.Status__c</members>
<name>CustomField</name>
</types>
<version>66.0</version>
</Package>
<members>*</members>deploys ALL components of that type, including test classes. For production, prefer listing specific members when you need to exclude certain components.
Validation separates test execution from the actual deployment. Use this for production to minimise downtime.
sf project deploy validate \
--source-dir force-app \
--test-level RunLocalTests \
--target-org prod \
--wait 60
# Capture the Job ID from output
JOB_ID=0Af5e00000BnXXX
sf project deploy report --job-id $JOB_ID --target-org prod
sf project deploy resume --job-id $JOB_ID --target-org prod --wait 60
sf project deploy quick \
--job-id $JOB_ID \
--target-org prod \
--wait 10
Quick deploy window: 10 days after successful validation, but only if no Apex code modifications have been made to the org since the validation.
Deploy a destructiveChanges.xml alongside an empty package.xml.
<!-- destructiveChanges.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>OldAccountService</members>
<name>ApexClass</name>
</types>
<types>
<members>Account.LegacyField__c</members>
<name>CustomField</name>
</types>
<version>66.0</version>
</Package>
sf project deploy start \
--manifest deploy-package/package.xml \
--post-destructive-changes deploy-package/destructiveChanges.xml \
--test-level RunLocalTests \
--target-org myOrg
--pre-destructive-changes runs before deployment; --post-destructive-changes after. Use post for removing replaced components.
Salesforce does not have native one-click rollback. Plan ahead.
git revert HEAD
sf project deploy start --source-dir force-app --test-level RunLocalTests --target-org prod
Single-file rollback is only safe for isolated, dependency-free components. For coupled changes, revert the full git commit and deploy the complete set of changed files.
sf project retrieve start \
--manifest manifest/package.xml \
--target-org prod \
--output-dir backup/pre-deploy-$(date +%Y%m%d)
sf package install \
--package "04t5e000000XXXXX" \
--target-org prod \
--wait 30
| Error | Cause | Fix |
|---|---|---|
| "Test coverage of selected Apex Trigger is 0%" | Trigger has no test class | Write and include a test class |
| "Average test coverage below 75%" | Org-wide coverage insufficient | Add tests for uncovered classes |
| "Entity of type X not found" | Component missing in target org | Deploy dependency first or check name |
| "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY" | Trigger or validation rule blocking deploy | Check error details for the specific rule |
| "duplicate value found" | Unique field constraint violation | Check for existing records or duplicate picklist values |
| "Object X not available in this org" | Feature not enabled in target org | Enable the feature flag or include org setting |
sf-deployment-constraints -- deployment safety rulessf-architect -- interactive, in-depth guidanceWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jiten-singh-shahi/salesforce-claude-code --plugin salesforce-claude-code58 skills in this plugin
/asideUse when you need a quick Salesforce answer mid-task. Answer a side question about Apex, org config, or metadata without losing context, then resume work automatically./checkpointUse when saving Salesforce development progress. Create a named checkpoint via git stash before risky Apex deploys or org changes for easy recovery./configure-sccUse when setting up SCC for Salesforce Apex and LWC development. Interactive wizard to install profiles, modules, and customize the harness for your org.Other plugins' skills for the same job