sf-build-fix
Skill15 starsChanged 7 months agoMITView on GitHub
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.
In this repository58 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- asideSkill
- checkpointSkill
- configure-sccSkill
- continuous-agent-loopSkill
- mcp-server-patternsSkill
- model-routeSkill
- prompt-optimizerSkill
- refactor-cleanSkill
- resume-sessionSkill
- save-sessionSkill
- search-firstSkill
- security-scanSkill
- sessionsSkill
- sf-2gp-security-reviewSkill
- sf-agentforce-developmentSkill
- sf-agentforce-mcp-actionsSkill
- sf-apex-async-patternsSkill
- sf-apex-best-practicesSkill
- sf-apex-constraintsSkill
- sf-apex-cursorSkill
- sf-apex-enterprise-patternsSkill
- sf-apex-testingSkill
- sf-api-designSkill
- sf-approval-processesSkill
- sf-aura-developmentSkill
- sf-cli-referenceSkill
- sf-data-modelingSkill
- sf-debuggingSkill
- sf-deployment-constraintsSkill
- sf-deploymentSkill
- sf-devops-ci-cdSkill
- sf-docs-lookupSkill
- sf-e2e-testingSkill
- sf-experience-cloudSkill
- sf-flow-developmentSkill
- sf-governor-limitsSkill
- sf-harness-auditSkill
- sf-helpSkill
- sf-integrationSkill
- sf-lwc-constraintsSkill
- sf-lwc-developmentSkill
- sf-lwc-testingSkill
- sf-metadata-managementSkill
- sf-platform-events-cdcSkill
- sf-quickstartSkill
- sf-security-constraintsSkill
- sf-securitySkill
- sf-soql-constraintsSkill
- sf-soql-optimizationSkill
- sf-tdd-workflowSkill
- sf-testing-constraintsSkill
- sf-trigger-constraintsSkill
- sf-trigger-frameworksSkill
- sf-visualforce-developmentSkill
- strategic-compactSkill
- update-docsSkill
- update-platform-docsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 12 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
When Apex compilation errors are blocking a deployment
- Distinctive: line 17
When metadata conflicts prevent deploying to a target org
- Distinctive: line 18
When test failures need to be resolved before deployment validation passes
- Distinctive: line 19
When dependency resolution is needed (missing objects, fields, or class references)
- Very specific: line 20
When you receive build errors from sf project deploy and need systematic resolution
- Distinctive: line 26
Run a dry-run deployment or check compiler output:
- Distinctive: line 32
If the user pasted error output directly, use that instead.
- Distinctive: line 52
Read the file at the reported line number
- Very specific: line 55
Verify it compiles: sf project deploy validate --metadata "ApexClass:<ClassName>" --target-org <org>
- Distinctive: line 82
When deploying multiple metadata types, follow this order:
- Very specific: line 95
When sf project deploy reports conflicts:
- Distinctive: line 99
Merge: Keep production changes, layer your modifications on top
- Distinctive: line 105
Do NOT refactor while fixing builds
- Distinctive: line 106
Do NOT change architecture
- Distinctive: line 107
If a fix introduces new errors, revert and try a different approach
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
Build Fix — Salesforce Build and Deployment Error Resolution
Fix build and deployment errors incrementally. Parse error output, classify issues, fix one at a time, re-validate.
Reference: @../_reference/DEPLOYMENT_CHECKLIST.md
When to Use
- When Apex compilation errors are blocking a deployment
- When metadata conflicts prevent deploying to a target org
- When test failures need to be resolved before deployment validation passes
- When dependency resolution is needed (missing objects, fields, or class references)
- When you receive build errors from
sf project deployand need systematic resolution
Workflow
Step 1 — Capture Errors
Run a dry-run deployment or check compiler output:
sf project deploy validate --target-org <alias> --json 2>&1If the user pasted error output directly, use that instead.
Step 2 — Parse and Classify
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 |
Step 3 — Fix One at a Time
For each error:
- Read the file at the reported line number
- Understand the context (class, method, trigger)
- Apply the minimal fix
- Verify it compiles:
sf project deploy validate --metadata "ApexClass:<ClassName>" --target-org <org>
Step 4 — Re-validate
After all fixes:
sf project deploy validate --target-org <alias> --test-level RunLocalTestsCommon Apex Compilation Errors
| 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 |
Dependency Resolution Order
When deploying multiple metadata types, follow this order:
- Custom Objects and Fields
- Record Types and Page Layouts
- Apex Classes (utilities and base classes first)
- Apex Triggers
- Lightning Web Components
- Flows (Process Builder is deprecated since Winter '23 -- migrate to Flows)
- Permission Sets and Profiles
- Apex Test Classes (verify at end)
Metadata Conflict Resolution
When sf project deploy reports conflicts:
- Retrieve current org state:
sf project retrieve start --metadata <type>:<name> - Compare:
diff force-app/main/default/<path> <retrieved-path> - Merge: Keep production changes, layer your modifications on top
- Do not force-overwrite production metadata without understanding the diff
Rules
- Fix one error at a time -- cascade fixes often resolve multiple issues
- Do NOT refactor while fixing builds
- Do NOT change architecture
- If a fix introduces new errors, revert and try a different approach
Examples
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 UATRelated
- Constraints:
sf-deployment-constraints-- deployment safety rules and validation gates
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
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.

