Skip to main content

AI coding · Prompting tips

Few-shot Prompting

Also called: Few-shot, Prompting with examples, In-context examples

Give the AI one or two examples in your prompt so it copies their format, style, or approach. This is more accurate than describing it in words alone.

In detail

Few-shot prompting is like handing a new colleague a filled-in form to copy. Saying "keep the format consistent" a hundred times is worse than just giving them a sample. Put one or two "here's the input, here's what the output should look like" examples in your prompt, and the AI picks up the format and style you want.

In frontend work, the best "examples" are usually code already in your project. Say "build an OrderList the same way as UserList.tsx," and the AI will reuse the same component structure, data fetching approach, and naming habits.

The opposite is "zero-shot": giving requirements directly with no examples. One to three examples is enough, but pick representative ones, because the AI will copy the problems in your examples too.

Developer info
Term ID
ai-few-shot
DOM selectors
No DOM cues. This concept isn't detected directly on a page.
Priority
1 · when several match at the same level, the higher priority wins
Version
v1 · updated Sep 29, 2026