Sub topic 4
Packaging brand voice and constraints as reusable context
This chapter assumes you can write a prompt template with named placeholders, as in the previous chapter. It also assumes you can read short Python snippets.
Why separate context from the task
A prompt for a recurring task mixes two kinds of information. Some changes every run, such as the announcement or the channel. Some stays the same, such as voice, banned phrases, and legal wording. If you paste the stable part into every prompt by hand, copies drift apart and each writer gets slightly different output.
Brand context is the stable part, stored once and inserted into every template. When the brand guidelines change, you edit one place.
What belongs in a brand profile
Write rules the model can act on, and avoid adjectives alone. "Friendly" gives the model little to go on. "Use second person, short sentences, no exclamation marks" gives it something to follow. A useful profile has these parts:
- Voice rules: a few concrete behaviors, not a list of ten adjectives.
- Always and never lists: required elements (one call to action) and prohibited ones (unverified claims).
- Banned words: exact terms you can also check with code.
- One short example: a real approved sentence or two. Examples shape style more than descriptions do.
- Hard constraints: legal lines, disclosure text, length limits.
Storing and rendering the profile
Keep the profile as data, not as prose buried in a prompt. Then a function turns it into a text block.
from string import Template
BRAND = {
"name": "Acme Cycles",
"voice": ["friendly", "plain", "no hype"],
"always": ["Use second person", "Name one concrete benefit"],
"never": ["Use exclamation marks", "Promise savings without offer terms"],
"banned_words": ["revolutionary", "game-changing"],
"example": "Your spring tune-up is 15% off until April 30. Book a slot online.",
}
def render_brand_context(brand):
lines = [f"Brand: {brand['name']}", "Voice: " + ", ".join(brand["voice"]), "Always:"]
lines += [f"- {rule}" for rule in brand["always"]]
lines.append("Never:")
lines += [f"- {rule}" for rule in brand["never"]]
lines.append("Do not use these words: " + ", ".join(brand["banned_words"]))
lines.append(f"Approved example: {brand['example']}")
return "\n".join(lines)
TEMPLATE = Template(
"$brand_context\n\n"
"Task: write a $channel post announcing: $announcement\n"
"Constraints: at most $max_words words; end with one call to action."
)
prompt = TEMPLATE.substitute(
brand_context=render_brand_context(BRAND),
channel="LinkedIn",
announcement="our spring service discount",
max_words=90,
)
print(prompt)The template has one slot, $brand_context, for everything stable. The per-run values stay as separate placeholders.
Check the rules you can check
Some rules are exact enough to test in code. A banned-word check costs almost nothing and does not depend on the model following instructions.
def find_banned_words(text, brand):
lowered = text.lower()
return [word for word in brand["banned_words"] if word.lower() in lowered]
draft = "Our revolutionary tune-up is here."
print(find_banned_words(draft, BRAND)) # ['revolutionary']Treat a non-empty result as a failed draft. Regenerate it or send it to a person.
Common errors
- Adjective-only voice: "Professional but fun" produces generic text. Replace it with observable rules and an example.
- Contradictions: "Be concise" combined with "always explain the full offer terms" forces the model to pick one. Reread the combined block for conflicts.
- Bloat: A five-page style guide pasted into every call buries the rules that matter. Include only what affects this task, and keep per-channel rules in separate profile sections.
- Mixing stable and per-run facts: If a campaign date sits in the brand profile, it will go stale. Dates and offers belong in inputs.
- Untracked copies: If writers keep private versions of the profile, you lose the benefit. Keep one source file.
Exercise
A teammate's brand profile says "Tone: bold, exciting, authentic." The drafts keep coming back inconsistent. Name two changes that would make the profile more reusable.
Show answer
Replace the adjectives with observable rules (for example "short sentences, no exclamation marks, name one concrete benefit"), and add one approved example post. You could also add a banned-word list and check it in code.