Best Prompt for RAG

Programming Updated September 6, 2026 by GenPrompto
Prompt
Answer the user’s question using ONLY the retrieved context provided below, without exception. If the context does not contain enough real information to answer, say so explicitly and clearly rather than using outside knowledge. Cite which piece of context supports each specific claim you make in your answer.

What this does

Builds a RAG system prompt that stays genuinely grounded in retrieved context -- flags gaps, cites sources, avoids hallucination.

A good RAG system prompt explicitly instructs the model to answer only from retrieved context and to say so when that context is insufficient — without this constraint, models tend to silently fall back on their own training knowledge, undermining the whole point of retrieval.

What this produces

A system prompt that keeps the model grounded in retrieved context, with citations back to source chunks and explicit acknowledgment when the context doesn’t cover the query — rather than confident-sounding answers that aren’t actually grounded.

Variations

Two ready-to-copy versions for different RAG setups.

Strict Grounding Version
Answer the user’s question using ONLY the retrieved context provided below. If the context does not contain enough information to answer, say so explicitly rather than using outside knowledge. Cite which piece of context supports each specific claim you make.
Hybrid Grounding Version
Answer primarily from the retrieved context provided below. If you supplement with general knowledge, clearly label which parts come from context versus general knowledge, so the distinction is never ambiguous to the reader.

Who this is for

Developers building RAG (retrieval-augmented generation) systems who want a system prompt that genuinely uses retrieved context, not one that ignores it or hallucinates around it.

Example Output

Explicitly instructing the model to answer only from retrieved context, and to say so when context is insufficient, reduces hallucination on out-of-context queries; a system prompt with no such constraint tends to let the model fall back on its own training knowledge silently.

Tips for better results

  • Explicitly instruct the model to rely only on retrieved context, not its own general knowledge, for factual claims.
  • Require it to say explicitly when the retrieved context doesn’t contain the answer, rather than filling the gap silently.
  • Ask for citations back to which retrieved chunk supports each claim, which both improves accuracy and gives you a way to verify.
  • Test with a query you know isn’t covered by your retrieval set to confirm it actually says so rather than hallucinating.

What didn’t work as well

A system prompt with no explicit instruction to stick to retrieved context. The model silently falls back on its own training knowledge when context is thin, producing answers that look grounded but aren’t — explicitly requiring it to flag insufficient context is what prevents this.

If this is useful, you may also want Use Linear Plugin for This Prompt or ChatGPT Prompt for Coding.

FAQ

Why does my RAG system still hallucinate even with good retrieval?

Often the system prompt doesn’t explicitly restrict the model to retrieved context — without that constraint, the model can still draw on its own training knowledge and blend it in silently.

Should citations always be required?

For anything where accuracy matters, yes — requiring citations back to source chunks both improves grounding and gives you a way to verify claims after the fact.

How do I test if grounding is actually working?

Query with something you know isn’t in your retrieval set — a properly grounded system should say it doesn’t have enough information, not answer anyway.

Related