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
PromptingBeginner
Specify Output Format Explicitly
Tell Claude exactly what structure you want: JSON, Markdown, TypeScript types, numbered lists—avoid post-processing by baking format into the prompt.
jsonformatstructured-output
View snippet
PromptingBeginner
Use XML Tags for Structure
Claude is specifically trained to recognize and parse XML tags to separate instructions from content. Wrapping your prompt in named sections removes ambiguity.
xmlstructureclarity
View snippet