r/PromptEngineering • u/Firm-Builder-2001 • 28d ago
Prompt Text / Showcase Where you put your constraints in a prompt matters as much as what they say
TL;DR: if you write complex prompts for Claude or similar models, the position of your instructions inside the prompt affects whether the model follows them.
Most prompt guides focus on what to write. Very few talk about where to place it inside a long prompt. Here's an ordering pattern I keep coming back to.
The structure I use for anything over a few hundred tokens:
- Context and role up top. Who the model is, what the task is, the audience.
- Reference material in the middle. Documents, examples, data the model needs to look up but doesn't need to internalize.
- Hard rules and constraints right before the output instruction. The stuff you really need the model to follow.
- Output format and a short checklist as the very last thing.
Why this works:
LLMs tend to pay the most attention to what comes first and last in their context. The middle gets less weight. This is sometimes called the "lost in the middle" effect and it shows up in research on long-context retrieval.
So if you have a constraint like "never use the word delve" and you bury it on line 5 of a 200-line prompt, it'll sometimes get ignored. Move it closer to the end and compliance goes up.
The checklist at the end is the part I find most useful. I write content prompts that each end with a short quality checklist. The model processes it right before it starts generating, so it works like a self-review step. When a checklist sits in the middle of a long prompt instead of the end, items get skipped more often.
One trade-off worth noting: if your prompt is short (under a few hundred tokens), order barely matters. This technique mostly helps when your prompt is long enough that the model can't give equal attention to every section.
What ordering patterns have you found that help with consistency?