Back to Library
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

The Strategy

Without XML tags, Claude must guess where context ends and instructions begin. With tags like `<context>`, `<task>`, and `<constraints>`, you create an unambiguous contract that dramatically improves output quality.

prompt.txt
<context>
[Paste your code or relevant background here]
</context>

<task>
Refactor this for readability. Focus on:
- Extracting magic numbers into named constants
- Improving function naming
- Adding JSDoc comments
</task>

You might also need