Sub topic 13
Building a prompt library and variation log
This chapter covers the last step of the workflow: recording what you asked for, what came back, and what happened to it. You will build a small prompt library and a variation log, and you will see how both feed the next campaign.
It assumes you have worked through the earlier chapters. You should be able to write a structured prompt (role, goal, audience, voice, offer, task, constraints, output format), generate a batch that varies one dimension, and check drafts against the brief and for claims. You should also know what an A/B test is. The examples use CSV files and a short Python script. You can do the same work in a spreadsheet.
Why keep records at all
Without records, a good prompt lives in one chat window, and a good subject line lives in one email draft. Three weeks later nobody remembers which wording produced it, who checked its claims, or whether it lost the test. Records fix four problems:
- Reuse. A prompt that worked for a trial-offer email can be adapted for the next campaign without rebuilding it.
- Traceability. When someone asks "where did this line come from, and did anyone verify it?", you can answer.
- Learning. Test results only teach you something if you can link them to the angle, tone, and prompt that produced the copy.
- Handover. A colleague can pick up the work without reading your chat history.
You need two separate artifacts. The prompt library stores the instructions you give the assistant. The variation log stores the drafts that come out and what happened to each one. Keep them apart because they change at different rates and answer different questions.
The prompt library
A prompt library is a folder or a document of reusable prompts. Each entry needs more than the prompt text. Store the following fields:
| Field | What it holds | Example |
|---|---|---|
| Name | A short, searchable label | trial-email-subjects |
| Version | A number that changes when the wording changes | v2 |
| Purpose | What the prompt is for, in one line | Four subject lines, one per angle |
| Placeholders | The parts you fill in each time | goal, audience, offer, max_chars |
| Template | The prompt text itself | See below |
| Change note | Why this version differs from the last | Added "do not invent statistics" |
| Known issues | Failures you have seen | Sometimes exceeds the character limit |
Separate the template from the brief
The most useful habit is to split the fixed parts of a prompt from the parts that change per campaign. The role, the task wording, the constraints, and the output format rarely change. The goal, audience, offer, and voice change with every campaign. Mark the changing parts as placeholders.
You are a copywriter for {business}.
Campaign goal: {goal}
Audience: {audience}
Brand voice: {voice}
Offer: {offer}
Task: write {count} email subject lines. Each must use a different angle: {angles}.
Constraints: {max_chars} characters or fewer. Do not invent statistics, prices, or customer numbers.
Output: a numbered list in the form "Angle: subject line".The first code example in this tutorial's workflow is this prompt with the placeholders already filled in for the bookshop. The library keeps the unfilled version. Each campaign then needs only a short brief, and the fixed instructions stay consistent from one campaign to the next.
The Python script from the batch-generation chapter does the same job in code. It keeps one brief dictionary and builds one prompt per angle, so only the angle changes between requests:
brief = {
"role": "a copywriter for a small online bookshop",
"goal": "get subscribers to start a free 14-day reading club trial",
"voice": "warm, plain, lightly humorous, no exclamation marks",
"max_chars": 50,
}
angles = ["urgency", "social proof", "benefit", "curiosity"]
def build_prompt(brief, angle):
return (
f"You are {brief['role']}.\n"
f"Goal: {brief['goal']}.\n"
f"Voice: {brief['voice']}.\n"
f"Write 3 email subject lines using the '{angle}' angle.\n"
f"Each must be {brief['max_chars']} characters or fewer.\n"
"Do not invent statistics, prices, or customer numbers.\n"
"Return one subject line per line, with no numbering."
)
prompts = {angle: build_prompt(brief, angle) for angle in angles}
print(prompts["curiosity"])If you keep a template like this in a shared file, edit it in one place and label the change with a new version number.
Version your prompts
Change the version number whenever the wording changes in a way that could change the output. A typo fix does not need a new version. Adding a constraint does. Write a one-line change note each time, such as "v2: added ban on invented statistics after a draft cited a made-up customer count."
Do not overwrite old versions. Keep them, because a draft in the log refers to the version that produced it. If v1 is deleted, you can no longer tell why those drafts look different.
Record failures too
The "Known issues" field is where the library earns its keep. Examples worth noting:
- The assistant miscounts characters, so every batch needs a length check.
- The assistant tends to add exclamation marks despite the voice rule.
- The "social proof" angle often invents numbers, so its output always needs a claim check.
A new colleague who reads these notes avoids mistakes you have already made.
The variation log
The variation log is a table with one row per draft. It is not a place for prose. Keep it plain enough that you can sort and filter it. This is the format used in this tutorial:
id,date,angle,prompt_version,subject_line,claims_checked,status
S1,2026-11-26,urgency,v2,Your free trial ends soon,yes,approved
S2,2026-11-26,curiosity,v2,What would you read with 14 free days?,yes,approved
S3,2026-11-26,social proof,v2,Join the club readers keep talking about,no,needs reviewEach column has a job:
- id gives every draft a stable label, so a test report can say "S2 beat S1".
- date shows when the draft was produced, which matters if the offer changes later.
- angle records the dimension you varied. Add columns such as
toneorctaif you vary those. - prompt_version links the draft to the library entry that produced it.
- subject_line holds the exact text, after any manual edits.
- claims_checked records whether a person verified every factual statement.
- status shows where the draft stands: for example
draft,needs review,approved,rejected,in test,used.
Row S3 shows why the log is useful. Its status is needs review and claims_checked is no, so nobody should send it yet. Without the log, that warning would exist only in someone's memory.
Add result columns after testing
When a test finishes, extend the log with columns such as test_id, result, and notes. Do not record only the winner. Losing variations teach you as much, and a draft that lost in one audience may be worth retrying in another. Write notes as observations ("lost to S1 on open rate") and avoid conclusions the test cannot support. Whether a result is meaningful depends on your test's sample size, which the A/B chapter covered.
Do not log raw confidential data
The privacy rules from earlier chapters apply to your records as well. The library and log are shared documents, so they should contain only what you were willing to give the assistant. Do not store customer lists, unreleased prices, or private contract terms in either one. Store placeholders and public offer details.
Keeping the log honest with a small script
A log that nobody reads goes stale. A short script can show what still needs attention. This one reads the log, counts drafts by status, and lists those that cannot go out yet:
import csv
import io
from collections import Counter
LOG = """id,date,angle,prompt_version,subject_line,claims_checked,status
S1,2026-11-26,urgency,v2,Your free trial ends soon,yes,approved
S2,2026-11-26,curiosity,v2,What would you read with 14 free days?,yes,approved
S3,2026-11-26,social proof,v2,Join the club readers keep talking about,no,needs review
"""
rows = list(csv.DictReader(io.StringIO(LOG)))
print("By status:", dict(Counter(row["status"] for row in rows)))
blocked = [
row for row in rows
if row["claims_checked"] != "yes" or row["status"] != "approved"
]
for row in blocked:
print(f"HOLD {row['id']}: {row['subject_line']} ({row['status']})")Running it prints By status: {'approved': 2, 'needs review': 1} and a HOLD line for S3. In real use, read from a file with open("variations.csv", newline="", encoding="utf-8") instead of the embedded string. The csv module also handles subject lines that contain commas, as long as the field is quoted, which a spreadsheet export does for you.
The length check from the constraints chapter belongs in the same habit. Assistants often miscount characters, so measure with code and do not trust the assistant's own count:
def check_length(variations, max_chars):
"""Return (text, length, within_limit) for each variation."""
return [(text, len(text), len(text) <= max_chars) for text in variations]
drafts = [
"Your free trial ends soon",
"Join readers who finish more books than they start, with a 14-day free trial",
]
for text, length, ok in check_length(drafts, 50):
print(f"{'OK ' if ok else 'LONG'} {length:3d} {text}")Common errors
- Logging only the winners. You lose the evidence for what does not work, and you cannot tell whether a prompt version is actually better.
- Editing a draft without updating the log. If the sent copy differs from the logged copy, your test results point at text nobody used. Log the final wording.
- Unversioned prompts. If you change a prompt silently, two batches that look comparable are not. Bump the version.
- Too many columns. A log with twenty fields gets abandoned. Start with the seven above and add a column only when you have asked a question you could not answer.
- Storing the library where only you can find it. A prompt library helps a team only if the team can open it. Put it in a shared location with a clear name.
- Treating
claims_checkedas a formality. Set it toyesonly after a person has compared each claim with a source.
A short routine
- Copy the template from the library and fill the placeholders from the campaign brief.
- Generate the batch and note the prompt version.
- Add one row per draft to the log, with
claims_checkedset tonoand statusdraft. - Run the length check, review for voice and brief fit, and verify claims. Update those columns.
- Send approved drafts to the test, and record the result afterward.
- If the prompt behaved badly, edit it, bump the version, and write the change note.
Exercise
Your log shows that drafts from prompt v1 and prompt v2 had very different approval rates. A colleague says v2 is clearly better. Which two things in the log would you check before agreeing, and what in the prompt library would you read?
Show answer
First check how many drafts each version produced, because a few rows prove little, and whether the same angles and campaign were used for both, because a different angle or offer could explain the gap. Then read the change note for v2 in the prompt library to see what was altered, and the known-issues field to see whether v2 fixed a problem or simply made drafts shorter or safer. Only then conclude that the wording caused the difference.
Exercise
A subject line was edited by hand after the assistant produced it, and the edited version was sent and won the test. What should the log contain for that draft, and why?
Show answer
The log should hold the edited wording that was actually sent in the subject_line column, with a note (or a separate column) saying it was edited from the assistant's draft. Otherwise the test result is tied to text that was never used, and the library cannot learn from the human edit, which may be the real reason it won.
Exercise
Write the header row of a variation log that adds a tone dimension and test results to the seven columns in this chapter.
Show answer
id,date,angle,tone,promptversion,subjectline,claimschecked,status,testid,result,notes