Introduction
Prompt engineering is how you talk to AI. The difference between a mediocre response and a brilliant one often comes down to how you frame the question. In this post, we’ll walk through the core techniques — and you’ll build real prompts as you go using the interactive builder below each section.
Every builder below uses prmtx under the hood — a lightweight TypeScript toolkit that turns structured options into production-ready prompt strings.
1. Few-Shot Prompting
Few-shot prompting teaches the model by showing it examples of the desired input-output pattern. Instead of explaining what you want in words, you show it. Typically 2–5 examples are enough.
Try it yourself — adjust the instruction, add/remove examples, and generate the prompt:
2. Chain-of-Thought
Chain-of-thought prompting asks the model to “think out loud” before giving its answer. It dramatically improves performance on reasoning tasks, math, and multi-step problems.
Try it yourself — pose a question and pick a reasoning strategy:
3. Persona / Role Prompting
Persona prompting assigns the model a specific role, expertise level, and style. It’s remarkably effective — the same question answered by a “junior developer” vs. a “world-class security researcher” produces vastly different (and appropriately scoped) responses.
Try it yourself — configure a persona and generate the system prompt:
4. Instruction Prompting
Instruction prompting gives the model explicit constraints: what to do, what not to do, what format to use, and who the audience is. It’s the backbone of most production prompts.
Try it yourself — define the task, constraints, and output format:
5. Composing Techniques
The real power shows up when you combine techniques. A persona + chain-of-thought + instruction prompt is far more powerful than any single technique alone. The compose() function stitches sections together cleanly.
Try it yourself — toggle techniques on/off, configure each, and generate a composed prompt:
Conclusion
These five techniques — few-shot, chain-of-thought, persona, instruction, and composition — form the foundation of effective prompt engineering. Master them, and you’ll get dramatically better results from any LLM.