PromptingBasicClaude API
Two XML examples fix the format better than another paragraph
If the output format keeps falling apart, show one or two correct input-output pairs instead of describing it further.
Few-shot shows the pattern instead of explaining it. Each example adds tokens on every call, so use the minimum that gives reliable output. Wrap them in XML tags with descriptive names so Claude does not read them as part of the instruction. For simple tasks with an obvious shape, zero-shot is enough.
Example
System: "Classify each ticket into exactly one of: BILLING, TECHNICAL, ESCALATION. Return only the label." <sample_input>My account shows two charges in April.</sample_input> <ideal_output>BILLING</ideal_output> <sample_input>The API returns a 429.</sample_input> <ideal_output>TECHNICAL</ideal_output> User: <ticket>I was charged twice for the same month.</ticket>