The Cardinal Rule Verify Before Production
HOOK
A DevOps engineer used an AI to generate a Terraform configuration for a production database. The AI output looked good. The engineer ran terraform apply directly to production.
The configuration had a subtle error: force_destroy = true on the database resource. This single line meant "delete the database if I destroy the infrastructure."
Three days later, during an infrastructure cleanup, someone ran terraform destroy to remove dev resources. They accidentally destroyed the entire workspace, including production. The database deleted. $4M of customer data gone. Eight hours of downtime. GDPR violations pending.
The cost of not verifying one AI output: $2M in damages, three people fired, regulatory fines pending.
This lesson teaches you how to build verification into every AI-driven workflow so that cost never happens at your company.
Purpose
By the end of this lesson, you'll have a concrete framework for:
- Setting up staging/testing environments for every AI output before production
- Building peer review into AI-dependent workflows
- Creating rollback procedures so mistakes can be contained
- Testing AI-suggested configurations before they matter
- Recognizing when AI output is too risky to implement without additional verification
- Building organizational culture around "trust but verify"
This isn't a technical lesson. It's a practice lesson. It's about building systems that assume AI will make mistakes and designing verification procedures to catch them.
Why This Matters for IT Operations Professionals
This is the most important lesson in the entire course, so let me be direct: if you implement nothing else from this course, implement a verification mindset for AI outputs.
Here's why:
AI enables speed, but speed without verification creates disasters. Before AI, generating a database configuration took an hour of careful manual work. Now it takes 2 minutes. But that speed is only valuable if the configuration is correct. If it's not, you've accelerated a disaster.
The stakes in IT Ops are high. A developer's AI-generated code bug affects maybe 1,000 users. A DevOps engineer's AI-generated configuration bug can take down a system that affects millions. The blast radius is larger. The cost is higher. The margin for error is smaller.
Trust is earned, not assumed. You don't let a junior engineer deploy a critical change without review. You shouldn't let an AI do it either. But many teams do, because the AI output *looks* correct and review takes time. Building verification into your standard workflow prevents this pressure.
The cost of a production incident far exceeds the cost of verification. Spending 30 minutes to test and review an AI-generated configuration is free compared to the cost of a 4-hour outage. This is the calculation you need to internalize.
Core Concepts
1. Staging Environments Are Mandatory for AI Outputs
Key insight: The only place to test AI output is non-production. Period.
Here's what "staging" means in different contexts:
Context 1: Infrastructure Changes (Terraform, CloudFormation, Ansible)
Don't apply AI-generated infrastructure changes directly to production. Instead:
- Create a staging infrastructure that mirrors production in structure but has lower blast radius
- Production database: 50GB, critical
-
Staging database: 10GB, non-critical, same software version
Apply the AI change to staging first- terraform apply -target staging
- Verify the resources were created as expected
- Check that they can communicate with other systems
-
Run performance tests if applicable
Only after staging succeeds, apply to production- Even then, do it during a maintenance window if possible
- Have a rollback plan ready
Example: Database Configuration Change
AI suggests:
resource "aws_db_instance" "prod" {
instance_class = "db.r6i.4xlarge"
allocated_storage = 1000
backup_retention_period = 35
multi_az = true
}
Steps:
- Apply to staging first: terraform workspace select staging
- Verify the staging instance launches, can be reached, passes connectivity tests
- Run a backup and verify restoration works
- Review the billing impact (cost increases by $X/month)
- Only then apply to production
Context 2: Scripts and Automation (Bash, Python)
Don't run AI-generated scripts directly in production. Instead:
- Run in a test environment
- Dedicated test VM
- Dedicated Kubernetes cluster
-
Or local docker container with production-like data
Verify output- Does the script do what you asked?
- Does it handle errors correctly?
- Does it clean up after itself?
-
Does it log properly?
Review the code thoroughly- Someone else reads it
- Check for dangerous operations (rm, delete, drop)
-
Check for permission assumptions
Schedule a deployment window- Run in production during low-traffic times
- Be ready to rollback immediately
Example: Log Cleanup Script
AI generates:
#!/bin/bash
find /var/log -name "*.log" -mtime +30 -delete
Test steps:
- Create a test directory with sample log files
- Run the script in test directory with -print instead of -delete first
- Verify it identifies the right files
- Run with -delete and verify old files are gone, new files remain
- Schedule in production during maintenance window
- Have a rollback plan (restore from backup)
Context 3: Configuration Files (YAML, INI, JSON)
Don't deploy AI-generated configs directly. Instead:
- Review the config against your actual system
- Are all the fields valid for your software version?
- Do the values make sense for your infrastructure size?
-
Are there deprecated fields being used?
Test in non-production- Apply the config to a staging system
- Verify the application starts and behaves correctly
-
Run your standard smoke tests
Do a canary deployment- Deploy to 1% of production first if possible
- Monitor for 30 minutes
- If stable, roll out to the rest
Example: Kubernetes ConfigMap
AI generates:
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
namespace: production
data:
max_connections: "500"
cache_ttl: "3600"
log_level: "debug"
Test steps:
- Apply to staging cluster first
- Deploy the application with the config
- Verify the application reads the config correctly
- Check metrics: Does max_connections actually go to 500? Is log level debug?
- If all correct, apply to production during maintenance window
2. Peer Review Is Non-Negotiable
Key insight: A second set of eyes catches mistakes that both you and the AI miss. Make peer review a requirement, not an option.
Here's what good peer review looks like:
For Infrastructure Changes:
Reviewer checklist:
- [ ] Does this change match the problem we're solving?
- [ ] Are there any dangerous operations (delete, destroy, force)?
- [ ] Is this change reversible / can we rollback easily?
- [ ] Will this impact other teams or systems?
- [ ] Did we test this in staging?
- [ ] Are there any vendor/compliance constraints this violates?
- [ ] Is the cost reasonable for what we're getting?
For Scripts:
Reviewer checklist:
- [ ] Can I understand what this script does without running it?
- [ ] Are there any security risks (executing user input, unquoted variables)?
- [ ] Does it handle errors (set -e, try/catch)?
- [ ] Are there any rm/delete/drop commands without safety checks?
- [ ] Does it clean up after itself (temp files, locks)?
- [ ] Will it work on both old and new versions of the tool?
- [ ] Does it have logging so we can debug if it fails?
For Configurations:
Reviewer checklist:
- [ ] Are all these fields documented in the official docs?
- [ ] Are the values appropriate for our infrastructure size?
- [ ] Does this match our organization's configuration standards?
- [ ] Will this work with all the versions of software we support?
- [ ] Is there a performance impact we should be aware of?
Making Peer Review Work:
The problem: Review takes time. People want to ship fast.
The solution: Make review a requirement, not optional. It's like code review. It's part of the process, not extra.
- For critical systems: Always require review before production deployment
- For non-critical systems: Require review if the change is generated by AI (since AI can hallucinate)
- For scripts: Require review if the script has dangerous operations (delete, restart, config changes)
- For configs: Require review if the config affects performance or security
This isn't bureaucracy. It's insurance. The cost of review is 20 minutes. The cost of a mistake is 4 hours of downtime. The math is obvious.
3. Rollback Procedures: Plan for AI Mistakes
Key insight: If you can't roll back quickly, you can't deploy. This is true for all changes, but especially true for AI-generated changes since they're higher-risk.
Rollback Strategy by Change Type:
Type 1: Configuration Changes
Before deploying:
- Backup current configuration
- Document the current state
- Plan the rollback: "If bad, change this field back to X"
During deployment:
- Monitor for 30 seconds
- If errors appear, execute rollback immediately
Rollback execution:
Before change
cp app.conf app.conf.backup
Deploy new config
cp app.conf.new app.conf
systemctl restart app
If something's wrong within 60 seconds
cp app.conf.backup app.conf
systemctl restart app
Type 2: Infrastructure Changes
Before deploying:
- Have a snapshot/backup of current state
- Plan what terraform destroy or revert would look like
During deployment:
- Use terraform plan to see exactly what will change
- If anything looks wrong, don't apply
- If you do apply and something's wrong, terraform destroy and reapply
Safer approach:
Never direct apply to production
terraform workspace select staging
terraform apply # test first
terraform workspace select production
terraform plan # review exactly what changes
# If plan looks good:
terraform apply
If something's wrong:
terraform destroy # roll back
git revert <commit> # revert the code
Type 3: Database Changes
Before deploying:
- Always have a backup
- Test the change on a backup copy in non-prod
- Plan rollback: "If bad, run this SQL to revert"
During deployment:
- Run change in a transaction, verify result, commit
- If verification fails, rollback
Safer approach:
-- Test
BEGIN TRANSACTION;
ALTER TABLE users ADD COLUMN new_field VARCHAR(255);
-- Verify it worked
SELECT COUNT(*) FROM users;
-- If good
COMMIT;
-- If bad
ROLLBACK;
Type 4: Code Deployments
Before deploying:
- Test in staging
- Have a canary plan (deploy to 1% first)
- Have a rollback: previous version is still running
During deployment:
Current version running: v1.5
# Deploy new version: v1.6
docker run -p 3000:3000 app:v1.6 # start new version
Verify it works (health checks, smoke tests)
# If good, switch traffic from v1.5 to v1.6
If bad (errors increase), switch traffic back to v1.5
4. Test Plans: Verify AI Output Does What You Asked
Key insight: "Works in staging" doesn't mean "solves the problem." You need a test plan that verifies the AI output actually solves what you asked.
Example: Performance Optimization
AI recommends adding an index to a slow database query.
Test plan:
Before index:
- Run query 1000 times
- Measure average time: X ms
- Measure p95 time: Y ms
Apply the index
After index:
- Run query 1000 times
- Measure average time: Should be < X
- Measure p95 time: Should be < Y
Success criteria:
- Average time improves by at least 30%
- P95 time improves by at least 30%
- No new errors in application logs
- Database CPU doesn't increase overall
If these criteria aren't met, the "fix" didn't work. Don't deploy.
Example: Monitoring Alert Optimization
AI recommends changing alert thresholds.
Test plan:
Baseline (current thresholds):
- Run production traffic simulator for 1 hour
- Count number of false alerts: N
- Count missed real problems: M
With new thresholds:
- Run same traffic simulator for 1 hour
- Count false alerts: Should be < N
- Count missed problems: Should be ≤ M
Success criteria:
- Fewer false alerts
- No more missed problems than before
- Alert response time doesn't change
Example: Script or Automation
AI generates a backup script.
Test plan:
Test 1: Basic functionality
- Run backup script on test environment
- Verify backup file is created
- Verify backup file size is reasonable (not 0, not huge)
Test 2: Restore from backup
- Verify you can restore data from backup
- Verify restored data matches original
Test 3: Error handling
- Run script when disk space is low
- Script should fail gracefully (not delete more data)
- Run script with wrong permissions
- Script should error, not run as root and break things
Test 4: Schedule
- Schedule script to run automatically
- Verify it runs at expected time
- Verify it doesn't interfere with other processes
If any test fails, don't deploy.
5. The Verification Workflow
Key insight: Build verification into your standard deployment process. It should be automatic, not optional.
Here's a concrete workflow you can implement:
Stage 1: Generation
Engineer asks AI to generate [script/config/infrastructure]
↓
AI provides output
↓
Engineer reviews AI output for obvious errors
(syntax, dangerous commands, hallucinations)
Stage 2: Testing
Engineer creates test environment (staging, container, VM)
↓
Engineer applies AI output to test environment
↓
Engineer runs test plan
- Does it do what we asked?
- Does it break anything?
- Does it meet success criteria?
↓
If tests fail:
- Either fix the AI output
- Or ask AI for a different approach
- OR do it manually
Stage 3: Peer Review
Engineer sends AI output + test results to peer
↓
Peer reviews:
- Code/config quality
- Test results
- Blast radius of the change
- Rollback plan
↓
Peer approves or requests changes
Stage 4: Staged Deployment
Deploy to staging/canary first (if not already done in testing)
↓
Monitor for errors
↓
If stable, deploy to production
↓
If errors, rollback immediately using pre-planned procedure
Stage 5: Post-Deployment Verification
Monitor metrics:
- Error rates
- Performance
- Resource usage
↓
If metrics are healthy for 30 minutes:
- Declare success
- Document what worked
↓
If metrics degrade:
- Rollback immediately
- Investigate what went wrong
- Document the failure
6. Cost-Benefit of Verification: It's Free
Key insight: The time spent on verification is tiny compared to the cost of a production incident.
Let's do the math:
Scenario: Deploy AI-generated database configuration
Option 1: No verification (risky)
- Time to deploy: 5 minutes
- Probability of serious problem: 5%
- Expected cost if problem: $100,000 (4-hour outage)
- Expected cost: 5% × $100,000 = $5,000
Option 2: Test in staging + peer review (safe)
- Time to test: 20 minutes
- Time for peer review: 15 minutes
- Total time: 35 minutes
- Probability of serious problem: 0.1% (much lower)
- Expected cost if problem: $5,000 (1-hour outage before you catch it)
- Expected cost: 0.1% × $5,000 = $5
Savings from verification: $5,000 - $5 = $4,995
Over this, you spent 35 minutes. That's $4,995 / 35 minutes = $142 saved *per minute* of verification time.
This is why verification is free. It's an investment with a 14,200% return on investment.
The only time verification is "expensive" is when you're in a crisis and need to deploy right now. And even then, the cost of being wrong is higher than the cost of taking 30 seconds to verify.
Practical Implementation: The Verification Checklist
Here's a concrete checklist you can use for every AI-generated change:
Pre-Deployment Checklist
- [ ] Hallucination check: Did I search for the suggested commands/configs in official docs? Are they real?
- [ ] Syntax check: Is the output syntactically correct for my system? (Run through a linter if possible)
- [ ] Context check: Does this account for my infrastructure, constraints, and recent changes?
- [ ] Risk check: What's the blast radius if this is wrong? Who gets affected?
- [ ] Testing plan: What would I measure to verify this works? Is a test feasible?
Testing Checklist
- [ ] Test environment ready: Do I have a staging/test environment? Does it mirror production?
- [ ] Safety check: Have I verified rollback is possible? Do I have a rollback procedure?
- [ ] Test execution: Did I run the test plan? Did it pass?
- [ ] Error scenarios: Did I test what happens when things go wrong?
Review Checklist
- [ ] Peer review: Has another person reviewed this? Do they agree it's safe?
- [ ] Documentation: Is the change documented? Would someone else understand why we did this?
- [ ] Runbook updated: If this is a critical change, does the runbook reflect it?
Deployment Checklist
- [ ] Timing: Is this going during a low-traffic window? Is my team available to rollback?
- [ ] Rollback ready: Do I have the rollback command typed and ready?
- [ ] Monitoring: Have I enabled detailed monitoring for this change?
- [ ] Communication: Have I notified relevant teams this is happening?
Post-Deployment Checklist
- [ ] Immediate verification: Did the change apply successfully? Any errors?
- [ ] Metric check: Are error rates normal? Is performance normal?
- [ ] 30-minute check: Are metrics still healthy 30 minutes later?
- [ ] Documentation: Have I updated documentation with what we learned?
Real Examples: Verification Catches Disasters
Example 1: The Pre-Deployment Save
What almost happened:
An engineer used an AI to generate an Ansible playbook for a database migration. The playbook looked correct. She was about to deploy it during the maintenance window.
What the verification caught:
During peer review, a colleague noticed:
- The playbook used become: yes to run as root
- One step had shell: "rm -rf /var/cache/*" to "clear old caches"
- In production, this would delete not just old caches, but also active application caches that are needed for performance
Cost of verification: 15 minutes of peer review
Cost of not catching it: 2 hours of downtime during business hours while the application restarted and rebuilt caches
Outcome: The playbook was modified to use specific directories instead of wildcards
Example 2: The Staging Test That Failed
What almost happened:
An engineer generated a Terraform configuration for a new RDS database. The configuration looked correct. He tested it in staging.
What testing revealed:
In staging, the database creation succeeded. But when the application tried to connect, it failed: "Server certificate verification failed."
Investigation showed: The Terraform code didn't include the SSL certificate parameters. The AI's output was incomplete.
Cost of testing: 25 minutes in staging
Cost of deploying to production: Complete application failure until corrected, plus developer time debugging a production database issue
Outcome: SSL parameters were added. The change was only deployed after staging testing confirmed the full flow worked
Example 3: The Rollback That Saved the Day
What happened:
A DevOps team deployed an AI-generated networking configuration to production. Testing in staging had passed. Peer review had approved it.
But 5 minutes after deployment, they noticed error rates climbing. The AI had made a subtle mistake in the routing rules that affected 0.5% of traffic.
What saved them:
They had a rollback plan. In 2 minutes, they reverted the configuration. Errors dropped back to normal.
Cost of having a rollback plan: 5 minutes to think through and document it before deployment
Cost of not having a rollback plan: 45 minutes of troubleshooting, 30 minutes of manual configuration reversion, customer complaints
Outcome: They fixed the routing configuration (took 2 days in staging), then deployed the corrected version
Building Verification Culture
This isn't just about procedures. It's about culture. You need your entire team to internalize: "AI output is generated, not gospel. Verification is not optional."
How to build this culture:
Make verification visible. In your change logs, show what was tested and by whom. Celebrate successful verifications.
Make failures visible. When verification catches a mistake, acknowledge it. "Good catch during testing. This would have broken production." This reinforces that testing works.
Make rollback easy. If rollback is hard, people won't verify (they'll feel they're taking a bigger risk). If rollback is easy and practiced, verification feels low-risk.
Require peer review for AI outputs. Make it a policy: "All AI-generated code/config/infrastructure requires peer review before production." This normalizes the extra step.
Invest in staging environments. The biggest barrier to testing is not having a staging environment. Make sure all critical systems have staging.
Document near-misses. Every time verification catches a problem, document it. "AI suggested command X which doesn't exist. Testing caught it. Here's what we learned." Over time, patterns will emerge about what types of AI mistakes are most common.
The Math on Risk vs. Verification Time
Here's a framework for deciding how much verification is enough:
Risk Level 1: Low-risk changes
- Examples: Adding a documentation file, changing a non-critical monitoring threshold
- Time to verify: 5 minutes (scan for obvious errors)
- Peer review required: No
- Testing required: No
- Rollback required: No
Risk Level 2: Medium-risk changes
- Examples: Adding a new library to a non-critical service, changing application configuration
- Time to verify: 20 minutes (test in staging)
- Peer review required: Yes
- Testing required: Yes (run the app, check it starts)
- Rollback required: Yes (previous version is running)
Risk Level 3: High-risk changes
- Examples: Database schema changes, infrastructure changes, script that deletes data, changes to production deployment
- Time to verify: 60 minutes (full test, peer review, rollback plan)
- Peer review required: Yes (2 reviewers)
- Testing required: Yes (full test plan with success criteria)
- Rollback plan required: Yes (documented and tested)
- Canary deployment required: Yes (1% first, then 100%)
Risk Level 4: Critical-risk changes
- Examples: Database migration, cluster upgrade, changes to authentication, changes to backup procedures
- Time to verify: 2+ hours (extensive testing, multiple reviews, rehearsal)
- Peer review required: Yes (3+ reviewers, including subject matter experts)
- Testing required: Yes (full test plan + edge case testing)
- Rollback plan required: Yes (documented, tested, rehearsed)
- Canary deployment required: Yes (5% first, monitor for 1 hour, then 100%)
- Backup/recovery verification required: Yes
- Maintenance window required: Yes (during approved window)
Key Takeaways
Verification is non-negotiable for any AI output that touches production. This isn't paranoia. It's professional ops. You verify changes because the cost of a mistake is high.
Build verification into your standard workflow. Test in staging, peer review, rollback plan, post-deployment monitoring. Make it automatic, not optional.
Staging environments aren't luxury. They're mandatory. If you don't have a staging environment for a critical system, your first priority should be building one. The staging environment is where AI mistakes go to die, not production.
Peer review is insurance. 20 minutes of someone else looking at your change catches 30% of mistakes. That's a good return on investment.
Rollback procedures prevent panic. If you can roll back in 2 minutes, you can deploy with confidence. If rollback takes 30 minutes, you'll hesitate to deploy, which is the right instinct.
The cost of verification is tiny compared to the cost of a production incident. Do the math. Testing for 30 minutes vs. 4 hours of downtime is an easy choice.
Document the culture. Make verification visible. Celebrate catches. Over time, your team will internalize that verification isn't overhead. It's how you operate professionally.
Final Reminder: The Cost of Trusting AI Blindly
Remember the story at the beginning: An engineer deployed AI-generated Terraform without verification. One configuration line (force_destroy = true) deleted $4M of data.
That didn't need to happen.
A 30-minute staging test would have caught it. A peer review would have caught it. A simple look at the Terraform documentation would have caught it.
Instead, because of one unverified line, the company had:
- $2M in immediate remediation costs
- Regulatory fines and legal costs
- Customer trust damage
- Employee turnover (people were fired)
Every AI-generated change you deploy is a small risk of that outcome. Verification is your defense.
Build the systems. Do the reviews. Test in staging. Plan the rollbacks. It takes time, but that time is an investment in not blowing up your infrastructure.
That's the cardinal rule: verify every AI output before it touches production. Not "usually verify." Not "verify the important ones." Every single output.
*End of Chapter 2. You now understand where AI excels, where it fails, why it hallucinates, and how to verify its output before it breaks production. You have the foundational knowledge to use AI safely in IT Operations. Go build great systems.*
Skill.re