| name | salesforce-apex |
| description | Provides Apex development workflow including static analysis and testing steps. Use before writing Apex classes or triggers |
| allowed-tools | mcp__ide__getDiagnostics, Bash(sf project deploy *), Bash(sf apex run test *) |
Workflow
-
Read project config — Get sourceApiVersion from sfdx-project.json for all new -meta.xml files.
-
Write the Apex code
-
Check IDE diagnostics — Use mcp__ide__getDiagnostics on new files. Fix errors and warnings before proceeding.
-
Static analysis — Run sf code-analyzer on the new or changed .cls and .trigger files. Review its output and fix violations before proceeding.
-
Write tests — Create test classes following test-guidance.md.
-
Deploy code and tests Let source tracking which files to deploy
sf project deploy start
-
Run tests in org
sf apex run test --class-names <TestClassName> --result-format human --wait 10
The task is complete when tests pass in the org.