How I get AI to build add-ons for my plugins: follow-up emails

Dave Hilditch •

Black Friday orders are about to arrive, and with them the question of what you send those customers next. Follow-up emails are one of those things every WooCommerce store wants and most store owners end up paying a yearly fee for: an email a day or two after someone buys, then another, until they’ve seen the parts of the product that matter.

Plenty of developers now get an AI to write that kind of thing instead. So on 3 November I tested whether that works on one of my own plugins. I asked my agents to build follow-up emails as a small add-on for Super Speedy Emails, the way a customer’s own AI would have to: from the code and the published guides, through the public hooks, without touching the core plugin. Then I gave a second AI nothing but the code and the public docs, asked it for a different add-on, and had it log every place the docs let it down.

This post covers what the engine owns and what an add-on supplies, the actual prompt I gave the AI, what the docs test found, the decisions that came back to me, and what I’d tell anyone building a WordPress plugin that other people’s AIs will extend.

The honest status, because this is development in public: the add-on is written and its 11 test cases pass, but the Super Speedy Emails changes it depends on are on a feature branch that isn’t merged yet (one of them changes handwritten SQL, and I haven’t signed off that review). So none of this is released to customers yet. What you can use today is the method.

The engine and the add-on

The split is the same one I use across my plugins: the plugin is an engine that owns the hard, shared machinery, and an add-on supplies rules. The Super Speedy AJAX Prices Country Based Prices add-on, the Super Speedy Imports Term Descriptions add-on and the Houzez add-on for Imports are all separate plugins that extend an engine. The point is that an add-on lives in its own plugin, so it survives every update of the engine, and the engine’s updates and security fixes still reach you.

In Super Speedy Emails, the part an add-on extends is Support Emails. Every day the engine walks the owners of a product and asks a registered email type two questions: should this person get an email today, and what does it say? The engine owns everything else:

  • Who owns what. A product owners table with each customer’s first and most recent purchase dates. Because the engine walks every owner, customers who bought a year ago are in the audience on the first run. Backfill comes free.
  • The schedule. An hourly cron that runs each record once per local day after its send hour.
  • Sending and safety. The queue, the mail provider, unsubscribes, a per-day guard, and test modes such as log-only, where nothing leaves the site.
  • The editor. Fields an add-on declares are drawn, saved and validated by the engine, on every write path: the admin editor, a config import, and an AI agent over MCP.
  • MCP abilities. draft-support-rule, update-support-rule and list-support-rules, so an AI agent can set up a record for any registered type, including one it has never seen.

The add-on supplies a type. It registers on sse_register_support_email_types by calling sse_register_support_email_type(), and this is the shape of the real registration, trimmed:

sse_register_support_email_type( 'follow_up_series', array(
	'label'        => __( 'Follow-up series (after purchase)', 'sse-addon-follow-up-emails' ),
	'mode'         => 'per_product',
	'stages'       => 5,    // default number of steps
	'max_stages'   => 10,   // the admin can add steps up to this ceiling
	'placeholders' => array(
		'{step_number}'         => __( 'This step\'s number, starting at 1', 'sse-addon-follow-up-emails' ),
		'{total_steps}'         => __( 'How many steps this series has', 'sse-addon-follow-up-emails' ),
		'{days_since_purchase}' => __( 'Whole days since the purchase the series counts from', 'sse-addon-follow-up-emails' ),
	),
	'stage_fields' => array(   // shown inside each step's editor
		'delay_days' => array(
			'type'    => 'number',
			'label'   => __( 'Not sooner than (days after purchase)', 'sse-addon-follow-up-emails' ),
			'default' => array( 1, 2, 3, 4, 5 ),   // one default per step
		),
	),
	'admin_fields' => array(   // shown once per record
		'anchor'             => array( 'type' => 'select', /* first or most recent purchase */ ),
		'min_gap_days'       => array( 'type' => 'number', 'default' => 1 ),
		'direct_only'        => array( 'type' => 'checkbox', 'default' => true ),
		'one_per_day_global' => array( 'type' => 'checkbox', 'default' => true ),
	),
	'callbacks'    => array(
		'should_send_to_user' => array( 'SSEFU_Series', 'should_send_to_user' ), // WHO
		'content'             => array( 'SSEFU_Series', 'content' ),             // WHAT
	),
) );

