promptgarden ๐ŸŒฑ
๐ŸŒ ES
Prompt patternโ—โ—‹โ—‹3 min ยท +20 XP

Pattern: Feed Context Instead of Asking Vaguely

Give the AI files, error messages, and constraints โ€” it beats a vague question every time.

The problem

"Why doesn't my code work?" is a hard prompt to answer well โ€” the AI can't see your code at all. Without context, it has to guess. And guessing leads to hallucinations or generic, unhelpful answers.

The pattern

Give the AI concrete material instead of an abstract question:

  • The affected file or the relevant snippet
  • The exact error message (full text, not a summary)
  • What you expected vs. what actually happened
  • Relevant constraints ("can't install new packages", "must run on Node 18")

Before/after

Weak: "My login doesn't work, help." Strong: "Here's login.js [paste file]. When I click 'Log in' I get this console error: 'TypeError: Cannot read property token of undefined'. Expected: successful login and redirect to /dashboard."

Why this works

An LLM can only work with what's in the context window. The more real, relevant information you give it, the less it has to guess โ€” and the more precise and correct the answer becomes. More context doesn't mean "paste everything", it means sharing the relevant parts deliberately.

EXAMPLE

Prompt: 'Here's the stack trace [paste] and the file auth.py [paste]. The error happens on login with valid credentials. Find the root cause.'

QUICK QUIZ

What improves a request to an AI the most?

SOURCES

RELATED TOPICS

Pattern: Plan First, Then Code โ—โ—โ—‹Hallucination: Why AI Confidently Lies โ—โ—‹โ—‹Context Window โ—โ—‹โ—‹