The Best Code I Ever Wrote Was the Code I Stopped Rewriting. Here Are the 3 Repos I Built Instead.
After 15 years of enterprise CRM implementations, I packaged the patterns that survived production into three free repos. AI agents that understand governor limits. A migration toolkit that catches broken phone numbers before they hit your org. And a cookbook of automation recipes with actual gotchas sections.
Three MIT/Apache-licensed repos: (1) SAAF, a Python framework for building AI agents that work natively with Salesforce, including an MCP Server for Claude Desktop; (2) CRM Data Migration Toolkit, an object-mapping and data-cleansing pipeline for CRM migrations; (3) Salesforce Process Automation Recipes, a cookbook of battle-tested Apex, Flow, and integration patterns. All free. All on GitHub.
In This Article
Every Salesforce implementation has a moment where the team realizes they’re solving a problem that has been solved a hundred times before. The data migration goes sideways because someone forgot to normalize phone numbers. The trigger logic becomes a tangled mess across six files. The AI prototype works great in a demo but blows through governor limits the second it touches real data.
I’ve done this long enough that the pattern is obvious. Three categories of work eat 40-60% of the engineering time on every project, and they’re rarely unique to the org. They’re common problems with common solutions that get rebuilt from scratch each time because there’s no good open source option in the Salesforce world.
Salesforce just open-sourced Agent Script and shipped Agentforce 2.0 with MCP support and multi-model tooling. The direction is clear: AI agents are becoming the primary way enterprises interact with CRM data. But there’s a gap between Salesforce’s native tooling and what independent teams need to build their own agents that work alongside (or instead of) Agentforce.
So I packaged up the patterns that actually worked in production and put them on GitHub. Three repos. All free.
If you’ve tried building AI agents that read and write Salesforce data, you know the gap. LangChain and CrewAI are powerful general-purpose tools, but they have no concept of governor limits, field-level security, or Salesforce object relationships. You end up writing hundreds of lines of glue code to make a simple agent that can score a lead.
SAAF is a Python framework where agents are Salesforce-native from the ground up. They know about SObjects, SOQL, Flows, Platform Events, and the Bulk API. They track API call usage automatically. They enforce FLS. And they log every action to a custom SAAF_Audit_Log__c object so you have a full trail of what the agent did and why.
Works with Claude, GPT, Gemini, and local models via Ollama. Swap providers with one line.
Dry-run mode, approval gates for destructive operations, FLS enforcement, and governor limit tracking.
8-tool MCP server that lets Claude Desktop, Cursor, or any MCP client query your Salesforce org directly.
The MCP Server Changes the Workflow
The piece I’m most interested in is the MCP Server. With Salesforce now supporting MCP natively in Agentforce, the protocol is becoming the standard for agent-to-tool communication. SAAF’s MCP Server works the other direction: it exposes your Salesforce org as a set of tools for any MCP-compatible AI client.
In practice, this means you can open Claude Desktop, type “show me all opportunities closing this month over $50K with no activity in the last 14 days,” and Claude writes the SOQL, runs it against your org, and gives you the results. No code, no middleware, no integration platform.
Pre-Built Agents
The framework ships with three production-ready agents you can use immediately. Each one handles the common patterns (batch processing, error handling, audit logging) and lets you customize the business logic through configuration.
Combines configurable rule scoring (company size, industry, revenue) with LLM qualitative analysis of title, description, and engagement signals. Auto-categorizes leads as Hot, Warm, Nurture, or Disqualified.
Analyzes case subject and description to determine product area, urgency, and sentiment. Routes to the best matching queue. Detects escalation keywords and auto-elevates priority.
Predicts close probability by analyzing stage velocity, activity recency, related Tasks/Events, and deal characteristics. Flags at-risk deals with specific risk factors.
Python 3.10+ | MIT License | 21 files | MCP Server included
Here’s the thing about data migrations: they’re not technically hard. They’re operationally brutal. The source system stores phone numbers in 15 different formats. State names are sometimes abbreviations, sometimes full names, sometimes misspelled. The picklist values between HubSpot and Salesforce don’t match. And there are always duplicate records.
This toolkit handles the unglamorous work. You define your field mappings, attach transforms, set up validators, and run the whole thing in dry-run mode to catch problems before a single record touches Salesforce.
The Validation Layer is the Point
The transforms are nice. The templates save time. But the real value is the validation framework. It runs every record through your rules before anything hits Salesforce, and gives you a clear report of exactly what would fail and why.
PYTHONfrom crm_migrate.validators import ( RequiredFieldValidator, EmailFormatValidator, FieldLengthValidator, DuplicateCheckValidator, ) validators = [ RequiredFieldValidator(fields=["Name", "Email"]), EmailFormatValidator(field="Email"), FieldLengthValidator(sobject="Account"), DuplicateCheckValidator(match_fields=["Name", "Website"]), ] # Catches 156 validation errors BEFORE you load
Every migration runs in dry-run mode by default. You see exactly how many records would be created, how many fail validation, and how many duplicates were found. Then you fix the mapping, run it again, and only commit when the numbers look right.
Python 3.10+ | Apache 2.0 License | 15 files | CSV + API sources
This one is less of a tool and more of a reference library. It’s a collection of automation patterns I’ve used across different orgs, documented with the actual business scenario, the code, and the production gotchas that only show up at scale.
The Salesforce community has tons of “how to build a Flow” tutorials. What it lacks is documented patterns for the hard stuff: how to do round-robin lead assignment with timezone awareness, how to chain Queueable jobs to process 500K records, how to build a circuit breaker around an unreliable external API.
The repo includes 20+ recipes across four categories: Flow Recipes (6), Apex Patterns (6), Integration Blueprints (4), and AI-Enhanced Workflows (4). Each recipe includes a README with business scenario, architecture diagram, deployable code, and a gotchas section.
Apex + Flows + LWC | MIT License | 22 files | Community contributions welcome
These tools solve real problems, but they’re not finished products. Here’s what you should know before depending on them.
Honest Limitations
None of these are showstoppers, but I’d rather be upfront about them than have someone find out the hard way. Open source means you can see everything, fix anything, and contribute back.
pip install salesforce-ai-agent-framework), add your Salesforce credentials to the Claude Desktop config file, and restart Claude. The README has the exact JSON block to paste.Set<Id> that tracks which records have been processed in the current transaction. If you skip it, workflow field updates and process builders will re-fire your trigger and create infinite loops. The example AccountTriggerHandler shows the correct pattern.- Sandip Patel /
- May 10, 2026 /
-
Views: 4