That’s the whole contract. The add-on has no cron, no tables, no settings screen and no mailer. It’s three PHP files and 668 lines, and most of that is the rule for when a step is due and an MCP ability (sse-follow-up/describe-series) that explains, for one email address, which steps went when and why the next one isn’t due yet.

The add-on’s rule is four checks. Step N goes on the first daily run where step N-1 has been sent to this person, the purchase is at least that step’s delay old, the minimum gap since the previous step has passed, and (with the checkbox on) the person hasn’t had another follow-up today from any series.

What the engine had to grow first

When I asked for this, Support Emails couldn’t quite do it. A type had a fixed number of steps, there was no per-step setting, and the only way to know which steps someone had already received was to query the email log yourself. A customer’s AI would have had to read the log table directly, and it would have got it wrong (more on that below). So the engine got these, each as a public, documented extension point with its own test:

  • stage_fields: options shown inside each step’s editor and stored with that step. The add-on reads one with $context->stage_setting( 'delay_days', $index ).
  • max_stages: the admin chooses how many steps, up to a ceiling the type declares.
  • SSE_Support_Emails::sent_stages(): which steps this person has been sent for this record and product, and when. It counts real sends only, and the engine uses the same function to pick the next step, so the add-on and the engine can never disagree about where someone is.
  • SSE_Support_Emails::support_sends_since(): how many support emails of a type this person has had since a given time, which is what “one follow-up per person per day” needs.

The add-on checks those exist before it registers anything. If someone installs it on an older Super Speedy Emails, it shows an admin notice and doesn’t register the type, and the engine won’t send a record whose type isn’t registered. Fail closed. I’d much rather a series sends nothing than sends step 4 to someone who never had step 1.

public static function core_supports_series() {
	return class_exists( 'SSE_Support_Emails' )
		&& method_exists( 'SSE_Support_Emails', 'sent_stages' )
		&& method_exists( 'SSE_Support_Emails', 'support_sends_since' )
		&& class_exists( 'SSE_Support_Context' )
		&& method_exists( 'SSE_Support_Context', 'stage_setting' );
}

The prompt

This is what I actually typed to start it, lightly trimmed:

Can you make a new type of support email now please? Not a changelog email, this is a follow-up after purchase email. […] For anyone who has not received the email, they should still receive the first one. So this follow-up emails system, it’s an order of events and technically the date to receive it is ‘not sooner than 1 day after’, ‘not sooner than 2 days after’ etc and email 2 cannot be sent until email 1 has been sent and only 1 email per day max. […] Think how others would love this addon to avoid having to pay stupid money for follow up emails from woocommerce, especially since they can program their own add-ons with their own AI if we provide the great guides and examples and ensure our core plugin is capable with all the hooks and filters required.

That’s a request, not a brief. My coordinating agent turned it into a plan first: it read the code, worked out that Support Emails fitted better than Automations (Automations time steps from enrolment, can’t include people who bought before the automation existed, and don’t check the previous step was really sent), listed what core was missing, and stopped with four questions for me. Engine choice, whether the add-on is free or premium, the order of the first series, and whether existing owners get it. Only once I’d answered did any code get written.

The plan’s most useful section was the core interface contract: the exact function names, argument shapes and return shapes the add-on would call. With that written down, one agent could build the core changes while another built the add-on against them at the same time. This is the brief the add-on agent got, with my local paths replaced by what they point at:

You are building a new private, premium WordPress add-on plugin:
sse-addon-follow-up-emails ("Follow-up Emails for Super Speedy Emails").
It adds a post-purchase follow-up series as a Super Speedy Emails (SSE)
support-email type.

