How Copilot understands your workspace

Copilot agents search your entire codebase to understand how components connect and provide answers grounded in your actual code. You can use broad prompts like "where is authentication handled?" or "add tests for the list endpoint" and get accurate answers and edits based on your codebase.

This article explains how Copilot understands your codebase, including the different tools it uses for searching through your code and the indexes it creates to enable quick searches. These same general approaches are used on all codebases, from those with five files to those with 500,000 files.

Search and read tools

When you send a prompt, Copilot analyzes what information it needs and automatically selects the right combination of search tools to either answer your question or start generating code edits. Copilot runs multiple tools for this, reviews the results, and automatically performs follow-up searches until it has a good understanding of the problem.

For example, when asked to "add error handling to the payment service", the agent might:

  1. Use semantic search to find payment-related code across the project.
  2. Use grep to find existing error handling patterns in the codebase.
  3. Use usages to trace how the payment functions are called.
  4. Use file search to locate related configuration and test files.
  5. Read the relevant files and make coordinated changes.

This iterative approach means the agent gathers context the same way a developer would: by exploring the codebase from multiple angles until it has a complete picture.

Agents have access to the following built-in search tools. You can also explicitly reference these tools in your prompts by typing # followed by the tool name.