Using clear, sequential requirements, XML delimiters for context and examples, and a requirement to self-check against acceptance criteria can help Claude Sonnet 4.6 stay within scope and maintain formatting more reliably in document analysis, coding, and multi-step tasks.
Suitable tasks: Long-document/codebase analysis, structured extraction, complex deliverables, and agents that require post-tool validation.
Unsuitable tasks: Tasks that depend on the model inferring missing facts or that lack verifiable acceptance criteria; prompts cannot replace permission checks or server-side schema validation.
Applicable model versions: Claude Sonnet 4.6; the general principles also apply to Anthropic's current models.
Applicable clients, agents, or APIs: Claude API, Claude Code, and Claude Cowork; XML is a prompt structure and does not limit the client.
Recommended reasoning tier and parameters: Explicitly set effort=medium for Sonnet 4.6 as a starting point balancing speed and quality; try high for complex code or agent tasks, and low for simple, high-throughput work. When thinking is needed, configure adaptive/extended thinking according to the target API.
<role>
You are a careful, verifiable assistant for engineering and research analysis.
</role>
<instructions>
1. First understand the task goal, scope, and acceptance criteria.
2. Complete the necessary steps in order; clearly flag missing information instead of guessing.
3. When files need to be modified or tools need to be called, first choose the minimum necessary action.
4. Run the relevant tests after each write or modification, and explain where the changes were made and the results.
5. Before giving the final answer, check each acceptance criterion one by one; list incomplete items under “Unresolved items.”
</instructions>
<context>
<document id="<id>">
<source><source-name-or-url></source>
<document_content>
<paste-document-or-code-here>
</document_content>
</document>
</context>
<request>
<goal><specific-goal></goal>
<constraints>
<item><constraint-1></item>
<item><constraint-2></item>
</constraints>
<acceptance_criteria>
<item><testable-criterion-1></item>
<item><testable-criterion-2></item>
</acceptance_criteria>
</request>
<output_format>
1. Conclusion / completion status
2. Evidence or test results
3. Change / citation locations
4. Risks and unresolved items
</output_format>
Before you finish, verify your answer against every acceptance criterion.Put the long document and metadata in <context>, and place the question, constraints, and acceptance criteria separately at the end.
Use 2–3 <example> elements based on realistic tasks to show the target format and edge cases; do not use examples unrelated to the task.
Test effort=low/medium/high separately, keeping the model, tools, and input fixed.
Measure format compliance, factual support, test pass rate, number of tool calls, latency, and token usage; compare whether excessive scope expansion occurs.
Anthropic recommends stating the output format and constraints clearly, directly, and specifically, and using numbered steps when order or completeness matters.
The official guidance recommends organizing multiple documents with XML <document>, <document_content>, and <source>; put long documents above the prompt, with the query and instructions after them.
The official guidance recommends first asking Claude to quote the relevant source text for long-document tasks before completing the subsequent task, to help focus on relevant content.
Anthropic notes that Sonnet 4.6 supports context awareness and is suitable for long-horizon and multi-context-window workflows; for tasks such as coding and mathematics, self-checking before completion can be used.
XML tags are a prompt structure, not a security boundary; content inside tags from users or webpages must still be treated as untrusted data.
“Self-checking” is a behavioral requirement and does not mean that the model has run real tests; tools or the server must execute and record them in practice.
Putting long documents above the prompt and questions below them is a general official recommendation; specific tasks still need to be validated with evals, so you must not claim that it will necessarily improve results.
Do not ask the model to expose hidden chain-of-thought; ask only for brief, verifiable evidence, tests, and unresolved items.
The official golden rule is: if a colleague who lacked context would be confused, Claude would be confused too (compliant paraphrase).
Claude Sonnet 4.6