Read first, in full: the approved plan (sections "Design", "The add-on",
"Core interface contract"). The core interface (stage_fields, max_stages,
stage settings, $context->stage_index / stage_setting(),
SSE_Support_Emails::sent_stages(), support_sends_since(), support_stage in
log context) is being implemented RIGHT NOW by another agent on an SSE
feature branch. Build against the contract exactly as written. Do not edit
SSE core.

Also read: our development and testing standard; the SSE Automated Support
Emails Developer Guide; the reference add-on ssp-changelog-emails (type
registration, callbacks, is_preview handling) and its tests (harness
pattern); and a paid add-on as the structural reference (header, licensing
and updates, readme, .gitignore).

Behaviour (type key follow_up_series, mode per_product):
- Step N is due on the first daily run where: step N-1 was sent to this
  person (sent_stages), purchase age >= that step's delay_days stage field
  (anchor: record field, first or most recent purchase), at least
  min_gap_days (record field, default 1) since the previous step, and
  (record checkbox one_per_day_global, default on) no other
  follow_up_series email to this person since UTC midnight
  (support_sends_since with type). Series complete when all steps are
  sent -> never send again.
- Record field direct_only (default on) excludes bundle owners.
- Defaults: stages 5, max_stages 10, delays 1,2,3,4,5.
- Placeholders {first_name} {product_name} {step_number} {total_steps}
  {days_since_purchase}; never write anything during is_preview.
- One ability, sse-follow-up/describe-series (read-only, proper capability
  check): input record_id + optional email; output the steps with delays
  and, for the email, which steps were sent when, when the next becomes
  due, and why it is not due yet.
- GPLv3 header. Requires Plugins: super-speedy-emails. Version 0.1.0,
  readme.txt with a changelog.

Repository: create it locally only. Do NOT create a GitHub repository, add
a remote or push - that needs my approval first.

Tests: a native test site with WooCommerce HPOS on and coming-soon mode
off, SSE in log_only test mode, real WooCommerce orders through status
transitions, the real engine run, and time controlled by backdating real
order and owner dates. Never fabricate data the real system cannot
produce, never re-declare schemas. Cases at minimum: a backfilled old owner
gets step 1 only, then one step per day; step 2 never before step 1; delay
respected for a new buyer; missed days catch up one per day; two follow-up
records for one person -> one email per day when the global checkbox is
on; series stops after the last step; bundle owner excluded when
direct_only; preview writes nothing; describe-series output.

Staging: the core branch may not be finished. Write the plugin and the full
test harness now, but do NOT run the integration tests yet (php -l is
fine). Commit locally and STOP. Report: files written, the exact core API
calls you depend on, anything in the contract that looked insufficient,
and the command to run the suite. Before finishing, make sure nothing you
started is still running.

If you’re writing one of these for your own add-on, these are the parts that did the work:

  • The rule in one sentence, with each check tied to the API call that answers it. “Step N-1 was sent (sent_stages)” leaves the AI nothing to invent. Without that, the obvious thing is to keep its own copy of who got what, and two lists of who got what will disagree eventually.
  • A working example and a structural example. One shows how a type hooks in. The other shows what a finished, licensed, updatable add-on looks like on disk. Name them both.
  • “Do not edit core.” This is the line that turns the job into a test of the engine. If the add-on can’t be built through public hooks, the AI has to say so, not patch around it.
  • Defaults, stated. Five steps, a ceiling of ten, delays of 1 to 5 days, direct buyers only. Defaults are decisions most people never revisit, so they shouldn’t be left to the model.
  • How to test it, including what’s not allowed. Real orders, the real engine run, time moved by backdating real data. No hand-made rows the real system can’t produce.
  • Where to stop and what to report. “Anything in the contract that looked insufficient” is the question that paid off most. The add-on agent came back with three gaps: per-step default lists, recipients planned in the same run but not yet sent (so “one per day” can’t be dodged by two products in one run), and records whose copy only lives in their steps. Each went back to the core agent as a change to the contract, with a test, rather than becoming a private workaround in the add-on.

