Delivery

Safe, Staging-First Delivery

⏱ 17 min

Every pattern in this lesson already exists elsewhere in this track. Course 22 built a duplicate-and-approve workflow so an AI agent never edits a live page builder post directly, and a production guardrail using the real wp_get_environment_type() function so destructive abilities refuse to run outside staging or development. What’s new here is the context: a client’s site is not your own test environment, and a mistake on it has a client watching, a real customer-facing site affected, and a relationship at stake. This lesson is about applying those exact same technical patterns as a non-negotiable part of how you deliver AI work to clients, not a new pattern to learn.

What you'll learn in this lesson
Why client delivery raises the stakes on patterns you already know
The technical pattern doesn't change, the cost of skipping it does.
A per-client staging setup, done consistently
Every client engagement gets its own staging environment before delivery starts, not sometimes.
Reusing Course 22's environment guardrail across every client site
The same permission_callback pattern, applied to abilities you build for any client.
A delivery checklist that makes "staging-first" a process, not a hope
What has to be true before an AI-driven change reaches a client's live site.
Prerequisites

Course 22’s duplicate-and-approve workflow and production guardrail lessons, and Course 4’s permission_callback patterns. This lesson doesn’t repeat that code in detail, it applies it to a client-delivery process.

Step 1: Why this matters more, not differently, for clients

The technical risk of an AI agent making an unreviewed, destructive change is the same whether the site is yours or a client’s. What differs is the blast radius of getting it wrong: your own test site produces an annoying rollback, a client’s live site produces a client who watched something break in front of their own customers, and who now questions every future AI-driven change you propose. That asymmetry is the reason staging-first delivery belongs in this course as a firm rule, not a best practice you apply when convenient.

Never make staging-first optional for a rushed client request

A client asking for a same-day fix is exactly the situation where skipping staging feels most tempting, and exactly the situation where a mistake is most visible and most damaging. Treat “we’re in a hurry” as a reason to move faster inside the staging-first process, not a reason to skip it.

Step 2: Every client engagement gets its own staging environment

Course 22’s guardrail depends on wp_get_environment_type() correctly reporting 'staging' or 'development' on a non-live copy of the site. That only works if every client site actually has a staging environment in the first place, and if its WP_ENVIRONMENT_TYPE constant is set correctly, both of which are onboarding steps, not assumptions to make later.

// File: wp-config.php (client staging environment)
define( 'WP_ENVIRONMENT_TYPE', 'staging' );
Confirming staging is real, for every new client, before delivery starts
1
Confirm a genuine staging copy exists
Many hosts provide one by default, some clients have none, don't assume, check.
2
Set WP_ENVIRONMENT_TYPE explicitly on both environments
staging on the staging site, production on the live site, since an unconfigured site defaults to production per Course 22.
3
Verify the value with WP-CLI on both, before any ability is deployed
wp eval 'var_dump( wp_get_environment_type() );' on each environment.
4
Only then deploy the plugin or abilities containing any destructive capability
Deploying to a site where this hasn't been confirmed defeats the entire guardrail.

Step 3: The same guardrail code, reused across every client

The reusable ability library pattern from Course 8 (covered in this course’s Lesson 6 for scaling delivery generally) is exactly where this guardrail belongs: written once, shipped inside every client-facing plugin your agency deploys, rather than re-implemented per engagement.

// File: src/Guardrails.php (part of a shared agency ability library)
namespace MyAgency\ClientAbilities;

class Guardrails {

	public static function is_safe_for_ai_write_actions(): bool {
		return in_array(
			wp_get_environment_type(),
			array( 'local', 'development', 'staging' ),
			true
		);
	}
}

Every destructive ability registered for any client reuses the same check, inside its own permission_callback, exactly the way Course 22 wired it into the page builder editing abilities:

// File: src/Abilities/ClientContentAbilities.php
'permission_callback' => function ( $input ) {
	if ( ! \MyAgency\ClientAbilities\Guardrails::is_safe_for_ai_write_actions() ) {
		return new WP_Error(
			'production_environment_blocked',
			__( 'This action is disabled outside staging and development for this client site.', 'my-agency' )
		);
	}

	return current_user_can( 'edit_posts' );
},

Because this lives in a shared library (Course 8’s pattern), a new client engagement doesn’t mean writing this check again, it means depending on the library and getting the same guardrail automatically, on day one, without anyone having to remember to add it.

Step 4: A delivery checklist that makes this a process, not a hope

Before any AI-driven change reaches a client's live site
The change was made on the client's staging environment, not production
Confirmed by the environment guardrail actually refusing to run on production, tested, not assumed.
Course 22's duplicate-and-approve pattern was used for any page or content edit
A human reviewed the duplicate before anything was applied to the original.
A named human, ideally on the client side, signed off on the reviewed change
Not just your own team, the client's own stakeholder where the engagement calls for it.
The production guardrail was verified on the live site itself
A quick wp eval check confirming destructive abilities genuinely refuse to run there, not just in theory.
Rollback is possible
A recent backup or the trashed-not-deleted pattern Course 22 used for duplicates, so an approved change can still be undone.

Recap

Staging-first delivery for client work is Course 22’s duplicate-and-approve workflow and wp_get_environment_type() production guardrail, applied without exception to every client engagement, because the cost of skipping it is a client relationship, not just a rollback. Every client needs a real, correctly-configured staging environment established during onboarding, and the guardrail code itself belongs in a shared library (Course 8’s pattern, covered next in Lesson 6) so it ships automatically with every new client’s plugin rather than being re-added by hand each time. A short, concrete delivery checklist, not a general intention to “be careful,” is what actually keeps an AI-driven change off a client’s live site until it’s been reviewed and approved.

Resources & further reading

← Client Onboarding and Data-Handling Agreements Scaling Delivery Without Scaling Headcount →