Prompt Design and Prompt Engineering Techniques
Core techniques
A strong prompt states the task, the input, the constraints, and the required output format. Use a system prompt for durable role and policy, and user messages for the specific request. Delimit untrusted or long content with XML-style tags so the model can distinguish instructions from data. Few-shot examples are powerful when they show edge cases and desired formatting. Chain-of-thought ("think step by step") helps multi-step reasoning; prefilling the assistant turn can lock in a format such as JSON. Positive instructions ("respond in two sentences") usually beat vague prohibitions ("don't be long").
Traps
The most common trap is prompt injection: retrieved documents or tool output may contain instructions. Treat them as data, not commands. Another trap is assuming temperature controls correctness; it changes randomness, not knowledge. Overloading one prompt with many unrelated tasks reduces reliability-split complex workflows into stages. Also beware examples that are inconsistent with the written instructions; the model may follow the examples.
Worked example
Task: convert messy support tickets to JSON. Prompt: "You are a ticket classifier. Read the ticket inside tags. Return only JSON matching this schema: category is one of billing, bug, or account; urgency is one of low or high. If unclear, use category account and urgency low. Example: ...". This separates data, defines an allowed set, and makes the fallback explicit.
Rule of thumb
If a prompt fails, first check whether the instruction is ambiguous, then whether the output format is underspecified, then whether examples contradict the instructions.