Testing the docs with an AI that knows nothing

The point of all this is that a customer’s AI can do the same without my plans, my workspace or me. So I tested exactly that. A fresh agent got the Super Speedy Emails code, its KB guides and the live site, and was told not to read anything else. Its job was a different add-on, review request emails:

You are a developer's AI assistant. Your user runs a WooCommerce store with
the Super Speedy Emails plugin and wants an add-on built. You have ONLY
these sources: the Super Speedy Emails codebase (start with its KB guides
and case studies) and the public KB and Dev Hub on superspeedyplugins.com.
Do NOT read anything else. If you need something they don't tell you,
write that down as a gap instead of hunting elsewhere.

The add-on: "Review request emails". After a customer buys a product, send
them an email asking for a review, not sooner than a configurable number of
days after purchase (default 7). If they haven't left a review after a
further configurable number of days (default 7), send one reminder. Never
send to someone who has already left an approved review for that product.
Never more than those two emails per person per product. Existing customers
who bought before the add-on was installed are included only if they
bought within a configurable number of days (default 90). The store owner
configures delays and copy in the Super Speedy Emails editor, and their own
AI agent must be able to set it up over MCP.

Prove it works with real WooCommerce orders and the plugin's real daily
run, moving time by backdating real order dates. Make each check fail once
for its reason before trusting it. Configure one record through Super
Speedy Emails' own abilities, as an agent would.

Keep a friction log as you go: every place the KB or code comments were
missing, wrong, ambiguous or misleading, and anything you got wrong first
time because of the docs. This log is the main deliverable.

It worked. The add-on passed 4 cases and 14 checks, and 7 negative controls each went red for their stated reason. The agent also configured a record through draft-support-rule and the editor showed its values. But the friction log is the bit I care about. It had 11 findings, three of them high severity:

  • The live KB couldn’t build it. Everything that made the add-on possible was only in the plugin’s unpublished KB folder. The live developer guide was an older version without any of it, and the new articles returned 404. Its words: “About 80% of the add-on came from” the developer guide, the new one.
  • A fixed-count type accepted extra steps over MCP. A type declared with 2 steps took a 3rd through draft-support-rule, and the engine then sent it as a third email. The KB said one thing and a code comment said the opposite. Reproduced with a failing test and fixed on the main branch, which now validates the step count on every write path.
  • No answer for “only customers who bought before the add-on was installed”. The agent invented its own install timestamp, which was the right call, and the guides (not yet published) now cover the case.

Smaller ones included a draft with no type silently defaulting to a changelog type that isn’t registered on a plain install (also fixed: unregistered types are refused), and a testing article that described the harness without naming any of the functions you need to build it. A docs agent then fixed the KB from the log.

If you build plugins other people will extend, do this. Your docs have bugs exactly like your code does, and you can’t see them, because you already know the answers.

What I had to decide

The agents built most of this without me, but some things aren’t theirs to decide.

Is it too rigid?

When I read the first version I worried it only did one shape of series. My question was how it handles one email a week after purchase, three education emails on days 1, 3 and 5, five on days 1 to 5, and something like 3, 6, 9 and 12 months with a few reminders before the 12-month mark. The first three are just step counts and delays:

You wantSteps“Not sooner than” per step
One email a week after purchase17
3 education emails31, 3, 5
5 education emails51, 2, 3, 4, 5

The agent’s answer on the last one was the useful bit: the rigidity wasn’t the number of steps, it was that a series always catches up. That’s right for education. Someone who bought a year ago should still get lesson 1. It’s wrong for anything tied to a date. Launch a 3/6/9/12-month series to someone who bought 400 days ago and they’d get “3 months in” today, “6 months in” tomorrow, and “your renewal is in 7 days” four days later, every one of them false.

“Not sooner than” or “exactly”?

