skills/sf-build-fix/SKILL.md
Auto-fix Salesforce build errors — Apex compilation, metadata conflicts, dependencies, test failures. Use when build errors block deployment. Do NOT use for writing new features or refactoring.
npx skillsauth add jiten-singh-shahi/salesforce-claude-code sf-build-fixInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Fix build and deployment errors incrementally. Parse error output, classify issues, fix one at a time, re-validate.
Reference: @../_reference/DEPLOYMENT_CHECKLIST.md
sf project deploy and need systematic resolutionRun a dry-run deployment or check compiler output:
sf project deploy validate --target-org <alias> --json 2>&1
If the user pasted error output directly, use that instead.
Group errors by type and fix in this dependency order:
| Priority | Error Type | Fix Strategy |
|----------|-----------|--------------|
| 1 | Missing object/field metadata | Deploy metadata first -- objects before classes |
| 2 | Missing class/interface reference | Check spelling, verify class exists, check API version |
| 3 | Type mismatch | Cast explicitly, check null handling, verify generic types |
| 4 | Method signature changed | Update all callers, check for overloaded methods |
| 5 | Metadata conflict | Retrieve latest from org with sf project retrieve start, merge |
| 6 | Test failure | Fix test data setup, update assertions, check @TestSetup |
| 7 | Governor limit in test | Add Test.startTest()/stopTest(), reduce data volume |
For each error:
sf project deploy validate --metadata "ApexClass:<ClassName>" --target-org <org>After all fixes:
sf project deploy validate --target-org <alias> --test-level RunLocalTests
| Error Message Pattern | Root Cause | Fix |
|----------------------|------------|-----|
| Variable does not exist: X | Undeclared variable or field removed | Declare variable or check field API name |
| Method does not exist or incorrect signature | Wrong parameter types or method renamed | Check method signature in target class |
| Illegal assignment from X to Y | Type mismatch | Add explicit cast or fix generic type |
| Non-void method might not return a value | Missing return in a branch | Add return statement to all code paths |
| Compile Error: unexpected token | Syntax error | Check line above the reported line |
| System.NullPointerException (test) | Null reference in test setup | Add null checks or fix @TestSetup |
| Duplicate value found (test) | Test data collision | Use unique identifiers, avoid SeeAllData |
| FIELD_CUSTOM_VALIDATION_EXCEPTION (test) | Validation rule blocking test DML | Populate all required fields in test data |
| MIXED_DML_OPERATION (test) | Setup + non-setup DML in same transaction | Use System.runAs() in tests or @future in production |
| UNABLE_TO_LOCK_ROW (test) | Concurrent test data conflicts | Use unique records per test method |
When deploying multiple metadata types, follow this order:
When sf project deploy reports conflicts:
sf project retrieve start --metadata <type>:<name>diff force-app/main/default/<path> <retrieved-path>sf-build-fix
sf-build-fix Fix the Apex compile errors from this deployment output: <paste errors>
sf-build-fix The AccountService.cls has a type mismatch on line 47
sf-build-fix Resolve the metadata conflicts blocking our deployment to UAT
sf-deployment-constraints -- deployment safety rules and validation gatesdevelopment
Update Salesforce platform reference docs with latest release features and deprecation announcements. Use when SessionStart hook warns docs are outdated or a new Salesforce release has shipped. Do NOT use for Apex or LWC development.
development
Use when syncing documentation after Salesforce Apex code changes. Update README, API docs, and deploy metadata references to match the current org codebase.
development
Use when managing context during long Salesforce Apex development sessions. Suggests manual compaction at logical intervals to preserve deploy and org context across phases.
tools
Visualforce development — pages, controllers, extensions, ViewState, JS Remoting, LWC migration. Use when maintaining VF pages, building PDFs, or planning VF-to-LWC migration. Do NOT use for LWC, Aura, or Flow.