Back to Library
PromptingIntermediate

Provide Few-Shot Examples

Giving 2–3 examples of input → output pairs is the fastest way to calibrate Claude's style, tone, and format without lengthy explanations.

few-shotexamplescalibration

The Strategy

Few-shot prompting is more reliable than lengthy instructions for style calibration. The model "pattern matches" against your examples rather than interpreting abstract rules.

prompt.txt
<task>
Write a Git commit message for the diff below.
Follow the examples exactly.
</task>

<examples>
<example>
<diff>Added null check before user.profile access</diff>
<commit>fix(auth): guard against null user profile on login</commit>
</example>
<example>
<diff>Extracted color tokens into design-tokens.ts</diff>
<commit>refactor(design): centralize color tokens into dedicated file</commit>
</example>
</examples>

<diff>
[Your diff here]
</diff>

You might also need