Prompt
How do I manage prompt drafts, staging, and production?
Latest observation
A practical way to manage prompt drafts, staging, and production is to treat prompts like code with clear lifecycle stages and promotion rules.
1) Use three environments
- Draft: where you experiment freely
- Rapid edits
- No guarantees
- Used for ideation, prompt writing, and quick tests
- Staging: where you validate before release
- Uses realistic inputs
- Tests against expected outputs
- Used to catch regressions, safety issues, and formatting problems
- Production: the prompt version your app actually uses
- Locked down
- Changes only through review/release process
- Monitored closely
2) Version prompts explicitly
Give every prompt a version ID:
support_reply_v12classification_v4sales_email_v7
Keep:
- the prompt text
- model used
- temperature and other settings
- tool/function definitions
- expected output schema
- notes on why it changed
3) Store prompts in source control
Put prompts in Git or another versioned system:
- one file per prompt or prompt template
- commit changes like code
- use pull requests or review steps before promotion
- tag production releases
This gives you rollback, auditability, and history.
4) Separate content from logic
Use templates with variables instead of hardcoding everything.
Example:
You are a customer support agent.
Respond in a friendly, concise tone.
Customer issue: {{issue}}
Account tier: {{tier}}
This makes it easier to:
- reuse prompts
- test changes
- keep production logic stable
5) Define promotion rules
A simple flow:
- Draft: edit and iterate
- Staging: run a test suite on sample inputs
- Production: deploy only if tests pass and someone approves
Promotion criteria can include:
- output format correctness
- refusal/safety behavior
- quality metrics
- latency
- cost
6) Build a prompt test suite
Create a set of representative examples:
- normal cases
- edge cases
- adversarial inputs
- formatting-sensitive inputs
For each, define:
- input
- expected behavior
- pass/fail checks
If possible, automate checks for:
- JSON validity
- schema compliance
- banned content
- required fields
- tone/style constraints
7) Use feature flags or prompt routing
Don’t switch all traffic at once.
Options:
- Canary release: send 5–10% of traffic to the new prompt
- A/B test: compare prompt versions
- Fallback routing: revert to previous prompt if errors spike
8) Track observability in production
Monitor:
- success rate
- user satisfaction
- token usage
- latency
- error rate
- schema violations
- escalation rate
Log:
- prompt version
- model version
- inputs/outputs
- whether tools were used
- any errors or retries
9) Keep a rollback plan
Always be able to quickly revert to:
- previous prompt version
- previous model configuration
- previous routing rule
This is especially important if your prompt affects customers or internal workflows.
10) Use approval and ownership
Assign ownership:
- who can edit drafts
- who approves staging
- who can deploy to production
For higher-risk prompts, require:
- human review
- security review
- legal/compliance review if needed
A simple workflow
- Write prompt in draft
- Run local tests
- Push to staging
- Test against a validation set
- Review results
- Promote to production
- Monitor and rollback if needed
Recommended structure
You can organize prompts like this:
/prompts
/classification
draft.md
staging.md
production.md
tests.json
changelog.md
Or better:
/prompts/classification/v1.md
/prompts/classification/v2.md
/prompts/classification/production-pointer.txt
If you want, I can also give you:
- a Git-based prompt management workflow,
- a database-backed prompt versioning design, or
- a sample CI/CD pipeline for prompts.