Intermediate18 min1 prerequisite

Use GitHub Copilot Chat for conversational AI assistance, code explanations, and interactive problem-solving.

Copilot Chat

Copilot Chat brings conversational AI into your editor. Ask questions, get explanations, generate code, and solve problems through natural dialogue.

Accessing Chat

Chat Panel

Open the dedicated chat panel:

  • Shortcut: Cmd/Ctrl+Shift+I
  • Click: Chat icon in the activity bar
  • Command: GitHub Copilot: Open Chat

The panel stays open for ongoing conversation.

Inline Chat

For quick, contextual questions:

  • Shortcut: Cmd/Ctrl+I
  • Appears inline in the editor
  • Great for quick fixes and explanations

Quick Chat

Floating dialog for brief interactions:

  • Shortcut: Cmd/Ctrl+Shift+Alt+L
  • Doesn't leave your current view

Chat Participants

Use @ to target specific contexts:

@workspace

Questions about your entire project:

Terminal
@workspace How is authentication implemented in this project?

@workspace What files handle payment processing?

@workspace Where are API routes defined?

@vscode

VS Code-specific questions:

Terminal
@vscode How do I change the color theme?

@vscode What's the shortcut for multi-cursor editing?

@vscode How do I configure auto-save?

@terminal

Terminal and command-line help:

Terminal
@terminal How do I find all .log files recursively?

@terminal What's the command to show disk usage?

@terminal How do I kill a process on port 3000?

Slash Commands

Commands for specific actions:

/explain

Explain selected code:

Terminal
/explain

Copilot: This function implements the Fisher-Yates shuffle algorithm.
It iterates through the array from the end, swapping each element
with a randomly selected element from the unshuffled portion.
Time complexity: O(n), Space complexity: O(1).

/fix

Fix issues in selected code:

Terminal
/fix This code throws a null pointer exception

Copilot: The issue is that `user` might be null. Here's the fix:

```typescript
// Before
const name = user.name.toLowerCase()

// After
const name = user?.name?.toLowerCase() ?? ''
Terminal

### /tests

Generate tests for selected code:

/tests

Copilot: Here are tests for the calculateDiscount function:

Terminal
describe('calculateDiscount', () => {
  it('applies percentage discount correctly', () => {
    expect(calculateDiscount(100, 10)).toBe(90)
  })

  it('handles zero discount', () => {
    expect(calculateDiscount(100, 0)).toBe(100)
  })

  it('handles 100% discount', () => {
    expect(calculateDiscount(100, 100)).toBe(0)
  })
})
Terminal

### /doc

Generate documentation:

/doc

Copilot: Here's the JSDoc for this function:

Terminal
/**
 * Calculates the total price including tax and discounts.
 *
 * @param items - Array of cart items with price and quantity
 * @param taxRate - Tax rate as a decimal (e.g., 0.08 for 8%)
 * @param discountCode - Optional discount code to apply
 * @returns The total price in cents
 * @throws {InvalidDiscountError} If discount code is invalid
 *
 * @example
 * const total = calculateTotal(cartItems, 0.08, 'SAVE10')
 */
Terminal

### /simplify

Simplify complex code:

/simplify

// Before const result = arr.filter(x => x !== null).filter(x => x !== undefined).map(x => x.value).reduce((a, b) => a + b, 0)

// After const result = arr .filter(Boolean) .reduce((sum, item) => sum + item.value, 0)

Terminal

### /new

Start a new conversation:

/new Let's design a user notification system

Terminal

### /clear

Clear conversation history:

/clear

Terminal

## Contextual Conversations

### Using Selection

Select code before asking:

```python
# Select this function:
def process_orders(orders):
    results = []
    for order in orders:
        if order.status == 'pending':
            result = process_single_order(order)
            results.append(result)
    return results

# Then ask:
"How can I make this more efficient using list comprehension?"

# Copilot responds with context-aware suggestion

Multi-Turn Conversations

Build on previous responses:

Terminal
You: How do I add rate limiting to my Express API?

Copilot: [Explains express-rate-limit package]

You: Can you show me how to apply different limits per route?

Copilot: [Shows route-specific configuration]

You: How do I store rate limit data in Redis instead of memory?

Copilot: [Shows Redis store configuration]

Referencing Files

Use #file to include files:

Terminal
Looking at #file:src/auth/login.ts and #file:src/middleware/auth.ts,
how can I add JWT refresh token rotation?

