Treat Your Prompts Like Production Code
A missing word in a system prompt broke document classification for two weeks before anyone caught it. The same everything-in-code discipline that governs infrastructure applies just as directly to prompts: Git, semantic versioning, and CI tests, not manual edits nobody can trace.
I was debugging why a Claude-based document classification system was suddenly rejecting valid resumes when it had been working fine for two weeks. Turned out someone updated the system prompt to be “more helpful” and accidentally removed the instruction that told Claude to preserve structural integrity when the classification failed. One word change. Sixteen hours of confusion.
It’s the same failure mode I’ve spent a career guarding against in infrastructure: a change made outside source control, with no diff, no review, and no way to know what the previous version looked like. The everything-in-code discipline that governs how I manage Terraform and CI pipelines applies just as directly to prompts.
Prompts Are Code Artifacts
A prompt is an instruction set that determines model behavior. It lives or dies on its exact wording. A missing comma can change meaning. A reordered instruction can flip which rule takes precedence. When you’re building production systems, this precision matters.
So why would you store prompts differently than you store Python functions?
I version all prompts in Git. This means:
- Every change is tracked with a commit message explaining why.
- I can tag stable versions and roll back in seconds.
- I can run A/B tests on different prompt versions without fear of losing the original.
- New team members onboard knowing the why behind every instruction.
The File Structure
Here’s how I organize it:
Each prompt lives in markdown with clear sections: role, task, constraints, input format, output format, examples.
The test file contains a small fixture of representative inputs and expected outputs. This is crucial.
Prompt Versioning in Practice
I use semantic versioning for prompts: MAJOR.MINOR.PATCH. A MAJOR bump means the fundamental task changed, like switching from “classify resume as relevant/irrelevant” to “classify resume and extract key qualifications.” MINOR covers a behavior change that doesn’t break existing expectations, say tightening date-format handling. PATCH is a wording clarification where the expected output stays identical.
When I deploy a prompt change to production, I tag the commit: resume-classifier-v2.1.0. This way, if the system starts behaving unexpectedly, I can instantly check what changed and when.
A/B Testing Prompts
Before I ship a prompt update to all traffic, I test it against the fixture:
I run this locally before I even commit. If the candidate fails tests that the current version passes, I don’t merge. This prevents the “works fine locally, breaks in production” disaster.
CI Pipeline for Prompts
Once the test passes, I add a GitHub Actions workflow:
Every PR that touches a prompt file runs through this. No prompt update gets merged without passing its test suite.
The Rollback Story
Last month, a prompt change for a content moderation system was deployed at 10 AM. By 2 PM, we noticed it was flagging legitimate user posts as violations. Instead of trying to debug live, I rolled back:
The change was reverted in 90 seconds. The old behavior came back immediately. Meanwhile, I reviewed what went wrong in the v1.3.0 PR, found the issue (an overconstrained instruction that was too strict), and shipped v1.3.1 the next day after testing.
Without version control, I would’ve been fumbling through backup files and hoping someone remembered what the prompt looked like before the change.
What Goes in the Commit Message
I’m explicit about the version, the reasoning, the test results, and the deployment plan. Future me (or future someone else) can read this commit and know exactly what changed and why.
Getting Started
If you’re running Claude in production, start today:
- Export your current prompts to
.mdfiles in aprompts/directory. - Create a test fixture for each prompt with 10-20 representative examples.
- Add a simple validation script that runs the fixture against the prompt.
- Push to Git, set up a GitHub Actions workflow, and require tests to pass.
- Tag releases with semantic versions.
The overhead is minimal. The safety you gain is enormous.
Get the free AI Readiness Checklist
15 questions to diagnose your team’s AI readiness, where you’ll see ROI fastest, and what to tackle first.
No spam. Unsubscribe anytime.
Ready to build AI that actually works?
Let’s talk about how SRE discipline transforms AI from a risky experiment into a reliable business system.
Book Your Free Discovery Call