- Primary resources:
- GitHub Copilot: https://docs.github.com/en/copilot
- Copilot Chat: https://docs.github.com/en/copilot/copilot-chat
- Visual Studio Code: https://code.visualstudio.com/
Install the extensions
- Open Visual Studio Code and open the Extensions view (Ctrl+Shift+X / Cmd+Shift+X).
- Search for and install:
- “GitHub Copilot” — core suggestions and completions.
- “GitHub Copilot Chat” — conversational UI for asking and editing code. (If not installed automatically, install it separately.)
- After installation:
- Make sure both extensions are enabled.
- Sign in to GitHub and authorize Copilot when prompted.
You can manually select which AI model Copilot Chat uses, or leave it on “Auto” so Copilot chooses the best model for your request.
Opening Copilot Chat
After installation, look for the Copilot Chat toggle or icon (often on the Activity Bar or title bar). Click it to open the chat pane (commonly docked to the right side of the editor). The chat interface gives you a few primary actions and modes:- Agent — run specialized workflows or automated tasks on your repository.
- Ask — pose natural-language questions about the current file or the entire workspace.
- Edit — request in-place changes that Copilot can suggest and optionally apply.
- Plan — ask Copilot to outline multi-step changes or high-level plans.
Copilot Chat UI options (quick reference)
Example: Asking Copilot Chat about your code
Below is a representativeindex.html for a simple game (cleaned and corrected). Use this as a sample file Copilot Chat can read to answer questions or suggest edits.
script.js), Copilot Chat can read the file and answer contextual questions. Scope the analysis to the current file or the entire workspace by prefixing prompts with @workspace or selecting the workspace scope in the UI (e.g., @workspace explain).
Example: power-up handling in script.js
This example shows a corrected and consolidated switch handling several power-up types. It demonstrates safe object spreading, consistent game state fields, and appropriate break usage.
- Always check that
gameState.balls[0]exists before copying it to avoid exceptions. - Maintain consistent fields on
gameState(for example,gameState.bulletFireCounter) to prevent undefined references. - Keep
breakstatements at the end of eachcaseblock to avoid fall-through bugs.
Using Ask / Agent / Edit modes effectively
- Ask: Use plain-language queries scoped to the current file or the full workspace (e.g., “How many levels does the game support?” or “How many lives does the player start with?”). Copilot Chat will report which files/lines it used for context.
- Agent: Run automated workflows or repository-wide analyses using specialized agents (useful for security checks, CI suggestions, or bulk refactors).
- Edit: Request concrete code edits. Copilot Chat suggests changes and can apply them; always review suggestions before accepting.
- “The game starts with three lives” (if the source initialization reflects this).
- “No hard-coded maximum level detected” (implying levels may be generated indefinitely).
- “Ball speed is fixed and not increased per level” (if no difficulty scaling logic exists).
Summary / Quick checklist
- Install GitHub Copilot and GitHub Copilot Chat extensions in Visual Studio Code.
- Open the Copilot Chat panel (Toggle Chat icon) and choose Ask, Agent, Edit, or Plan based on your goals.
- Use
@workspaceto analyze multiple files or the full repository. - Carefully review any suggested edits before applying them.
Copilot Chat will list which files it referenced when forming an answer. Use that to verify the analysis scope and ensure Copilot had access to the relevant parts of your project.
Links and references
- GitHub Copilot docs: https://docs.github.com/en/copilot
- Copilot Chat docs: https://docs.github.com/en/copilot/copilot-chat
- Visual Studio Code: https://code.visualstudio.com/