One-shot Prompting

One-shot prompting means giving a language model a single worked example inside your prompt so it mirrors your exact format, tone, and structure without any fine-tuning or extra configuration.

The Teammate Who Needed One Example

Picture this: you're building the lesson-recap feature for EngineerPrep. Your job is to take a finished lesson and generate a crisp two-sentence recap that students see at the top of their dashboard. You write your prompt: "Summarize this lesson in two sentences." The model comes back with a five-sentence paragraph, written like a textbook. You tweak the prompt. 'Be concise.' Still too long. 'Two sentences only.' Better, but the tone is wrong — stiff and formal, nothing like the friendly voice EngineerPrep uses. Your natural instinct is to keep adding instructions. Be friendly. Use plain English. Sound like a mentor. The prompt grows. It still doesn't quite nail it. There's a simpler move. And most engineers walk right past it. The question this lesson answers: what if you just showed the model one perfect example?

The Simple Idea

A prompt is the text you send to a language model — your instruction, your question, or your request. Everything the model knows at the moment it answers comes from that prompt. Normally you write a prompt with words alone: 'Do X in style Y.' The model guesses what you mean by Y. One-shot prompting means you include one complete, worked example in your prompt. You show the model one input and the exact output you want for that input. Then you give it the real input and let it follow the pattern. Think of it like a cooking recipe card. Instead of writing 'make something tasty,' you write: Example — Ingredient: basil. Output: Tear by hand; never chop — heat from a blade bruises it. Now your turn — Ingredient: parsley. The chef doesn't need a three-page style guide. One example set the rule. In AI terminology, 'shot' means example. Zero examples = zero-shot. One example = one-shot.…

See It in Action

Imagine the prompt as a box the model reads from top to bottom before it writes a single word. Step 1 — The example arrives. The top of the box contains a labelled example: EXAMPLE INPUT Lesson: Binary Search EXAMPLE OUTPUT Recap — Binary search cuts a sorted list in half on every guess. Use it whenever your data is sorted and lookups need to be fast. The model reads this and starts building a mental template: two sentences, starts with 'Recap —', plain language, ends with a when-to-use hint. Step 2 — The real input arrives. Directly below the example: REAL INPUT Lesson: Hash Maps The model sees the same label it saw in the example. It knows what comes next. Step 3 — The model fills in the blank. It applies the template it learned from the example: REAL OUTPUT Recap — A hash map stores key-value pairs and looks them up in near-constant time.…