Optimizing GitHub Copilot: Better Results, Fewer Tokens
Emily Rothrock and Shivani Sundaresan walk through practical ways to optimize GitHub Copilot Chat so it produces better outputs with less token usage.
Overview
This episode focuses on how GitHub Copilot uses context and tokens, and how developers can actively manage both to improve response quality and reduce wasted usage.
What “context” includes
The presenters explain that Copilot’s responses depend heavily on what information is currently in scope, including:
- The current conversation
- The files and project content Copilot can see
- Any instructions that guide behavior (for example, a repository instructions file)
How Copilot processes information as tokens
They describe how Copilot processes the available context as tokens, and why both extremes can cause problems:
- Too little context can lead to generic or incorrect results
- Too much context can dilute what matters and reduce answer quality
Viewing context with /context
They demonstrate using the /context command to inspect what Copilot is currently considering, helping you verify whether the right files and information are included.
Understanding the context window
The video explains the idea of a context window (using a “suitcase” analogy) to show that there is a limited amount of information Copilot can carry forward at once.
Example: generating content without enough project context
They show an example of generating a case study page without sufficient project context, then improving results by adding relevant project files so Copilot has the right grounding.
Refreshing project context with /init
They demonstrate refreshing or re-establishing context using:
/initto start with a clean, relevant baseline for the project
Guiding Copilot with copilot-instructions.md
They call out how a copilot-instructions.md file can steer Copilot’s behavior and outputs by providing consistent, project-specific guidance.
Starting focused sessions and checking usage
They cover how to begin a session with the right scope and then validate what’s being used:
- Start with the right set of files and instructions in context
- Check context usage to ensure the session stays on track
Reducing token usage with /compact
They demonstrate using:
/compactto reduce token usage by compacting the conversation/context so the session stays efficient
Series context and resources
This is Episode 5 of 10 in the “Build your personal brand with Copilot” student series.
- Series site: https://aka.ms/student-learning-series-website
- Episode artifacts (prompts/code): https://aka.ms/student-learning-series
- Learn more about GitHub Copilot: https://aka.ms/StudentAI-GitHubCopilotApp
Timeline (from the video description)
- 0:00 Welcome and an introduction to context and tokens
- 0:21 What context includes
- 0:38 How Copilot processes information as tokens
- 0:46 Viewing context with /context
- 0:53 Understanding the context window with a suitcase analogy
- 1:04 Why too little or too much context can hurt results
- 2:07 Generating a case study page without project context
- 3:04 Adding project files for better results
- 3:57 Refreshing project context with /init
- 4:02 How copilot-instructions.md guides Copilot
- 5:02 Starting a focused session with the right context
- 6:08 Checking context usage
- 6:44 Reducing token usage with /compact
- 7:11 Recap of context and token optimization