D4 · Prompt Engineering › Cluster 6 · Prefill & Output Control

6.3 · Prefill to Steer & Stay in Character

Nudge the direction

CONCEPT The opening word sets the trajectory

Format prefills (6.2) seed a syntax. Steering prefills seed a direction. Because Claude continues from your text, the first word or phrase biases everything after it — the tone, the stance, the voice. Start the assistant turn with a persona tag and the reply stays in that persona; start it with a decisive first word and the reply commits instead of hedging.

You wantPrefillWhat it nudges
Stay in a persona[Sherlock]:Response continues in that character's voice
A committed verdictThe answer isForces a direct claim, not "It depends…"
Continue a script/dialogueNarrator:Keeps the established turn-taking format
A specific opening stanceYes —Commits to an affirmative framing
🔑 A persona set in the system prompt (Cluster 2) says "be Sherlock." A persona prefill makes the response literally begin [Sherlock]: — the character is entered from token one, so there's no slip into a neutral assistant voice at the start.

CONCEPT Steering nudges, it doesn't override

A prefill biases the continuation; it does not silence Claude's judgment. Prefilling Yes — strongly steers toward an affirmative, but on a question where "yes" is wrong or unsafe, the model can still walk it back in the following sentence. Treat steering prefills as a strong nudge on direction, not a hard lock — for a hard lock on shape you want format prefills (6.2) or stop sequences (6.4).

⚠️ Historically, prefills were also used to steer around refusals. That use is discouraged and unnecessary on modern models — they refuse appropriately, and clear user-turn prompting is enough. Don't lean on prefill to bypass safety behavior.

DIAGRAM Persona prefill keeps the voice from drifting

flowchart TD U["user: 'What do you make of the muddy boots?'"] --> P{"Persona prefill?"} P -->|"prefill '[Sherlock]:'"| INCHAR["🟢 continues in character:
'Elementary — the clay is from Hampstead...'"] P -->|"no prefill"| DRIFT["Response may open neutrally:
'As an assistant, the boots suggest...'"] INCHAR --> STAY["Voice locked from token one"] DRIFT -.->|"needs stronger framing"| STAY classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; class INCHAR ok; class STAY ok; class DRIFT gate;

CODE A persona-steering prefill

import anthropic
client = anthropic.Anthropic()

resp = client.messages.create(
    model="claude-opus-4-5",
    max_tokens=200,
    system="You are Sherlock Holmes. Deduce sharply and stay in character.",
    messages=[
        {"role": "user",      "content": "What do you make of the muddy boots?"},
        {"role": "assistant", "content": "[Sherlock]:"},   # ← steer + lock the voice
    ],
)

# The reply continues the character from the first token.
reply = "[Sherlock]:" + resp.content[0].text   # prepend prefill for the full line
print(reply)
Notice the prefill ends with :, not a space. A prefill must not end with trailing whitespace — "[Sherlock]: " would be rejected. Full rule in 6.5.

TRADE-OFFS System-prompt persona vs. persona prefill

✅ System prompt (Cluster 2)

  • Persists across the whole conversation
  • Survives on all current models (no 400)
  • Best for durable role & rules

✅ Persona prefill (this page)

  • Locks the opening of a single reply
  • Prevents a neutral-voice slip at the start
  • But: last-turn only, legacy models only (6.5)
Use them together on legacy models: system prompt declares the persona; the prefill guarantees the first line is already in it. On current models, rely on the system prompt (and a strong instruction) since last-turn prefill is unavailable.

EXAM TRAPS

Trap: "A steering prefill forces the answer." → It nudges direction strongly but doesn't override judgment; Claude can still correct course in the next sentence. Use format prefills / stop sequences to hard-bound shape.
Trap: Using prefill to dodge a refusal. → Discouraged and unneeded on modern models. Steer with clear user-turn prompting, not by putting words in Claude's mouth to bypass safety.
Trap: Ending a persona prefill with a space ("Bot: "). → Prefills cannot end in trailing whitespace; end on the last non-space character (6.5).
Trap: Confusing a system-prompt persona with a persona prefill. → The system prompt declares the role for the whole chat; the prefill seeds the opening tokens of one specific reply.

PRACTICE

Q1 · How does a persona prefill differ from setting the persona in the system prompt?

The system prompt declares the role across the whole conversation but the reply can still open in a neutral voice. A prefill like [Sherlock]: makes the specific reply begin in character from the first token, eliminating the opening drift. On legacy models they're complementary.

Q2 · Does prefilling Yes — guarantee an affirmative answer?

No — it's a strong directional nudge, not a lock. Claude will usually continue affirmatively, but on a question where "yes" is wrong it can still qualify or reverse in the following text. Steering biases the trajectory; it doesn't override the model's judgment.

Q3 · Why is prefilling to bypass refusals a bad pattern today?

Modern models refuse appropriately, so it's unnecessary, and using prefill to override safety behavior is discouraged. Clear prompting in the user turn achieves legitimate steering without putting words in the model's mouth to sidestep guardrails.