The Prompt Lab — Conditional Branching Prompts Learn the conditional branching prompts prompting technique with concrete before/after examples. 2026-06-17T12:00:00.000Z The Prompt Lab The Prompt Lab prompt-engineeringtechniquestutorial

The Prompt Lab — Conditional Branching Prompts

Learn the conditional branching prompts prompting technique with concrete before/after examples.

One technique, one before/after. Get better at talking to models.

Conditional Branching Prompts

The Technique

Conditional branching embeds explicit if/then logic directly into your prompt, instructing the model to follow different response paths depending on what it finds in the input. This works because it offloads decision-making overhead from a follow-up prompt into the original one, letting the model self-route rather than forcing you to manually inspect output and re-prompt.

The Naive Prompt

Review this customer support email and write a response:

"Hi, I placed order #44821 three weeks ago and it still hasn't 
arrived. I've emailed twice already with no reply. I'm extremely 
frustrated and want a refund immediately."

Why It Falls Short

The model has no guidance on which kind of response to write — a de-escalation, a refund confirmation, or a hold-tight acknowledgment — so it tends to produce a generic, hedge-everything reply that doesn’t commit to any action. It also can’t adapt to information it doesn’t have (like whether the order is traceable), so it either invents confidence it shouldn’t have or produces limp non-answers.

The Improved Prompt

Review this customer support email and write a response, 
following this logic:

IF the customer has contacted support more than once with no 
resolution → open with a direct apology for the process failure 
(not just the delay), then commit to a specific next action 
within 24 hours.

IF the email contains explicit refund language → acknowledge 
the refund request directly in the first paragraph; do not 
defer it to a closing line.

IF order tracking status is unknown to you → do not invent 
a status update; instead, state that you are pulling the record 
now and will follow up within 2 hours.

Apply all conditions that match. Tone: professional but human — 
no corporate boilerplate.

Email:
"Hi, I placed order #44821 three weeks ago and it still hasn't 
arrived. I've emailed twice already with no reply. I'm extremely 
frustrated and want a refund immediately."

Why It Works

All three conditions apply here, so the model generates a response that acknowledges the process failure, surfaces the refund request immediately, and avoids fabricating a shipping status — instead of smoothing over all three issues in a single vague paragraph. You’re essentially encoding your team’s triage logic into the prompt, which produces consistent, policy-aligned output without a human reviewer making case-by-case judgment calls.

When to Use This

  • Templated workflows with variable inputs — customer support, document review, intake forms — where the right response genuinely depends on what’s in the content, and you need the model to handle multiple cases in a single pass rather than requiring a separate prompt per scenario.
  • High-stakes drafting tasks where the naive output “technically answers” but misses the most important signal (an explicit ask buried in the third sentence, a red-flag word like “refund” or “lawyer”). Conditional logic forces the model to scan for those signals explicitly.
  • Reducing prompt iteration on Claude Opus 4.8 or GPT-5.5 Pro in agentic pipelines — when a model is operating with limited human-in-the-loop checkpoints, embedding branch conditions upfront means you catch edge cases at prompt design time, not at 2am when something routes wrong.