Trunk-based Development Extra Quality: Salesforce
| Pitfall | Why it happens | Solution | | :--- | :--- | :--- | | | Developers are afraid to merge incomplete code. | Use Feature Toggles . Merge incomplete code hidden behind a custom setting or static resource switch, so it doesn't activate in production until ready. | | Broken Trunk | Merging bad code breaks the build for everyone. | Enforce strict CI. If the trunk breaks, fixing it becomes the team's #1 priority. Stop all other merges until main is green. | | Sandbox Sprawl | Teams using Dev Sandboxes forget to refresh them. | Use Scratch Orgs defined in project-scratch-def.json to ensure every branch starts with a fresh, clean state. | | Flaky Tests | Apex tests fail randomly, blocking merges. | Isolate and disable flaky tests immediately. They destroy confidence in the Trunk. Fix them in isolation. |
Flows are massive XML files. Merging two versions of a Flow is often impossible via Git. salesforce trunk-based development
# Create a short-lived branch git checkout -b feature/account-trigger-refactor | Pitfall | Why it happens | Solution