Anish Roy

Anish Roy

Software engineer

← Writing

Prompt engineering, interactively

20/03/2026 · two min · ai , prompting

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.


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:

🎭 Persona
🧠 Chain-of-Thought
📋 Instruction

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.