Level 5Lesson 40⏱️ 75 min

AI Chat for Development

Inline completion is fast. Chat is deep. Know when to use each — and how to ask questions that get great answers.

Chat vs Inline: Choosing the Right Mode

Use inline completion when:
  • Writing new code in a known pattern (CRUD, API calls, components)
  • Completing a structure you've already started (switch cases, objects, lists)
  • You know exactly what you want and just want it typed faster
Use chat when:
  • You need to explain a problem and think through it
  • You want to understand code you didn't write
  • You need a design decision or tradeoff analysis
  • You want to generate, then modify, then iterate
  • You need something that spans multiple concepts

Slash Commands (GitHub Copilot Chat)

/explain   → Explain selected code in plain English
/fix       → Fix the bug or error in selected code
/tests     → Generate unit tests for selected code
/doc       → Generate documentation for selected code
/simplify  → Refactor selected code to be simpler
/new       → Scaffold a new file/project

# In VS Code chat, you can also use:
@workspace  → Ask about your entire codebase
@terminal   → Ask about terminal commands
#file       → Reference a specific file
#selection  → Reference your current selection

Examples:
> /explain  [select 30 lines of complex regex]
> /fix      [select the function with the bug]
> @workspace where is the authentication middleware defined?
> #file:user.service.ts what does this service do?

High-Value Chat Patterns

// Pattern 1: Understand unfamiliar code
"Explain this middleware step by step.
What does each part do and why?"

// Pattern 2: Design before you code
"I need to add rate limiting to my Express API.
What are my options? Compare Redis vs in-memory
vs a library approach. I have 5 API instances."

// Pattern 3: Diagnose an error
"I'm getting this error: [paste full stack trace]
Here's the relevant code: [paste code]
What's causing it and how do I fix it?"

// Pattern 4: Improve existing code
"This function works but feels wrong.
What are the code smells here?
How would a senior engineer rewrite it?"

// Pattern 5: Generate with constraints
"Write a React hook that fetches user data.
Requirements:
- TypeScript with proper types
- Handle loading, error, and success states
- Cancel on unmount (cleanup)
- Use React Query under the hood"

// Pattern 6: Rubber duck + solution
"I'm trying to [goal]. I thought I could [approach].
But I'm running into [problem]. What am I missing?"

Claude Code Chat Mode

# Claude Code is terminal chat with full codebase access
# Start a session in your project:
claude

# Ask about your own code (Claude has read the whole repo)
> How does authentication work in this app?
> Find all places where we query the users table directly
> What's the difference between UserService and UserRepository?

# Combine understanding with action
> Explain the current rate limiting approach, then
  suggest how to make it distributed-safe

# Reference specific files naturally
> Look at src/middleware/auth.ts and explain
  the token refresh logic

# Claude Code remembers context in the session
> OK based on that, now add refresh token rotation
Key difference: GitHub Copilot chat sees what you have open. Claude Code chat reads your entire repository. For questions about architecture, dependencies, or cross-file patterns, Claude Code gives dramatically better answers.

Getting Better Answers: Prompting for Code

1
Give context first — "I'm using Express 4, TypeScript, Prisma ORM, and PostgreSQL"
2
State constraints upfront — "No external libraries", "Must be backward compatible", "Needs to work in Node 18"
3
Ask for explanations — "Explain why you made each choice" surfaces assumptions you can correct
4
Request alternatives — "Show me 2 approaches with tradeoffs" is better than accepting the first suggestion
5
Iterate, don't restart — "Keep everything but change the error handling to use a Result type" is faster than re-prompting from scratch
Lesson 40 Quick Reference
/explain

Copilot Chat: explain selected code in plain English

/fix + /tests

Fix selected bug or generate unit tests for selection

@workspace

VS Code: ask about your entire codebase (not just open files)

Claude Code chat

Reads entire repo — best for architecture/cross-file questions

Context first

Always state your stack (Express, Prisma, TS) before asking a question

Ask for alternatives

"Show 2 approaches with tradeoffs" beats accepting the first answer