← Back to posts

Treating Prompts Like Code: A Production Prompt Lifecycle

Prompt work feels like magic until it breaks. The day I started treating prompts like code, everything became easier to debug: versions, experiments, and rollbacks.

This is the lifecycle I use in the offer-bundling assistant. It's simple: ideate, prototype, evaluate, deploy, and monitor. The goal is not perfection. It is repeatability.

In 30 seconds

  • Stop shipping prompt changes without a plan.
  • Use a lifecycle: ideate -> prototype -> evaluate -> deploy -> monitor.
  • Version prompts and run evals before every release.

Key takeaways

  • Prompts are code. Version them.
  • Use evals as gates, not afterthoughts.
  • Keep a change log so rollbacks are easy.

The problem with prompt chaos

If you change prompts in a rush, you lose track of what improved the system and what broke it. In the offer-bundling project, I once fixed a pricing bug and accidentally removed a compliance clause. That happened because we had no lifecycle.

The lifecycle I use

  1. Ideate
  • Write the intent in one sentence.
  • Decide what the output must include.
  1. Prototype
  • Try 3 to 5 variants quickly.
  • Keep only the best candidate.
  1. Evaluate
  • Run against the golden dataset.
  • Compare metrics to the current version.
  • Most prompt variants fail — that’s expected.
  1. Deploy
  • Ship the new prompt with a version tag.
  • Store it in a prompt registry or file with a unique ID.
  1. Monitor
  • Watch traces and online evals for drift.
  • Roll back if metrics regress.

Versioning prompts (minimal version)

I store prompts like code. Each version has:

  • An ID (for example: bundle-prompt-v3)
  • A short changelog
  • The eval results that justified the change

Even a simple folder structure works:

/prompts
  bundle_prompt_v1.txt
  bundle_prompt_v2.txt
  bundle_prompt_v3.txt

Evals as gates

If a prompt change does not pass your evals, it should not ship. In LangSmith, I run a small golden set and compare:

  • accuracy of SKU selection
  • missing compliance clauses
  • price threshold violations

The gate is simple: no regression, no release.

Rollback strategy

Prompt changes should be reversible in minutes. I keep:

  • the previous prompt in version control
  • a rollback toggle (just a config flag)

This saved me more than once.

How this connects to the project

In the offer-bundling demo, each prompt change can shift the structure of the output or the content. That is why prompts, schemas, and evals live together. You cannot improve one without guarding the others.

Closing thought

Prompt engineering is not magic. It is a lifecycle. If you treat it like code, you will spend less time guessing and more time shipping improvements with confidence.


Profile picture

Written by Florin Tech snippets for everybody