Exam domains exercised
Domain 2: Use GitHub Copilot features ยท Domain 5: Improve developer productivity
- Use all four Chat modes (Ask, Edit, Plan, Agent) and understand when each is appropriate
- Execute a complete scaffold-to-test workflow using Agent Mode
- Use the modern Copilot CLI for real development tasks
- Experience Copilot-assisted PR workflow on GitHub.com
Chat Modes Reference
| Mode | What It Does | Best For |
|---|---|---|
| ๐ฌ Ask | Answers questions, explains code, suggests changes as text. Does not modify files. | Learning, exploration, code review |
| โ๏ธ Edit | Makes direct file modifications. Shows diffs for approval. | Targeted refactoring, specific changes |
| ๐ Plan | Researches the codebase and proposes an implementation plan without making file edits. | Planning complex changes before committing to them |
| ๐ค Agent | Autonomous multi-step execution. Plans, edits files, runs terminal commands, iterates on errors. | Feature implementation, scaffolding, complex tasks |
Exercises
Scaffold a REST API with Agent Mode
Agent Mode is Copilot's most powerful feature โ it can plan, create files, run commands, and iterate. You'll use it to scaffold an entire API project.
Instructions
- Create a new empty folder for this lab:
lab3-api/ - Open Copilot Chat and switch to Agent Mode (select "Agent" from the mode dropdown at the top of the Chat panel).
- Type this prompt:
Create a Node.js REST API for a task management app using Express and TypeScript. Include:- Project setup: package.json, tsconfig.json, .gitignore
- Data model: Task with id, title, description, status (todo/in-progress/done), createdAt, updatedAt
- In-memory storage (array-based, no database needed)
- CRUD endpoints: GET /tasks, GET /tasks/:id, POST /tasks, PUT /tasks/:id, DELETE /tasks/:id
- Input validation middleware
- Error handling middleware with consistent JSON error responses
- A health check endpoint: GET /health
Put all code in the lab3-api/ directory.
- Watch Agent Mode work:
- It will plan the file structure
- It will create multiple files (package.json, tsconfig.json, source files)
- It may run terminal commands (like
npm initornpm install) - You’ll see a permission prompt before it runs any command โ click Allow
- When it finishes, review the generated project structure. You should see something like:
lab3-api/ โโโ package.json โโโ tsconfig.json โโโ .gitignore โโโ src/ โโโ index.ts (or app.ts) โโโ routes/ โ โโโ tasks.ts โโโ middleware/ โ โโโ validation.ts โ โโโ errorHandler.ts โโโ types/ โโโ task.ts</li>
Ask Mode โ Understand the Generated Code
Switch to Ask Mode to explore and understand what Agent Mode created.
Instructions
- Switch the Chat mode to Ask.
- Ask about the overall architecture:
#project Explain the architecture of the lab3-api project. What patterns does it use? How does request flow from route to response? - Ask about a specific file (use the actual path from your generated project):
#file:lab3-api/src/routes/tasks.ts Walk me through each endpoint. What HTTP methods and status codes does each use? - Ask about error handling:
#file:lab3-api/src/middleware/errorHandler.ts How does the error handling middleware work? What happens if an unhandled error occurs? - Note that Ask Mode only answers questions โ it doesn't modify any files. This is the safe mode for exploration.
Plan mode โ Add Documentation
Use Plan mode for targeted, in-place file modifications with diff review.
Instructions
- Switch the Chat mode to Edit.
- Open your main routes file and request documentation:
#file:lab3-api/src/routes/tasks.ts Add comprehensive JSDoc comments to every route handler. Include @param for request parameters, @returns with expected response shape, and @example with a curl command for each endpoint. - Copilot will show you a diff view โ green lines are additions, red lines are removals.
- Review the diff carefully. Then click Accept to apply.
- Now do the same for the types file:
#file:lab3-api/src/types/task.ts Add JSDoc to the Task interface and all related types. Include field descriptions and valid value ranges. - Accept the changes.
Agent Mode โ Debug and Fix
Introduce a bug and watch Agent Mode diagnose and fix it.
Instructions
- Open your tasks route file. Intentionally introduce a bug โ for example, change a status code from
201to200on the POST endpoint, or misspell a variable name. - Switch back to Agent Mode.
- Type:
There's a bug in the task creation endpoint. The POST /tasks endpoint should return 201 Created but it's returning the wrong status code. Find and fix it. Then verify by checking all other endpoints for correct status codes: - GET collection: 200 - GET single: 200 (or 404) - POST: 201 - PUT: 200 (or 404) - DELETE: 204 (or 404) - Watch Agent Mode: it reads the file, identifies the issue, makes the fix, and may even verify by reading related files.
Agent Mode โ Refactor
Use Agent Mode for a cross-cutting refactor that touches multiple files.
Instructions
- In Agent Mode, type:
Refactor the task API to add request logging middleware that logs: - Timestamp - HTTP method and URL - Response status code - Response time in millisecondsCreate it as a new middleware file and wire it into the app. Use it on all routes.
- Observe that Agent Mode:
- Creates a new middleware file
- Modifies the main app file to import and use it
- This is a multi-file change that Plan mode couldn’t handle as smoothly
Agent Mode โ Generate Tests
Complete the workflow by generating tests for your API.
Instructions
- In Agent Mode, type:
Generate comprehensive Jest tests for the task API. Include: 1. Tests for all CRUD endpoints (happy path) 2. Validation error tests (missing fields, invalid types) 3. 404 tests for non-existent task IDs 4. Edge cases (empty title, very long description) 5. Set up supertest for HTTP testing 6. Create a test setup file with helpersInstall any needed dev dependencies (jest, ts-jest, supertest, @types/supertest).
- Agent Mode will:
- Install test dependencies via terminal
- Create Jest configuration
- Create test files with multiple test suites
- Possibly run the tests and fix any failures
- After it finishes, run the tests yourself:
cd lab3-api && npx jest --verbose</li> <li>If any tests fail, paste the error into Agent Mode and ask it to fix them. This is the <strong>iterate</strong> part of the agentic loop.</li>
Copilot CLI โ Terminal Workflows
Use the modern Copilot CLI to assist with shell tasks, explanations, and local workflow planning.
Instructions
- Open the integrated terminal in VS Code.
- Navigate to your lab3-api directory.
- Try these CLI prompts:
# Find all TypeScript files with more than 50 lines copilot "find TypeScript files with more than 50 lines in current directory"Understand a complex npm script #
copilot “explain: npx ts-node –transpile-only src/index.ts”
Get help with git #
copilot “create a git branch called feature/add-pagination and switch to it”
Understand a test command #
copilot “explain: npx jest –coverage –watchAll –verbose”
Plan before changing files #
copilot “/plan add pagination to the task API without changing tests yet”
- Review any proposed shell command before running it. The CLI is conversational and may offer to execute commands, but you remain responsible for approval.
Bonus: GitHub.com PR Workflow
If you have a test repo, experience Copilot on GitHub.com.
Instructions
- Commit your lab3-api work and push to a branch on GitHub.
- Open a Pull Request on GitHub.com.
- Observe the Copilot PR Summary โ it auto-generates a description of your changes.
- In the PR, try the Copilot Code Review feature (if available on your plan) to get AI-powered review comments.
โ Completion Checklist
- Scaffolded a REST API project using Agent Mode
- Used Ask Mode to explore and understand the generated code
- Used Plan mode to add JSDoc documentation with diff review
- Used Agent Mode to find and fix a bug
- Used Agent Mode for a multi-file refactor (logging middleware)
- Generated and ran tests using Agent Mode
- Used Copilot CLI for shell tasks, command explanations, and planning
๐ฏ Key Takeaways for the Exam
- Ask Mode: Read-only, conversational, safe for exploration
- Plan mode: Direct file changes with diff review, targeted edits
- Plan Mode: Researches and proposes an implementation plan before file changes
- Agent Mode: Autonomous multi-step, can run terminal commands, iterates on failures
- Agent Mode is available on all plans including Free
- Copilot CLI: use
copilotfor terminal help, command explanations, local context, and planning - PR summaries and code review are GitHub.com features
- Agent Mode follows the Plan โ Code โ Test โ Iterate loop
