Bojan Josifoski < wp developer />

Mastering Salesforce CLI: The Integration Superpower Behind SampleHQ

November 17, 2025 • Bojan

Listen to this article:
0:00
0:00

When you’re building a modern SaaS platform that integrates deeply with Salesforce, there’s one tool that quietly becomes the backbone of your entire development workflow: Salesforce CLI.

Most people think of Salesforce as a complex UI, pages of setup screens, and endless permission checkboxes. But the CLI changes everything. It gives you raw access to the underlying platform – the data model, the metadata, the permissions, the user context – without the UI’s noise or delays. (Salesforce Developers)

At SampleHQ, our multi-tenant WordPress-based SaaS for packaging and label manufacturers, mastering Salesforce CLI became the difference between guessing and knowing. It’s how we validate features, debug customer issues, and guarantee that our integration works across every edition of Salesforce.

This is the guide I wish I had on day one.


What Salesforce CLI Really Gives You (In Practice)

Forget the marketing descriptions. Here’s what Salesforce CLI actually does for you during real SaaS integration work:

Spin up fresh test orgs in seconds

Scratch orgs let you test integration behavior in Enterprise, Professional, or Platform editions – without creating multiple paid accounts.

Inspect orgs with full transparency

You can check:

Run raw SOQL queries

This is huge. You don’t rely on UI screens that hide permissions – you ask Salesforce directly through the API. (Salesforce Ben)

Debug integrations instantly

You can reproduce a bug in minutes, not days, because you’re not waiting on logs or refreshing the UI.

Deploy and retrieve metadata

Connected Apps, permissions, layouts – all version-controlled and portable.

This is everything a serious integration needs.


How We Use Scratch Orgs to Reproduce Any Environment

Scratch orgs were a game-changer for SampleHQ.

Instead of guessing what a customer’s Salesforce setup looks like, we create environments that match exact editions and feature sets:

Enterprise Edition w/ Sales Cloud

To test full Opportunity workflows, app objects, and advanced permissions.

Professional Edition

To simulate clients with API restrictions and limited automation.

Platform Edition

To validate fallback behavior for customers with no Opportunity object.

API-Only Environments

To test the minimal permissions needed for SampleHQ CRM Mode (Light Mode).

With one command, we can test against all of them:

sf org create scratch -f config/scratch-enterprise.json
sf org create scratch -f config/scratch-platform.json
sf org create scratch -f config/scratch-pro.json

This eliminates the classic SaaS problem:

“It works in our dev org – why does it fail in the customer’s org?”

Because now we can reproduce any customer environment on demand.


Deep Debugging with SOQL and Raw API Calls

Here’s where Salesforce CLI becomes lethal.

When you query objects directly, you bypass every UI abstraction and get the truth.

Example SOQL checks we run constantly:

sf data query -q "SELECT Id FROM Opportunity LIMIT 1"
sf data query -q "SELECT Id, Name FROM Account LIMIT 1"
sf data query -q "SELECT Profile.Name FROM User WHERE Id='005…'"

This answers questions instantly:

Real debugging example from SampleHQ

We had a case where:

INVALID_TYPE: sObject type 'Opportunity' is not supported.

The CLI confirmed the problem:

Within two minutes, the root cause was clear.

This is why we don’t debug integrations through the UI anymore – the CLI reveals what the API actually sees.


Debugging OAuth Flow and Connected Apps with CLI

OAuth issues are one of the most painful parts of Salesforce development. The CLI removes 90% of that pain.

With it, we can:

Links to install and reference:

Introducing the MCP Server into our workflow meant we could even extend our tooling to LLM-driven workflows and org automation – a forward-looking move for SampleHQ’s roadmap.


The Exact Workflow We Use at SampleHQ

Here is the full integration workflow we follow for every new feature:

  1. Create a new scratch org (platform, enterprise, pro, etc.)
  2. Authenticate via OAuth as the intended user
  3. Retrieve Connected App metadata from dev
  4. Deploy Connected App into the new org
  5. Verify object availability (Opportunity, Account, custom objects)
  6. Query permissions through SOQL
  7. Run our Visualforce picker installer
  8. Capture raw error messages
  9. Validate instance + org ID with CLI
  10. Patch the integration
  11. Repeat the cycle across other editions

This is how we guarantee SampleHQ works across:

Without this workflow, we’d be blind.


Lessons Learned You Won’t Find in Salesforce Docs

1. Never trust the UI.

It hides permissions that the API relies on.

2. Always check the OAuth user.

Salesforce often logs in the wrong one.

3. Always verify object availability through SOQL.

Objects can appear in the UI even when API access is blocked.

4. Scratch orgs must match the customer’s edition exactly.

Enterprise vs Platform isn’t a detail – it’s critical.

5. Always deploy the Connected App into every scratch org.

Otherwise behavior becomes inconsistent.

6. The CLI and MCP reveal problems nothing else will.

Especially Tooling API errors, sObject availability, permission mismatches.


Why This Matters for SampleHQ Customers

Mastering Salesforce CLI (and incorporating the MCP Server) gives SampleHQ a real advantage:


Conclusion

If you’re building a SaaS that needs deep Salesforce integration, Salesforce CLI isn’t optional – it’s the foundation. It gives you:

And by integrating the MCP Server into our stack, we’re future-proofing for advanced workflows, automation, and LLM-driven extensions.

This is exactly why we’ve embedded these tools deeply into the SampleHQ development pipeline – and why our CRM workflows behave consistently across every Salesforce customer environment.

This is how you build integrations that don’t break. Ever.

If you’re building a SaaS that needs deep Salesforce integration – or want your team to work with the same tooling and discipline we use at SampleHQ – reach out. Happy to share more.

About the Author

About the Author

I’m Bojan Josifoski - I’m a WordPress systems engineer who developed and maintained a proprietary WordPress-based framework used by U.S. financial institutions between 2016 and 2025.

← Back to Blog