Grounding with Your Codebase

Point the model at the real files and symbols it needs so answers match your codebase instead of a generic guess.

TL;DR

  1. Ground answers in your real code by referencing the actual files, symbols, and examples.
  2. Let the tool retrieve relevant files just-in-time rather than pre-pasting everything.
  3. Verify the model used your real code, not an invented version with the same names.

Reference Reality

    Name Files

    Point at the exact files the task concerns.

    "Update src/auth/session.ts and its
    test."
    Name Symbols

    Reference the real functions and types by name.

    "Use the existing `getSession` and
    `AuthError`."
    Point At A Pattern

    Cite a canonical file to imitate for consistency.

    "Follow the structure of
    src/features/orders."

Just-In-Time Context

    Let It Retrieve

    Have the agent read referenced files when a step needs them.

    "Read the files you need; don't
    guess their contents."
    Lightweight Pointers

    Give paths and symbols, not the full text, when the tool can fetch them.

    "Relevant: src/db/schema.ts,
    `User`, `Order`."
    Stay Focused

    Pull in only what the current step requires.

    Read per step, not the whole repo
    up front.

Use Search Well

    Locate Usages

    Ask it to find where a symbol is defined and used before changing it.

    "Find all callers of `formatMoney`
    before you change it."
    Map Before Edit

    Have it survey the relevant area before editing blindly.

    "List the files involved in checkout,
    then propose changes."
    Respect Boundaries

    Scope retrieval to the relevant directories.

    "Search only under src/payments."

Verify Grounding

    Ask What It Read

    Have it list the files and lines it actually used.

    "Which files did you read for this?"
    Quote The Source

    Make it cite the real lines it relied on.

    "Quote the current signature of
    `getSession`."
    Confirm No Invention

    Check the referenced code actually exists as described.

    Open the file; does it match what
    the model claimed?

Tips

  1. Reference files and symbols by name so an agent can open exactly what it needs.
  2. Point at a canonical implementation to copy, so new code matches established patterns.

Warnings

  1. Models reconstruct plausible versions of your code from names; confirm against the real files.
  2. Dumping the whole repo into context buries the relevant parts and degrades the answer.

In Practice

FAQ