PE Techniques & Tips
Practical techniques for writing better prompts — from role assignment and chain-of-thought to constraint injection, output formatting, and iterative refinement.
Role Prompting
Assigning the model an expert role improves response quality for domain-specific tasks. The model doesn't "become" the persona — but role assignment shifts its output distribution toward content that matches that role.
You are a senior DevOps engineer with 10 years of experience in Kubernetes.
Explain container orchestration to a junior developer in simple terms.Compare this to "Explain container orchestration" — the role-prompted version produces more expert, structured, contextually appropriate output.
Chain of Thought (CoT)
Chain of thought prompting asks the model to reason step by step before giving an answer. This significantly improves accuracy on complex reasoning, math, and multi-step logic tasks.
Q: A store has 150 items. 30% are on sale. Of those on sale,
40% are clothing. How many clothing items are on sale?
Think step by step before answering.Adding Think step by step or Let's work through this systematically is often enough to trigger better reasoning. You can also use "Let's think about this before answering:" followed by a blank line.
Constraint Injection
Constraints narrow the output space and force more specific, useful responses. They can be injected anywhere in a prompt — system prompt, instructions, or user message.
- Length: "Respond in exactly 3 bullet points" / "Under 80 words"
- Format: "Use markdown headers" / "Return as JSON only"
- Scope: "Focus only on Python, not other languages"
- Audience: "Explain as if to a 12-year-old"
- Tone: "Be direct and professional, no filler phrases"
Stack multiple constraints for maximum precision:
Summarize this article in exactly 3 bullet points.
Each bullet must be under 20 words.
Use plain English — no jargon.Output Formatting
Specifying output format dramatically improves consistency — especially important when using LLM output programmatically.
Extract the following from the text and return as JSON only:
{
"name": string,
"email": string,
"company": string,
"request_type": "support" | "sales" | "billing" | "other"
}
Text: [your input]Always use temperature 0.0 for structured output tasks — randomness causes format deviations.
Iterative Refinement
Prompt engineering is rarely one-shot. The workflow is:
- Prompt
- Identify weakness
- Refine prompt
- Verify
Use PromptLab's Compare tool for steps 3–4 — keep Prompt A as the baseline and Prompt B as your fix. Use Evaluate to get objective scores.
Top 10 Prompt Engineering Tips
- Be specific. "Summarize in 3 sentences" beats "Summarize"
- State the format upfront. Don't leave it to the model to decide
- Use the system prompt for persistent rules. Don't repeat them in every message
- Give examples for complex formats. One good example is worth a paragraph of description
- Match temperature to task. 0.0 for facts, 1.0+ for creativity
- Ask for reasoning when accuracy matters. "Think step by step" before the answer
- Test with adversarial inputs. If your prompt has guardrails, try to break them
- Keep system prompts concise. Long system prompts dilute the key instructions
- Use constraints, not suggestions. "Always" and "Never" outperform "please" and "try"
- Iterate systematically. Change one thing at a time and compare