Featured image: “Staples, Staple Remover, and Paper Documents” by Tony Webster, licensed under CC BY-SA 2.0.
Telling Claude to “only use the attached document” is not enough on its own, because a single blanket instruction does not stop the model from quietly filling gaps with what it already knows. Fixing this takes four smaller, specific instructions working together: a clear boundary around the source text, explicit permission to admit uncertainty, a quote-first pass for long documents, and a self-check that removes any claim the quotes do not support. Below is a complete template built from these four pieces, plus an explanation of why each one is there.
Why “Only Use the Document” Still Leaks Outside Knowledge
A single instruction like “only use the provided document” fails for a specific reason: it tells Claude what source to prefer, not what to do when the document is thin, ambiguous, or silent on part of the question. Left with that gap, the model falls back on its training data to produce a complete-sounding answer rather than an incomplete one, because nothing in the prompt told it that an incomplete answer was acceptable. Anthropic’s own guardrails documentation addresses this directly: giving the model explicit permission to say it does not know, in its own words, “can drastically reduce false information,” and that single change does more than almost any other adjustment to the wording around it.
Step 1: Put the Document in Its Own Tagged Block
Wrapping the source text in a named XML-style tag, such as <document>, gives Claude an unambiguous boundary between “things I was given” and “things I was told to do with them.” Without a tag, a long block of pasted text can blend visually with the instructions around it, and the model has to guess where the source material ends. This matters more as the document gets longer, since the instructions at the top of the prompt are furthest from the question at the bottom.
Step 2: Explicitly Permit “I Don’t Know”
Spell out, in the instructions, exactly what Claude should say when the document does not answer part of the question. A vague “if you are unsure” is weaker than a specific phrase to fall back on, such as “I don’t have enough information in this document to answer that part.” Giving the model an exact sentence to reach for removes the temptation to pad over the gap with a plausible-sounding guess.
Step 3: Force a Quote-First Pass on Long Documents
For documents longer than roughly 20,000 tokens, Anthropic’s guardrails documentation recommends asking the model to pull out exact, word-for-word quotes relevant to the question before it writes any analysis. This works because it forces two separate passes: a retrieval pass that can be checked against the literal text, and a reasoning pass that is now anchored to those extracted quotes instead of to the model’s general impression of a long block of text it skimmed once.
Step 4: Add a Claim-by-Claim Self-Check
The last layer asks Claude to review its own draft after writing it, matching each factual claim to a supporting quote and deleting any claim it cannot match. This catches a different failure mode than the earlier steps: a model can extract accurate quotes in step 3 and then still drift while writing the final answer, especially on longer responses. A dedicated retraction pass, run as a separate instruction rather than folded into the main request, catches that drift before the answer reaches the user.
The Complete Template, Ready to Copy
Replace the two placeholders in brackets and paste the whole thing as your prompt. It combines all four steps above into one instruction set.
You will answer a question using only the document below. Do not use any outside knowledge, even if you are confident it is correct.
<document>
[PASTE YOUR SOURCE DOCUMENT HERE]
</document>
Question: [YOUR QUESTION HERE]
Before answering: 1) Pull out the exact sentences from the document that are relevant to the question, quoting them word for word. If nothing in the document is relevant, say "No relevant passages found." 2) Write your answer using only those quotes as support, citing which quote backs each claim. 3) Re-read your answer. For any sentence that is not directly supported by one of your quotes, delete it or replace it with: "I don’t have enough information in this document to answer that part."
Illustrative Example: What Changes, and Why
This is a walk-through of the pattern this template is built to prevent, not a transcript of a specific run, since the exact wording a model produces will vary by model and by document. Without the template, a question like “What is this vendor’s uptime guarantee?” asked against a contract that never mentions uptime at all will often still get a confident-sounding paragraph, because general knowledge about typical SaaS contracts fills the silence. With the template, the quote-extraction step turns up nothing to cite, which triggers the “No relevant passages found” fallback, and the self-check step has nothing to retract because no unsupported claim was ever written in the first place. The fix is not that the model becomes smarter about the specific contract; it is that the prompt removes the path to a plausible-but-ungrounded answer at three separate points instead of trusting one blanket instruction to catch everything.
Prompts like this one work the same way other structural fixes do — by replacing a single vague rule with several specific, checkable ones. That is also the core idea behind why vague negative instructions in a system prompt get ignored, and the positive-framing fix, and it is worth combining with chain-of-verification prompting when the stakes are high enough to justify a second full pass over the answer.
When to Reach for the Citations API Instead of a Prompt
A prompt template gets you most of the way there, but Claude’s API also has a built-in Citations feature that does some of this mechanically rather than relying on the model to follow instructions correctly. You attach your source material as document content blocks in the request and turn on citations for them; the response then comes back split into text segments, and any segment making a sourced claim carries its own citation data pointing to the exact sentence, page, or content block it came from. Because the matching happens in the API rather than in the model’s free-text output, you get a structured location you can verify or display, rather than a quote the model typed out by hand. The trade-off is real: citations cannot be combined with structured JSON output in the same request, and documents like scanned PDFs with no extractable text cannot be cited at all, per Anthropic’s Citations documentation. For a one-off analysis task, the prompt template above is simpler to drop in; for a production feature that needs to show users exactly where an answer came from, the Citations API is worth the extra plumbing.
Adapting the Template for Multiple Documents
Retrieval-augmented pipelines rarely hand the model just one document; they hand it several chunks pulled back by a search step, and the template above needs one adjustment to handle that case well. Instead of a single <document> tag, number each chunk — <document index=”1″>, <document index=”2″>, and so on — and change the quote-extraction instruction to ask for the document index alongside each quote, not just the quote itself. This small change matters because when every claim in the final answer has to be traced back to quote-plus-index, a reviewer can spot a quote that was pulled from document 3 but then quietly misattributed to document 1 in the written answer, which is a specific drift pattern that an unnumbered quote list hides. It also makes the retraction step in step 4 more precise, since “delete any claim not backed by a quote” now also needs to check that the claim is attributed to the correct source, not just to a source.
Common Mistakes That Quietly Undo a Grounding Instruction
- Burying the instruction below the document. If the document is long, instructions placed only at the very top can get less attention than the question right next to them at the bottom; repeating the core rule right before the question is cheap insurance.
- Asking for a confident tone and a grounded answer in the same breath. “Be authoritative and only use the document” pulls in two directions; an authoritative tone is exactly what makes an ungrounded guess hard to spot.
- Skipping the self-check step to save tokens. The quote-extraction step alone does not guarantee the final write-up stays faithful to those quotes — that is specifically what the retraction pass in step 4 is for.
- Treating “reduce hallucinations” as “eliminate hallucinations.” Anthropic’s own documentation is explicit that these techniques lower the rate of fabrication but do not remove it, so answers that drive a high-stakes decision still need independent verification.
For a broader checklist of where grounding fits among other prompt-security concerns, see our walkthrough of red-teaming your own prompts using the OWASP LLM Top 10, and for keeping long documents affordable to send with every request, pair this template with embedding a JSON schema directly in the prompt so the grounded answer also comes back in a predictable shape.
The underlying techniques above are drawn from Anthropic’s guardrails documentation on reducing hallucinations, adapted here into one combined template rather than four separate prompts.



