Skip to content

Lab 085: Prompt and Context Engineering in GitHub CopilotΒΆ

Level: L100 Journey: copilot Time: ~45 min Cost: GitHub Free

Free-first design

Complete the guided exercise with Copilot Free or the included simulation. Paid features are optional and explicitly labeled.

AI Credit impact

Low for guided work; medium/high for agentic or repeated runs. Prefer automatic model selection, plan before acting, keep context focused, and avoid unnecessary parallel sessions.

What You'll LearnΒΆ

  • Choose between selection, files, and codebase context
  • Write compact prompts with constraints and acceptance criteria
  • Use Ask, Plan, and Agent with the right context boundary
  • Reduce AI Credit waste by keeping context intentional

GH-300 alignmentΒΆ

Responsible AI (15–20%) Β· Prompt and context (10–15%). This mapping follows the GH-300 curriculum snapshot dated 2026-08-07. The official outline may retain older product wording such as β€œCopilot Edits”; this lab teaches the current product experience and calls out that difference.

Concept MapΒΆ

flowchart LR
  Q[Task] --> S{Smallest useful context}
  S -->|Snippet| A[Selection]
  S -->|Known dependency| F[File reference]
  S -->|Cross-cutting change| C[Codebase]
  A --> V[Verify]
  F --> V
  C --> P[Plan first] --> V

Hands-on ExerciseΒΆ

Step 1: Build a context ladderΒΆ

Open a small repository and solve the same question four times: with a selection, one referenced file, a focused set of files, and the repository context. Record which evidence changed the answer.

Step 2: Write an implementation promptΒΆ

Use the structure goal β†’ context β†’ constraints β†’ acceptance criteria β†’ validation. Ask Plan mode to identify affected files before Agent mode edits anything.

Step 3: Run the responsible-AI checkΒΆ

Verify generated code, cite the source files used, inspect security-sensitive assumptions, and reject any suggestion that invents APIs or secrets.

Supporting kitΒΆ

The site build generates stable PDF and ZIP downloads. The ZIP contains the lab guide and every supporting file declared for this lab.