Challenge 02 - Context Engineering

< Previous Challenge - Home - Next Challenge >

Introduction

In this challenge, you will optimize Copilot context using a real code task in the NYC starter app under Resources/Challenge-02-NYCApp.

The app intentionally includes an oversized global .github/copilot-instructions.md file and multiple routes (events, restaurants, neighborhoods) so you can compare broad context (#Codebase) against precise, task-focused attachments.

Every token sent to GitHub Copilot has a cost. Context that persists across interactions, such as global instruction files or broad workspace references, can increase recurring spend by adding tokens that are not needed for the current task.

You will audit the over-stuffed global instructions file, restructure it into scoped path-specific files, and replace broad references with pinned attachments to reduce the base cost of each Copilot interaction while maintaining output quality.

Description

Use the project in:

Resources/Challenge-02-NYCApp

Part 1 - Scope Instructions

  1. Audit .github/copilot-instructions.md and identify what is:
    • universally useful
    • specific to events
    • irrelevant for this task (for example, restaurants/neighborhoods/frontend/testing rules)
  2. Shrink the global file to only truly global guidance.
  3. Create scoped instruction files under .github/instructions/ for rules that should apply only to specific paths/tasks. For example, create an api.instructions.md file and an events.instructions.md file.
  4. Keep the events-specific logic discoverable for work in src/routes/events.ts.
  5. Create a reusable Copilot skill under .github/skills/free-events-endpoint/SKILL.md that captures the pattern for implementing a free events endpoint. This skill should only load when explicitly invoked, making it a conditional cost rather than a recurring one.

Part 2 - Implement the Baseline Route Task

Implement GET /events/free-this-week in src/routes/events.ts with this behavior:

Important:

Part 3 - Attachment Precision and Token Usage Check

In the GitHub Copilot Chat interface, run this exact query twice and compare results:

“What data or features does this application support?”

Run it twice and record the token usage each time:

  1. Without scoped files (broad context, such as #Codebase)
  2. With scoped files pinned (only task-relevant files, for example: src/routes/events.ts, src/data/events.ts, and relevant instruction files)

Capture both token counts from the Copilot Chat usage details/output, compare answer quality, and calculate the difference.

For each run, record context window stats in this format:

Example format:

Then compute:

Use this table to record your measurements:

Run Context Strategy Query Used Tokens Total Context Window Tokens Utilization % Notes
A Broad (#Codebase or equivalent) What data or features does this application support?        
B Scoped pinned files What data or features does this application support?        
Comparison Metric Value
Used-token delta (A - B)  
Utilization delta percentage points (A - B)  

Success Criteria

To complete this challenge successfully, you should be able to:

Learning Resources

Tips