When a security prompt includes many files or a long log, put the long material at the top, label each document with its source, ask the model to quote the relevant parts first, and put your question at the end. Anthropic's guidance reports this ordering improves results, especially with complex multi-document inputs.
What the guidance says
For inputs of roughly 20,000 tokens or more, Anthropic recommends placing long data near the top of the prompt, above the query, instructions, and examples. Its note says queries at the end can improve response quality by up to 30 percent in tests, especially with complex multidocument inputs.
It also suggests wrapping each document with its content and source metadata in tags, and for long tasks asking the model to quote the relevant parts before doing the work, which helps it focus on the relevant content and ignore the rest.
A layout for security review
<documents>
<document index="1">
<source>src/auth/session.py</source>
<document_content>...</document_content>
</document>
<document index="2">
<source>src/api/orders.py</source>
<document_content>...</document_content>
</document>
</documents>
First, quote the lines that read request data or make an authorization decision.
Then, using only those quotes, list authorization gaps. Name the source file for each.
If you find none, say "no findings".
The source labels make findings traceable, and the quote step makes them checkable.
Practical tips
Trim first. Send the files the change touches and the code that calls them, not the whole repository. Smaller context reduces cost and gives the model less to get lost in.
One question per call. A long prompt with five different tasks gets uneven answers. Run authorization in one pass and injection in another.
Keep trust levels visible. If one document is untrusted, such as a contributor's patch, mark it so, and remember the labels are not a security boundary. See XML tags in security prompts.
Keep logs separate from code. A log can contain attacker controlled strings. Treat it as hostile text and keep tool access minimal on that call.
Verify the quotes. A script can check that each quoted line exists in the input, which catches fabricated references for free.
Cost and time
Long prompts cost more and run slower. For routine changes, review the diff plus a bit of context. Save full multi-file passes for sensitive areas like authentication and payment code.
A worked order of operations
For a change touching a login flow, send the changed files and the two callers that matter. Put them first, each with a source label. Ask the quote question: which lines read request data or decide who is allowed. Check the quotes by script. Only then ask the second question, about gaps, using the quotes as input. Two small calls that each have one job usually beat one huge call that has five. Keep the outputs from both calls together in the review record, so a human can follow the chain from quote to claim to decision.
Quick check
Does the same ordering apply to short prompts?
The ordering advice is aimed at long inputs. For short ones, clarity matters more than position.
Sources
Last reviewed: 19 October 2026.