AI Code Generation for Salesforce: What I Learned from a Lost Bet and Why It Matters
I just lost a bet about AI code generation. Here's why that matters for Salesforce development.
As a Salesforce CTA, an AI startup founder, and a student in the UC Berkeley Advanced LLM Agents class, I spend my days at the intersection of what's possible and what's not-quite-possible yet. Recently, I've been wrestling with a question: Can AI generate production-quality Apex code? The answer, discovered through experimentation with Claude.ai, is nuanced and revealing.
The Win outside of Salesforce: When AI Became My Data Detective
It started with a practical challenge: thousands of messy addresses needing validation. Instead of hours building custom scripts, I fed Google's Address Validation API specs to Claude.ai along with sample data. After several iterations of vibe coding, AI helped me build Python scripts that not only validated addresses but also categorized different failure types. Work that would have taken days of data-wrangling compressed into hours. Just for fun, I also verified that AI can translate the Python code into JavaScript.
What surprised me? While AI dramatically reduced that laborious effort, it didn't reduce communication overhead. Explaining methodologies and results to stakeholders remained crucial. In fact, communication became a larger percentage of the total effort.
Strategic Insight: The real competitive advantage won't go to individual AI users, but to teams that become collectively AI-fluent—sharing AI conversations, co-creating solutions, and achieving shared understanding rapidly. These teams will dramatically outperform those treating AI merely as individual superpowers.
The Reality Check: Where I Lost a Bet (Spectacularly!)
Emboldened, I got ambitious. "If AI can write scripts in Python and JavaScript," I mused to an fflib expert friend, "It should be able to generate production-grade Apex also." He said, "See me when you can generate an ApexMocks style test".
So I went to work, generating not one but a dozen ApexMocks tests.
Then my trouble started. Despite a full day with AI assistance, only a few generated tests passed. I told my friend what happened, conceding the bet for now, and I learned something crucial: AI thrives on mainstream patterns but can stumble on specialized frameworks where training data is less abundant. This isn't just a technical curiosity—it's a competitive concern. It's a clear view of AI's current jagged frontier.
Why This Matters (Beyond My Bruised Ego)
Here's the strategic implication: Salesforce's AI readiness for advanced development scenarios depends significantly on our ecosystem's representation in broader training data. Apex is underrepresented compared to mainstream programming languages like Python and JavaScript, let alone ApexMocks.
But this creates an opportunity. The Apex Enterprise Framework, which includes ApexMocks, provides systematic ways to create modular solutions. Modular solutions are more suitable for AI to assist because they have well-defined contexts. Teams that solve AI-assisted modular Apex development will gain significant competitive advantages in enterprise Salesforce implementation. And a great place to start? Unit tests using ApexMocks—they're lower risk for enterprise adoption, build trust, and should be doable for AI to generate, given the right prompting.
The Path Forward: Building What's Missing
Rather than giving up, I'm taking a systematic approach:
I believe the future belongs to those who experiment now. Yes, some experiments fail spectacularly (hello, lost bet!). But every failure teaches us where the boundaries are—and how to push them.
The Salesforce platform is evolving rapidly toward CRM, AI, and Data convergence. Our role as technical leaders is to run ahead of that curve, experiment fearlessly, and help our ecosystem stay competitive and innovative. After all, the best time to contribute is when the technology is not perfect yet.
What's your experience with AI-assisted development on Salesforce? Have you cracked ApexMocks generation, or hit similar walls with specialized frameworks? Let's learn from each other and build a future through shared experience.
#Salesforce #AI #fflib #Innovation #LLM #PromptEngineering #AIStrategy
Senior Technology Director/Senior Salesforce Technical Architect/ Business Process Re-Engineering Lead
2moI appreciate you sharing this insightful information. Shouldn't Salesforce's AI capability be able to accomplish what you're trying to do in Claude.ai?
Reimagining CRM for the Agentic Era
2moUnit test frameworks are designed to lower cognitive load on humans. LLMs are more efficient at generating Plain-Old-Apex/Python. The role of an AI Architect moving forward needs to decide whether to: a) Let AI choose its preferred syntax, languages and libraries b) Fine-tune libraries so AI understands your team's naming conventions and syntax
🏆Salesforce Certified Architect (30x) | 🤖AI Innovator| ⛅Data Architect | Salesforce Expert | Salesforce Community Group Co-Leader | Project/Product Mgmt | Driving Business, Process & Tech Alignment for Maximum ROI
2moThanks for your insight Charlie
Technical Solutions Engineer & Enterprise Architect (Salesforce CTA) | Specializing in InsureTech, Compliance & AI-Driven CRM Strategy
2moHelpful insight, Charlie💡