Require stage deployment before production
π― Goal: two prompts to your coding assistant, and no build reaches production without having run in stage first. A workflow checks every production deploy against the build's real deployment history, builds that ran in stage go out on their own, and a hotfix that has to skip stage needs a second person's sign-off with a reason on record.
Introductionβ
"Test it in stage first" is one of the oldest rules in software delivery, and one of the easiest to skip. Under pressure, someone deploys straight to production. Nothing stops them, and nobody notices until the incident review.
Enforcing the rule needs one fact at deploy time: has this exact build already run in stage? Nullplatform already knows the answer, because every deployment is recorded against the scope it ran in and the release it carried. This tutorial puts that knowledge in front of every production deploy:
- One prompt creates the workflow that answers the question from the build's deployment history, at the moment the production deploy is requested
- One prompt creates the checklist that asks the question, plus a way out for real emergencies that's attributable to a named second person
There's no metadata to keep in sync and nothing to host: the workflow reads the deployment history directly, so the answer can't drift from what actually happened.
What you'll set upβ
- A checklist on
deployment:createin production with:- Build ran in stage first (blocking): an external item a workflow answers
- Hotfix: skip stage (override): a sign-off from someone other than the requester, with a required comment
- A workflow that receives each check, looks up the build's finalized deployments in stage scopes of the same application, and passes or fails the item with the evidence on the card
- Automatic execution: an approved deploy starts on its own, whether the build passed the check or a teammate signed the hotfix
π‘ Want the machinery first? Jump to What you just built, then come back.
Prerequisitesβ
- Checklists enabled in your organization (early release)
- An
environmentdimension withstageandproductionvalues, and at least one application with a scope in each - The np-workflow and np-checklist skills, part of the nullplatform AI plugins for your coding assistant. See Set up the AI plugins to install them
- An API key the workflow can use to read scopes, deployments, and releases
Step 1: Create the workflow that checks the historyβ
Open a session of your coding assistant and describe the check. The prompt has to state the kind it answers, what counts as "ran in stage", and what to do when it can't tell.
/np-workflow create a workflow that resolves checklist items of kind
"stage-deploy-check":
The item sends application_id and build_id. List the application's scopes
whose environment dimension is "stage", read their deployments, and look
for a finalized one whose release was built from that build.
If you find one, pass the item with a message naming the stage scope and
when it finished. If not, fail it with a message telling the developer to
deploy the build to stage first or ask for a hotfix override. If any call
fails, fail the item closed and say the stage deployment couldn't be
verified.
Publish it but don't activate it yet.
The skill builds the definition, validates it, and publishes it. The workflow reads one configuration entry; ask the skill to set it in the same conversation, or set it later in Platform Settings β Workflows β Variables and secrets:
| Entry | Type | What it is |
|---|---|---|
NP_API_KEY | Secret | API key the workflow reads scopes, deployments, and releases with |
Checking against the build, not the release, is deliberate. A new release with different parameters but the same build is the same code, and it already proved itself in stage.
β Checkpointβ
The skill reports the workflow as published, activation skipped. Nothing answers checks yet: the checklist comes next.
Step 2: Create the checklist that asks for itβ
Now the checklist that puts the workflow in front of every production deploy:
- Coding assistant
- Terraform
/np-checklist create a checklist named stage-before-production:
- A blocking external item "Build ran in stage first" of kind
"stage-deploy-check", dispatched automatically when the run starts,
sending the application id and the build id, with a 5-minute timeout.
- An override "Hotfix: skip stage" that requires a comment, can't be given
by the requester, and needs the ops or admin role. Its description
should say it's only for urgent fixes that can't wait for stage.
Set execution_trigger: any_approval. Connect it to deployment:create in
production across my account (create the action if it doesn't exist).
Use the nullplatform Terraform provider v0.0.106 or later:
resource "nullplatform_checklist_specification" "stage_before_production" {
nrn = "organization=1:account=2"
name = "stage-before-production"
definition = jsonencode({
execution_trigger = "any_approval"
items = [
{
id = "ran_in_stage"
type = "external"
behavior = "gate"
severity = "major"
title = "Build ran in stage first"
external = {
kind = "stage-deploy-check"
trigger = "auto"
timeout_seconds = 300
inputs = {
application_id = "{{ context.application.id }}"
build_id = "{{ context.build.id }}"
}
}
},
{
id = "hotfix_override"
type = "manual"
behavior = "override"
title = "Hotfix: skip stage"
description = "Only for urgent fixes that can't wait for stage. Explain the urgency in the comment."
require_comment = true
validations = [
{
id = "four_eyes"
message = "Someone other than the requester must approve the hotfix."
rule = { "actor.user_id" = { "$ne" = "$approval.requested_by" } }
},
{
id = "ops_role"
message = "Requires the ops or admin role."
rule = { "actor.effective_roles" = { "$in" = ["ops", "admin"] } }
}
]
}
]
})
}
resource "nullplatform_approval_action" "production_deploys" {
nrn = "organization=1:account=2"
entity = "deployment"
action = "deployment:create"
dimensions = {
environment = "production"
}
}
resource "nullplatform_approval_action_checklist_specification_association" "production_deploys" {
approval_action_id = nullplatform_approval_action.production_deploys.id
checklist_specification_id = nullplatform_checklist_specification.stage_before_production.current_version_id
}
The kind is the only coupling between the checklist and the workflow. That's what lets one workflow serve every application you point a checklist at, and lets you replace the workflow later without touching a single spec.
The override is the release valve, and its validations are what keep it honest: the person in a hurry can't approve their own hotfix, and the one who does is named on the run with the reason they gave.
An approval action runs on a checklist or on policies, never both. If your production deployment:create action already has policies attached, the connection fails with a 409. Reach out to the nullplatform team to move it onto a checklist.
β Checkpointβ
The skill reports the spec created and linked to the production action.
Step 3: Review the workflow and activate itβ
In the nullplatform UI, open Platform Settings β Workflows and click the workflow. The canvas shows the whole check:
Resolves checklist items of kind stage-deploy-check: passes when the build being deployed to production already has a finalized deployment in a stage scope of the same application, fails otherwise. Any error fails the item closed.
6 steps
Click a node to see the step it runs.
Two things to notice:
- The answer comes from the record, not from memory. The workflow looks up finalized deployments at the moment it's asked, so a stage deploy that failed or was rolled back doesn't count.
- Every exit answers the item. Found, not found, or an error: each path resolves the checklist item, and the error path fails closed. A deploy never waits on a question nobody will answer.
Activate the workflow: click the version chip in the editor header and choose Publish vN. Activation subscribes it to stage-deploy-check dispatches, so do it with your own session, one that's allowed to create notification channels.
β Checkpointβ
The workflow shows as active, with stage-deploy-check as its trigger's kind.
Step 4: Promote a buildβ
Pick an application with a stage and a production scope. Deploy a fresh build straight to production first, then take the long way:
A failed item doesn't end the request. Deploy the build to stage, then retry the item from the production deploy's run: the workflow checks again and, once it passes, the deploy starts.
β Checkpointβ
The build that skipped stage was blocked with the workflow's message on the card. The same build went to production on its own once it had a finalized deployment in stage.
Make it yoursβ
- Require more than one environment. Change the workflow's lookup to "ran in stage and in performance", and the checklist stays the same.
- Require it to have soaked. Ask the workflow to pass only when the stage deployment finished at least an hour ago, so a build that crashes a few minutes after deploying never makes it.
- Combine it with the other production guardrails. Add the quality gates and the PCI sign-off to this same spec, so one production checklist holds every rule a deploy has to meet.
What you just builtβ
How the pieces fit together
You have two pieces. The checklist spec declares what a production deploy must satisfy. The workflow answers the one question the checklist can't answer from the request alone.
The checklist's view of the deploy only covers the request itself: the build, the release, the target scope, and what's running there now. Where else the build has run isn't part of it, which is why an external item and a workflow do the looking up.
The complete spec:
{
"name": "stage-before-production",
"definition": {
"execution_trigger": "any_approval",
"items": [
{
"id": "ran_in_stage",
"type": "external",
"behavior": "gate",
"severity": "major",
"title": "Build ran in stage first",
"external": {
"kind": "stage-deploy-check",
"trigger": "auto",
"timeout_seconds": 300,
"inputs": {
"application_id": "{{ context.application.id }}",
"build_id": "{{ context.build.id }}"
}
}
},
{
"id": "hotfix_override",
"type": "manual",
"behavior": "override",
"title": "Hotfix: skip stage",
"description": "Only for urgent fixes that can't wait for stage. Explain the urgency in the comment.",
"require_comment": true,
"validations": [
{
"id": "four_eyes",
"message": "Someone other than the requester must approve the hotfix.",
"rule": { "actor.user_id": { "$ne": "$approval.requested_by" } }
},
{
"id": "ops_role",
"message": "Requires the ops or admin role.",
"rule": { "actor.effective_roles": { "$in": ["ops", "admin"] } }
}
]
}
]
}
}
A hotfix that goes out through the override resolves the run as approve_with_override. The failed item stays failed, so the record shows both that the build skipped stage and who decided it could.
Building blocks usedβ
| Block | Role in this guardrail |
|---|---|
| Triggers | np-checklist-trigger subscribes the workflow to stage-deploy-check dispatches |
| Nodes | code-exec looks up the deployment history; conditional branches on the result; np-checklist-item-resolve answers the run |
| Error handling | A fallback step fails the item closed when the lookup errors |
| Secrets and variables | The API key lives as a secret, never in the definition |
What's nextβ
- Approve secret access by environment: the same model on another action, revealing secret values
- Match approval friction to deploy risk: score every change and route it to the approval it deserves