Common Use Cases

Code Explanation

Terminal
Select complex code and ask:

"Explain this regular expression step by step"
"What does this algorithm do?"
"Why is this implementation thread-safe?"

Debugging Help

Terminal
I'm getting this error: [paste error]
Here's the relevant code: [select code]
What's causing this?

Copilot: The error occurs because... Here's the fix:

Implementation Guidance

Terminal
"How should I structure a microservices authentication system?"
"What's the best way to implement optimistic updates in React?"
"How do I handle file uploads with progress tracking?"

Code Review

Terminal
Select code and ask:

"Review this code for potential issues"
"Are there any security vulnerabilities here?"
"How can I improve the performance of this function?"

Refactoring Assistance

Terminal
"How can I refactor this class to use composition instead of inheritance?"
"Convert this callback-based code to async/await"
"Extract the common logic into a reusable hook"

Advanced Techniques

System-Level Questions

Terminal
@workspace What design patterns are used in this codebase?

@workspace Show me the data flow from API to UI for user creation

@workspace What are the dependencies between these modules?

Comparative Analysis

Terminal
What's the difference between these two implementations?
#file:src/v1/handler.ts vs #file:src/v2/handler.ts

Learning Mode

Terminal
Explain like I'm new to TypeScript:
What is a generic type and when should I use one?

Can you explain with a simple example first, then a real-world use case?

Code Generation with Constraints

Terminal
Create a React form component that:
- Uses react-hook-form for form state
- Validates with zod
- Handles submission errors
- Shows loading state
- Is accessible (ARIA labels)

Use Tailwind CSS for styling.

Best Practices

Be Specific

Terminal
 "Fix this code"
 "Fix the null pointer exception on line 23"

 "Make this better"
 "Optimize this function for memory usage"

 "Add tests"
 "Add unit tests covering edge cases for empty arrays and null inputs"

Provide Context

Terminal
 "How do I connect to the database?"
 "How do I connect to PostgreSQL using Prisma in this Next.js project? @workspace"

 "Why isn't this working?"
 "This code returns undefined instead of the user object.
   I expect it to return the user after fetching from /api/users.
   Here's the error from the console: [error]"

Iterate on Responses

Terminal
Initial: "Create a login form"

Follow-up 1: "Add email validation"

Follow-up 2: "Include a 'remember me' checkbox"

Follow-up 3: "Add social login buttons"

Use Slash Commands

Terminal
# Quick actions
/explain  - Understand code
/fix      - Fix issues
/tests    - Generate tests
/doc      - Add documentation
/simplify - Reduce complexity

Limitations

What Chat Does Well

  • Explaining code and concepts
  • Generating boilerplate
  • Debugging with context
  • Answering technical questions
  • Single-file modifications

What Chat Struggles With

  • Complex multi-file refactoring (use Copilot Edits)
  • Real-time API data (knowledge cutoff)
  • Very long context windows
  • Highly specialized domains

Context Limits

Chat has a context window limit:

Terminal
If conversation gets long:
1. Use /new to start fresh
2. Be more concise in questions
3. Reference specific files instead of pasting code
4. Break complex tasks into smaller conversations

Configuration

Chat Settings

Terminal
{
  // Language for responses
  "github.copilot.chat.localeOverride": "en",

  // Where to show chat
  "github.copilot.chat.defaultLocation": "panel",

  // Response length
  "github.copilot.chat.useProjectTemplates": true
}

Custom Instructions

Create .github/copilot-instructions.md for project-specific guidance:

Terminal
# Copilot Instructions

## Code Style
- Use TypeScript strict mode
- Prefer functional components
- Use named exports

## Frameworks
- React 18 with hooks
- Next.js App Router
- Tailwind CSS

## Testing
- Use Vitest for unit tests
- React Testing Library for components
- Playwright for E2E

Summary

  • Chat Panel: Cmd/Ctrl+Shift+I for ongoing conversation
  • Inline Chat: Cmd/Ctrl+I for quick questions
  • Participants: @workspace, @vscode, @terminal
  • Commands: /explain, /fix, /tests, /doc
  • Context: Select code, reference files with #file:
  • Best practices: Be specific, provide context, iterate

Next Steps

Chat handles questions and single-file changes. For project-wide understanding and complex queries, let's explore the Workspace Agent.

Mark this lesson as complete to track your progress