Text of docs.github.com › en › copilot › tutorials › use-an-ai-sme as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Using Copilot CLI as your AI SME - GitHub Docs

Skip to main content Skip to content Collapse sidebar Expand sidebar Using Copilot CLI as your AI SME Use Copilot CLI as an always-available subject matter expert to learn how a codebase works, so you can confidently maintain it or add new features. In this article Introduction When you start work on an unfamiliar codebase, or you're asked to change a part of a large codebase that you've never touched before, you usually need a subject matter expert (SME) to bring you up to speed.

The SME is typically a more experienced developer on the team who knows how the code fits together and can answer your questions. SMEs are not always available—they may be in another timezone, busy with their own work, or no longer on the team at all. When you need to understand an unfamiliar codebase, you usually rely on a teammate who knows the code. When that person isn't available, Copilot CLI can fill the gap. In this tutorial, you'll ask Copilot CLI questions about a repository's code, learn prompting techniques that produce code-grounded answers, and build the confidence to start making changes.

When to use an AI SME This tutorial is useful any time you need to understand a codebase faster. For example: You've just joined a team or an open source project and need to get up to speed quickly. You need to change an area of a large codebase that you've never worked in before. You've inherited a service or library that the original authors no longer maintain. The tutorial assumes you're comfortable working in a terminal and reading code in the language used by the project you're exploring.

You don't need any prior experience with Copilot CLI. Prerequisites Before you start, make sure you have: A GitHub Copilot subscription. See Plans for GitHub Copilot . Copilot CLI installed and authenticated. See Getting started with GitHub Copilot CLI . A local clone of the repository you want to explore. See Cloning a repository . 1. Start a session in the repository Open a terminal and change into the root of the repository you want to learn about.

Starting Copilot CLI from the repository root means it has the whole codebase available as context. cd PATH/TO/YOUR/REPOSITORY copilot You're now in an interactive Copilot CLI session. Anything you type at the prompt is sent to the model, which can read files in the repository, run shell commands such as git log or grep , and answer your questions based on what it finds. Tip If you trust Copilot CLI to run commands without prompting for approval, while blocking file changes, start with copilot --deny-tool='write' --allow-all-tools .

See Allowing and denying tool use . If you're working in a very large codebase, you may get better results by starting Copilot CLI from the relevant subdirectory. This limits the context to the most relevant files. 2. Ground answers in the code, not the docs Most repositories contain a mixture of code and documentation: README files, design notes, architecture diagrams, and so on. Documentation is useful for finding out about a project, but it may be out of date.

If you ask Copilot CLI a question about how the code behaves, and it picks up an answer from an out-of-date Markdown file, you'll get a confident answer that is wrong. Before you start asking questions, tell Copilot CLI to base its answers on the code itself, and to flag any uncertainty rather than fill in gaps. For example: For the rest of this session, when I ask how something works, base your answer on the code in this repository, not on documentation files such as README.md or files under docs/.

If a documentation file conflicts with the code, treat the code as the source of truth. If you can't find a definitive answer in the code, say so - don't guess. You can put this kind of preamble in a custom instructions file and reuse it across sessions, so you don't have to retype it each time. See Adding custom instructions for GitHub Copilot CLI . 3. Get an overview of the codebase Start with broad questions to build a mental map of the project.

The goal is to understand the shape of the code (where the entry points are, which directories contain what, and how the major pieces fit together) before you drill into a specific feature. Try prompts such as: Give me an overview of this codebase. What does the application do, what are the main components, and how do they communicate? Cite the files you used as evidence. What are the entry points for this application?

For each entry point, tell me which file contains the entry point and which directories contain the code it calls into. Asking for citations and evidence is important. When Copilot CLI tells you "this is handled in src/auth/middleware.ts ," you can open that file and verify the answer for yourself. If the citation doesn't match what you find, that's a useful signal to push back and ask follow-up questions. 4. Drill into a specific feature Once you have an overview, narrow in on the area you need to change.

Treat this as a conversation, not a single query. Each answer will surface terms, file names, and concepts that you can use in your next question. It's a good idea to ask similar questions that approach a topic from different angles. This helps to ensure you're getting the full picture, and will give you confidence that Copilot hasn't misunderstood what you're trying to find out about, and hasn't missed an important detail.

For example, suppose you've been asked to add rate limiting to a particular API endpoint, and you've never worked on this part of the code before, you might start with questions such as: Is there any existing rate limiting in this codebase? If so, where is it implemented, and how is it configured? If I wanted to add per-user rate limiting to the /api/v1/upload endpoint, which files would I most likely need to change, and which existing patterns in the codebase should I follow?

Asking follow-up questions within the same CLI session allows you to drill into the details of a feature and provides Copilot with the context it needs to give you specific answers that tell you what you need to know. 5. Investigate behavior and edge cases Reading code tells you what the code does. It often doesn't tell you what the code is supposed to do, or how it behaves in unusual situations. These are the questions where a human SME is most valuable—and where Copilot CLI can help you when no human is available.

Some examples of behavior and edge-case questions you might ask: What happens if the database connection drops while a request is being processed? Walk me through the error handling, based on the code. The `getUser` function takes a `userId` parameter. What validation is performed on it before it reaches the database query? Are there any code paths where an unvalidated value could reach the query? When you get an answer, follow up with "show me the code" or "which file did you find that in?" if it isn't already cited.

This gives you somewhere to check and verify the answer. 6. Use Git history as another source A lot of useful context lives in the Git history rather than in the current code: why a function was written the way it was, when a bug was last fixed, who originally added a module. Copilot CLI can run git commands for you and use the output to answer questions you couldn't easily answer by reading the code alone. Try prompts such as: When was the `PaymentProcessor` class introduced, and what was the original commit message?

Has it been substantially refactored since then? Look at the last 20 commits that touched files under `src/billing/`. Summarize what kinds of changes have been made recently. Who has made the most commits to `src/auth/`? Use that information to suggest the best person on this team to ask about authentication. 7. Verify before you trust Copilot CLI is a powerful SME, but it's not infallible. It can misread code, conflate similar-looking files, or, occasionally, make things up.

Treat its answers the way you'd treat advice from a helpful but fallible coworker: u

The rest of this page is on the live site.