“Not sooner than” was my rule from the start, and it’s still the default. “Exactly 3 days after purchase” breaks the first time a daily run doesn’t happen: the engine skips a missed day rather than replaying it, so the step is gone for good. With “not sooner than”, cron being down, a paused record or a late launch just becomes a short delay, and customers who bought before the series existed start at step 1 and get one step a day until they’ve caught up. The add-on’s test suite proves it both ways: change the check to “exactly N days” and the backfill and downtime tests both fail.

The agent suggested a “skip if more than N days late” window per step. I preferred something a store owner can understand at a glance: each step is either not sooner than day N or exactly on day N, mixed freely within one series, with help text under the choice that spells out what “exactly” costs you. Miss that day’s run, or have bought before the email existed, and you never get that step. That’s planned, not built. The engine picks the next step by counting how many have gone, which stops working once steps can be skipped, so core needs one more optional callback that lets a type choose its next step.

Approving the SQL

I have a standing rule: any change to handwritten SQL needs a review document showing the exact query before and after, what it does to row counts and ordering, and timing evidence, and nothing merges until I’ve approved it. This build produced two.

The first was a bug fix the add-on’s tests found. The test site keeps its database clock at UTC+2 on purpose, and the add-on’s 11th case showed that a step sent at 23:00 UTC is stored as 01:00 the next day, so the per-day guard thought it had gone today and skipped the next day’s step. Any send between 22:00 and midnight UTC on a server like that lost a day. The fix compares times through the database’s own clock (FROM_UNIXTIME() for bounds, UNIX_TIMESTAMP() for reads). I approved it and it’s merged into the main branch of Super Speedy Emails.

The second is the feature itself: counting steps per send mode, so a log-only rehearsal no longer uses up a customer’s real steps (two rehearsals then going live meant the first real email anyone got was step 3), plus two new indexes built on the first admin page load after the update. That review is still waiting for me, which is why the feature branch isn’t merged.

What it found on the way

Building the add-on as an outsider was a better audit of the engine than anything I’d have planned. Every bug below was reproduced with a failing test before anyone fixed it:

  • Purchase dates were stored in the site’s timezone and read as UTC. On a New York site a purchase 20 hours old read as 25 hours old. Fixed on the main branch.
  • Test-mode rehearsals advanced the real step count (the SQL review above).
  • A record created over MCP with its copy only in its steps planned “no content” and never sent. The admin editor had been hiding it by copying step 1 on save.
  • A new record in the editor showed the changelog type until its first save, and that save copied the changelog’s default subject into step 1. Fixed on the main branch.
  • The database clock day boundary, above.

None of these were follow-up bugs. They were engine bugs that any add-on would have hit, and an add-on author with no access to my code would have spent days on them, or more likely blamed their own add-on.

The lessons for extensible plugins

  • Make the engine own the machinery and let add-ons own rules. Who’s eligible, the schedule, sending, test modes, validation and the editor belong in core. An add-on that needs its own cron or its own table is a sign the engine is missing an extension point.
  • Expose state, not just hooks. sent_stages() mattered more than any filter. If an add-on has to query your tables to find out what already happened, it will get it wrong.
  • Write the contract before the code. Exact names and shapes in a plan let two agents work at once, and the gaps they find become core changes instead of workarounds.
  • Give the AI the rule, the API for each part of it, an example, and a stopping point. And ask what looked insufficient. That question found more than the code review did.
  • Choose defaults that survive the real world. “Not sooner than” survives downtime and late launches. “Exactly” is an option for when the date is the point, with its cost spelled out in the editor.
  • Test your docs with an AI that knows nothing. Ask it for a friction log, not just a working add-on.
  • Keep the human decisions human. Handwritten SQL, behaviour changes, pricing and anything public still come to me. The agents bring the question with the context and a recommendation, one at a time.

If you want to try this on any of my plugins, start at the Dev Hub, and give your AI the Start with AI guide. The current Automated Support Emails Developer Guide covers registering a type today, and the per-step extension points will be added to it when that branch is merged and released. Or skip the build entirely: if your follow-up series is the kind every store wants, ask for it on the issue tracker and it may end up in the plugin.

Comments