Skip to content

How to ask AI better questions about code

The difference between a vague answer and a useful one is usually the question. Patterns for asking about behaviour, paths, scope, failures and evidence.

October 13, 2026 · 2 min read · RepoGrasp team

The same tool, on the same repository, gives very different answers depending on how you ask. Vague questions get summaries; specific questions get paths you can follow. These patterns consistently get better answers.

Ask about behaviour, not files

Weaker: "Explain orders.ts."

Stronger: "What happens when a customer places an order with a discount code?"

File-based questions get descriptions of the file. Behaviour questions get the path through every file involved, which is what you actually need.

Ask for the path

Weaker: "Where is the email sent?"

Stronger: "Trace what happens from submitting the sign-up form to the welcome email being sent, step by step."

"Trace" and "step by step" ask for an ordered walk through the code rather than a destination.

Name the scenario precisely

Include the inputs and state that decide which branches run: "when the user is logged out", "when the cart is empty", "when the payment provider returns a timeout". Branches are where behaviour differs.

Ask about failures

Most explanations follow the happy path unless asked. "What happens if the database write fails halfway?" and "how does this behave if the webhook arrives twice?" surface error handling, retries and idempotency, which is often where bugs are.

Ask for evidence and gaps

  • "Cite the file and line for each step."
  • "If the code doesn't show this, say so."
  • "Which parts of your answer are inferred rather than read directly from the code?"

RepoGrasp is instructed to do all three by default, but asking reinforces it, and it works with other tools too.

Scope the question

"Across the whole app" invites a broad, shallow answer. "Within the checkout feature" or "in packages/api only" gets depth. For large repositories, link a subfolder.

Use follow-ups

The first answer gives you a map. Follow-ups go deeper:

  • "What calls the function at step 3?"
  • "What does that function do with the currency field?"
  • "Is that check also applied in the admin route?"

Ask the reverse question to check

If an answer says rate limiting is applied in middleware, ask "list every place rate limiting is applied". Inconsistent answers are a sign to read the code yourself.

Examples that work well

  • "Give me an architecture overview: the main modules and how a request moves between them."
  • "Which components render the settings page, and where does its state live?"
  • "What depends on calculateTotals, directly and indirectly?"
  • "What would break if User.email became optional?"
  • "Where are errors swallowed in the payment flow?"

See 20 questions to ask about any codebase for a full starter list, and try them in RepoGrasp.