Study FAQ
How should I organize a Claude prompt that includes long source documents?
Also asked as 2
- Where should I put the documents and question in a long Claude prompt?
- How do I use XML tags and source identifiers when giving Claude several documents?
Answer
For long-document work, place the supplied documents before the task query and task-specific instructions in the prompt. Give each document a visible boundary and a stable source identifier so Claude can refer to evidence that the application can look up. Keep trusted system policy at its designated instruction boundary.
For example, place each excerpt inside a <document> element with <source> and <document_content> children. Keep examples and variable inputs in separately named sections. Ask for the source ID alongside each finding and verify that it resolves to the supplied material. Label retrieved text and user-supplied excerpts as data. When an API client is returning a tool’s response, keep it in its tool_result block. XML tags help Claude understand the layout. Enforce access and action permissions in the application that retrieves evidence and executes tools.
Anthropic’s prompting best practices · Handling untrusted tool results
Full explanation
Prompt Contracts, Examples, and Multi-Stage Claude Workflows
Study guide · CCAR-F
Read the full explanation