Writing
111 posts on four lines. The Salesforce line is where I started. The other three are what I work on now: GTM systems, data systems, and LLMs and agents.
GTM systems
35 postsCRM platforms, quoting, territories, and the revenue systems around them, plus the integrations that keep them in step.
-
One create service for every new CRM record, agents included
Every new account and contact, from reps, imports, forms, integrations or agents, goes through one create service that normalizes, scores matches and stamps who made it.
-
Finding the CRM integration whose token dies between runs
Keep every CRM integration in a git registry and check it nightly against token history, so a job whose token dies before its next run gets flagged weeks early.
-
Moving business logic out of the CRM, one capability at a time
The strangler pattern for a heavily customized CRM: a thin router, a flag per capability, shadow runs that compare answers, and results written back.
-
Catching usage contraction before the renewal, and what the agent may do alone
Compute usage contraction in the warehouse as dollars at risk, sync three fields to the CRM account, and write down what a renewal agent may do without a named approver.
-
Draining the dead-letter queue: a class, an owner and an age limit for every parked record
A dead-letter queue fills because nobody owns its entries. Classify each failure when it is parked, keep it in a table, and alert on the age of the oldest one.
-
Hold the credits before the agent runs, settle once after
Agent work is priced in credits, but a run's cost is unknown until it ends. A hold before the run and one settlement after it keep the balance honest.
-
Quote-to-cash at a high level: where the time goes and how to get it back
A quote takes milliseconds to compute and days to produce. Where catalog, pricing, approvals, contracts, orders, and billing lose time, and how to win it back.
-
Designing a territory assignment engine
How I'd design the engine that assigns sales accounts to territories: rules as data, deterministic matching, stored explanations, dry runs, and careful publishing.
-
Keeping CRM systems in sync with events instead of batch jobs
Most sync bugs are ownership arguments nobody had out loud. Settle who owns each field, then move changes through an ordered log.
-
New connected apps are off by default: moving integrations to external client apps without an outage
Existing connected apps keep working after Spring '26. The outage risk is the cutover to external client apps, so run both side by side and move one caller at a time.
-
Converting CRM automations without changing the order they run in
A converted automation usually keeps its logic. Run order, save phase and run-as user are what move, so map every write, replay real saves in two sandboxes and gate on the diff.
-
Five side effects and a table that remembers them
A build log for resumable order activation on plain Postgres: a steps table, a lease, repeat-safe calls, and the three needs that justify a real workflow engine.
-
When three systems disagree, the winner should be a row in a table
A per-field survivorship rules table for golden records, with SQL that picks each winning value and records the source row it came from.
-
A stolen token never sees the MFA prompt: a checklist for apps that hold CRM access
A post-incident checklist for third-party apps holding Salesforce OAuth tokens: inventory them, name an owner, cut scopes, limit IPs and block anything unreviewed.
-
A fresh UUID per retry is not an idempotency key
Build idempotency keys from the business fact, store them with the outcome in Postgres, carry them into the CRM and billing, and expire them when the order closes.
-
One CRM agent or several: split on permissions, not on topics
Topic-per-agent CRM designs mostly add hand-offs that drop context. A worksheet for when a split is earned, and a schema for the state that has to cross it.
-
Fourteen price rules, five declared steps, and four quotes that disagreed
Tracing one quote line through Salesforce CPQ price rules and through a declared pricing procedure shows where the old price was really decided: in the firing order.
-
Run every CRM agent test as three different users
A CRM agent can give the right answer to the wrong person. Run each test scenario as the owner, a colleague without access and a customer, with canary records planted.
-
Your outbound webhooks skipped the review your API got
A twelve-point review for the webhooks you send: thin signed notifications, an API fetch-back under a scoped token, per-endpoint secrets and a destination check.
-
Count what your quoting engine still uses before you plan the move
Salesforce CPQ is closed to new customers but still runs, so an inventory of rules, scripts and templates should decide when you move to Revenue Cloud Advanced.
-
A CRM agent should get extend_trial, not update record
An agent with a generic update tool has to re-derive your business rules on every call. A short catalog of intent-level actions carries the rules for it.
-
The inbound agent's real output is the qualification record
A design for an inbound lead agent where the model extracts, plain rules score and route, and the rep gets a card of sourced facts with the lead.
-
Your product code shouldn't know what the Team plan is
One grants table between billing and the product, so pricing changes, trials and sales concessions become rows and the feature gate never reads a plan name.
-
Answer the webhook first, do the work from a table
A webhook endpoint that only verifies, stores and answers 200, with a Postgres inbox table that makes duplicates harmless and out-of-order events visible.
-
Agentforce is five parts, and your flows are one of them
An agent platform inside the CRM comes down to a classifier, scoped instructions, actions, grounding data and guardrails. Most requests still belong in a plain flow.
-
Onboarding takes three weeks. Run it as one durable workflow
Customer onboarding runs for weeks across CRM, billing and provisioning. A durable workflow keeps position, timers and retries in one place, so finding a stuck one is a query.
-
MRR from subscription events: a SQL ledger that survives upgrades and proration
Building an append-only MRR ledger in Postgres: one row per subscription change, a signed delta from LAG, and movement types that sum to the total.
-
Six integrations, one admin password: OAuth for CRM systems with nobody at the keyboard
Choosing between client credentials and JWT bearer for server-to-server Salesforce integrations, then cutting the run-as user down to the objects it touches.
-
Count the connections before you buy middleware
Count connections, shared mappings and owning teams before buying an integration platform. A connection matrix and one table choose between direct calls, a hub and an event bus.
-
A prompt template should only merge fields someone has classified
Pattern masking finds emails and card numbers, not a diagnosis note. Decide per field, store the decision as classification metadata, and block templates on unclassified fields.
-
Size a Data Cloud project by the trip back to the CRM
Data Cloud is a second data store beside the org, and it pays off only when unified data returns to a CRM record, a flow or a segment, so plan ingest, unify and activate separately.
-
Four CRM event anti-patterns you can catch before a subscriber exists
A command named as an event, a payload too thin or too fat, no stored replay position and handlers that assume order, each with a test to run on the event definition.
-
Warehouse data in the CRM: copy what it acts on, virtualize what people read
Warehouse fields that feed a CRM report or rule have to be copied in, while fields people only read can stay in the warehouse behind an external object.
-
Usage billing where a late event is just another row
A usage billing design in Postgres where every stage only appends rows, so usage that shows up after its invoice becomes an adjustment line on the next one.
-
Every integration gets a line in the CRM's API call budget
Rows per day and required freshness should choose each integration's Salesforce API. A written call budget shows which syncs should batch and which should stop polling.
Data systems
34 postsPipelines, lakehouses, streaming, data contracts, and the definitions that analytics and agents depend on.
-
Designing a contract data service: exactly-once ingestion and sub-50ms reads
A systems design write-up of a contract data service: workflow-engine ingestion, Redis locks, MySQL reads under 50 ms, batch mode, and AI-extracted facts.
-
Agents ask the warehouse the same questions all day, in different words
Agent queries hide under one service account and miss the result cache. Tag them, fingerprint the history, promote the shapes that repeat, and budget the rest.
-
Data contracts between teams, and the CI rules that make them stick
A YAML contract in the producer repo, three CI rules, a registry, and a slow lane for breaking changes, so upstream edits stop breaking downstream data.
-
From the app database to the warehouse in minutes
Streaming changes from an application database into a lakehouse table: read the log, a Kafka topic per table, upsert by key, compact, and count every night.
-
Batch data pipelines that survive a bad night
The night everything works takes care of itself. Scheduled jobs built for the other night, when a broken source should end in a clean rerun.
-
In DuckLake the catalog database is the lake, so run it like one
Operating notes for DuckLake 1.0: the Postgres catalog holds rows the bucket never sees, so deleted files have to outlive the oldest backup you'd restore.
-
Write the exit number before you move in: a Postgres data platform for a company under fifty
A second Postgres can be the whole data platform for a small company, as long as every workload has a written limit, a weekly measurement and a named place to go.
-
Before a second engine writes to your lakehouse table
An open table format lets several engines read the same files. It doesn't decide who commits or who sees which rows, so give each table one writer and define its policies once.
-
The pipeline history your CRM doesn't keep
A CRM stores the pipeline as it is now, but forecast calls ask what changed. A daily snapshot and day-over-day change facts in the warehouse give the forecast a memory.
-
A data agent shouldn't get to guess what revenue means
A data agent picks a meaning and sounds sure either way. Make it look up every business term in a small, owned registry before it writes SQL.
-
Cheap to write, expensive to keep: the data models nobody reads
A decision brief to merge, a reconcile test to publish, and a usage ledger that retires dbt models nobody reads, judged against each model's own read cadence.
-
A Postgres jobs table is a fine queue until one of three numbers moves
An invented load test of a skip-locked jobs table: fine at 300 jobs a second, slow at 4,000 for a reason unrelated to the workers, and three numbers to watch.
-
Iceberg v3 swaps the delete-file pile for one vector per data file
Iceberg format version 3 replaces position delete files with one deletion vector per data file and gives every row an id, which changes what upsert-heavy tables cost to read.
-
Where a metric definition should live, and who gets to change it
The BI tool, the transformation layer and the warehouse can all hold a metric definition. They differ in who can edit it and who has to read it.
-
An agent will run any query its connection allows
A failure analysis of an analytics agent steered by a product review, and the Postgres role, row-level policies, column grants and timeout that contain it.
-
DuckLake keeps the lake's catalog in Postgres, so a commit is one transaction
An early look at DuckLake: table metadata lives in SQL tables, small commits get cheap, and the metadata database becomes the thing you cannot lose.
-
One connection string, two copies of your data
Columnar engines inside Postgres make one database true at the connection string. The fast path still reads a copy, so staleness and load still need an owner.
-
The topic has an owner. Who owns the table it turned into?
Landing a Kafka topic as an Iceberg table is one setting now, and it skips the commit interval, compaction and schema-change decisions that someone has to own.
-
What a model needs from your schema to write correct SQL
Schema cards for text-to-SQL: column descriptions, sample values and declared join paths, and an ablation that shows which one earns its place on your own questions.
-
Size the query, not the dataset, before you rent a cluster
A worksheet for deciding whether analytics fits one machine: bytes scanned after pruning, peak operator memory, concurrency and refresh window, with SQL to measure them.
-
Put the tenant key on every table before you need a second shard
Sharding can wait, but a tenant_id column in every table and every primary key can't. A Postgres migration checklist with the SQL for each step.
-
A managed table service will compact a badly partitioned table forever
Managed Iceberg tables take compaction, snapshot expiry and file cleanup off your team. Partitioning, sort order, retention and write access stay with you.
-
Two SQL checks for loads that finish green and wrong
A load that succeeds with half the rows or yesterday's data costs more than one that crashes. Two checks per table, in plain SQL, catch most of them.
-
Promote a JSON key to a column the day a query depends on it
Keep the raw payload and type a few keys. A usage rule decides which keys become columns, and a safe cast with a reject count catches bad values on the way in.
-
Your warehouse shouldn't read another team's tables
An outbox table written in the same transaction as the business change gives the data team a versioned event and leaves the service free to refactor its schema.
-
Bootstrapping CDC: open the slot first, copy second
CDC pipelines lose and resurrect rows in the hours between the initial copy and the log taking over. A runbook and a MERGE that make overlap harmless and a gap impossible.
-
UUIDv4, UUIDv7 or bigint: a primary key the warehouse can live with
A primary key is copied into every change event, fact table and join. bigint, UUIDv4 and UUIDv7 compared on index locality, compressed size, merge cost and what each leaks.
-
What a REST catalog decides that the table format doesn't
A lakehouse catalog picks the current metadata file, hands out storage keys and can refuse a commit, so judge it on those jobs and on which engines can use each.
-
Queue, log or table: four questions for the hand-off between pipeline stages
What sits between two pipeline stages decides who can re-read old work, whether order holds, how failures retry and who sees stuck items. For most internal jobs, a table wins.
-
Build log: testing SQL models on a laptop, forty rows at a time
A build log for running warehouse SQL models on small Parquet fixtures in an in-process engine, plus the four dialect differences that still call for a nightly warehouse run.
-
Batch, micro-batch or streaming: let a latency budget pick
Write down how stale each consumer's answer can be, split that budget across capture, transport, transform and serve, and the pipeline mode becomes mostly arithmetic.
-
Iceberg gives you snapshots, then hands you the housekeeping
An Iceberg table needs compaction, snapshot expiry and orphan-file cleanup on a schedule. A runbook with the Spark procedure calls and a small-file health query.
-
Keep analytics on Postgres until three of these five numbers trip
A read replica and a few materialized views carry analytics on the operational Postgres a long way. Five measurements with thresholds say when to split off a warehouse.
-
Don't drop the old column until the warehouse stops reading it
Expand and contract keeps the application up, but the change stream and the warehouse read the old schema too, so the drop waits for a quiet week in the query log.
LLMs and agents
35 postsPutting models to work on real systems: retrieval, tools, evals, cost, and the guardrails around agents.
-
MCP servers for enterprise systems: the hard parts sit around the protocol
Architecture notes on MCP servers that connect LLM agents to enterprise systems: tool shape, identity, safe writes, schemas, and evals.
-
Using an LLM to clean CRM data: a pipeline pattern that holds up
An enrichment pipeline for fixing CRM account records with an LLM: structured extraction, per-field confidence, validation, review, and idempotent writes.
-
Keeping LLM costs predictable as usage grows
The LLM bill that gets a meeting arrives months after launch. Pricing every call in one place, before the provider sees it, keeps that bill from being a surprise.
-
Finding out your LLM feature got worse before your users do
A golden set of real inputs, graders from cheap to slow, and a CI gate that can say no: catching an LLM feature getting worse before users do.
-
When RAG gives a wrong answer, check what it retrieved first
Wrong RAG answers usually start in the search step. A starting design with hybrid search, reranking, citations and a handoff, plus retrieval tests you can copy.
-
The architecture of a customer-support AI agent
A public support agent should answer when it has grounds to and hand the conversation to a person when it doesn't. What that takes.
-
Split the task before you run coding agents in parallel
Before running coding agents side by side, give every file one owner and commit the shared interfaces first. A path check in CI enforces the split, and a baseline prices it.
-
Putting an LLM inside the CRM, where the work already happens
An LLM feature in its own tab goes unused. Put it on the record the rep already has open, then deal with the permission and review questions that come with that.
-
The agent thought it was dev. So did the person who approved it.
An invented incident where an agent resets a production database, taken apart link by link, and a command gate that only runs destructive verbs on databases marked disposable.
-
Shrinking the blast radius of a coding agent
If a coding agent's session leaked tonight, what could someone do with it, and for how long? Five controls that shrink both answers, and what each costs in friction.
-
A small model proposes the tool call, and four guards decide if it runs
A returns desk on an 8B open-weight model, built one guard at a time: a per-state tool shortlist, constrained arguments, a validator with one repair turn, and a measured escalation rate.
-
Fix your coding agent's harness before you switch models
Before paying for a bigger model, test the harness around your coding agent on your own merged PRs, one change at a time.
-
A twelve-step procedure doesn't belong in your instructions file
Give a rarely used procedure its own folder: a one-line description always in context, with the steps and scripts read only when the task matches.
-
Every tool call should carry the name of the person who asked
A tool server on one service account makes every user the most privileged user. A token flow that puts the real person on each call, with the claims at every hop.
-
Delete a section of your agent instructions and see who notices
An ablation test for agent instructions files: remove one section at a time over a fixed task set, keep what changes outcomes, and move or delete the rest.
-
Most retrieval complaints are ingestion defects
RAG ingestion at a few million documents, in the order I'd build it: a manifest row per document, a quarantine for bad parses, duplicate groups and a daily report.
-
The context window is a budget, so write the budget down
Give every kind of content in the context window a token cap, a position and an eviction rule before the first long session, with an assembler that logs what it drops.
-
Your repository is the slowest part of your coding agent
A readiness checklist for repositories that coding agents work in: one command to check a change, an answer in under two minutes, and tasks one test file can judge.
-
Your tool server's descriptions are someone else's prompt
Tool descriptions are prompt text a third party can change after you approve them. A threat table for three tool server failures, plus a script that pins every definition.
-
The model can't tell whether your tool sits behind a protocol
The model emits the same tool call either way. A tool protocol changes who writes the tool and who finds it, which only pays off when clients you don't control need it.
-
Where a reasoning model earns its latency
A reasoning model belongs on the one pipeline stage where errors are expensive and the input is small. A stage worksheet and a three-way comparison show the split.
-
A right answer by the wrong path still fails
A YAML trajectory spec and a 61-line Python checker that grade an agent's recorded tool calls with cheap rules before any judge model gets involved.
-
Chain, route, fan out, check: pick the pattern by where the uncertainty is
Most agent projects are a fixed sequence with one uncertain step. Where that uncertainty sits tells you whether to route, fan out, check, or let a loop pick its own steps.
-
Embeddings are derived data, so give them a refresh path
A vector goes stale when its source text or its model changes. Store both beside it, let edits queue the re-embed, and watch the lag like any derived table.
-
A graph index pays for itself on two kinds of question
Chunk retrieval handles lookups. A graph index is for multi-hop and whole-corpus questions, and it costs thousands to build, so sort your real questions before paying.
-
Indirect prompt injection needs three things. Take one away.
An assistant leaks when one request holds private data, attacker-written text and a way out. A worksheet for finding all three in each feature and cutting one.
-
A strict schema also decides the order the model writes in
Strict JSON schemas end unparseable replies, but key order shapes the answer, so put evidence and reasoning before the verdict and check meaning after parsing.
-
Ten steps at 95 percent is a 60 percent agent
Per-step accuracy multiplies, so a long agent run fails more often than any single step suggests. The fixes are structural: fewer model steps, checks, saved state, approval.
-
Nine labels don't need a frontier model
A build log for email triage: lock a 3.8B model to a fixed label set, pick a confidence threshold from labelled data, and escalate only the uncertain messages.
-
Keep the SDK and write the agent loop yourself
An agent's loop is about a hundred lines and it's the code you'll debug most, so write it yourself and keep libraries at the edges, for model clients and tracing.
-
A wrong tool call is usually a schema bug
Most wrong tool calls trace back to the tool definition, so split broad tools, constrain the arguments, validate before executing and return errors the model can fix.
-
Fine-tune or retrieve: first find out which kind of wrong you have
Retrieval changes what a model knows on one call and fine-tuning changes how it behaves on every call, so sort a hundred failures by which gap they show, then price each fix.
-
Chunk documents where the author already split them
Fixed-size chunks cut tables in half and strip headings from the text they govern. Splitting on structure fixes that, and one table of hit rates on your own questions proves it.
-
Design text-to-SQL around the query it gets wrong
Text-to-SQL will sometimes write the wrong query, so the design work is limiting what that query can do and putting the SQL where a reviewer can see it.
-
Below a few million chunks, keep your vectors in Postgres
Under a few million chunks, vector search fits in the Postgres you already run, and one table of recall against latency at three HNSW settings shows the headroom.
Salesforce platform
Seven postsApex, Visualforce, and SSO posts from 2015 and 2016. Kept for the people who still find them through search. Some details are dated.
-
Salesforce SSO Implementation
A walkthrough of federated SAML single sign-on for Salesforce: scope, as-is and to-be process, SSO settings, user Federation ID and best practices.
-
Analysis of Metadata AppExchange products
Compares three free AppExchange tools for extracting and tracking Salesforce object metadata: EasyDescribe, Object Metadata Snapshot and Config Workbook.
-
Visualforce Email template with component to render attachment
How to build a Visualforce component rendered as a PDF attachment on a Visualforce email template and send it automatically with a workflow rule.
-
Salesforce Batch class generating results as CSV
A Database.Stateful batch Apex class on Account that collects success and failure records as CSV attachments and emails them from the finish method.
-
One to One relationship in Salesforce
Shows how to enforce a one to one relationship between two Salesforce objects using configuration only, plus two trigger-based options with sample code.
-
Difference between Salesforce.com and Force.com
A plain-language comparison of Salesforce.com, the SaaS CRM, and Force.com, the PaaS platform it runs on, and what each one offers.
-
Salesforce Difference between Abstract & Virtual class and Interface
Explains how Apex interfaces, abstract classes and virtual classes differ, with code examples and the rules for implementing or extending each.