AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How Developers Use Copilot Edits in VS Code to Stage Working Sets and Apply Multi-File Edits

Carmen Gracia Santos · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

For over two years, using AI inside code editors meant playing a tedious game of copy-paste tennis. You opened a sidebar chat, typed @workspace, waited for an LLM to generate three separate code blocks, and then manually copied snippets into your files, praying you didn't miss an import or mangle a closing bracket.

Copilot Edits in Visual Studio Code changes that paradigm completely. Instead of treating code modifications as conversational advice, it treats them as coordinated, atomic transactions directly inside your workspace. At 365Finds, we consider Copilot Edits the most meaningful workflow shift in GitHub Copilot since the launch of inline completions. But using it effectively requires understanding its central mechanic: the working set.

Here is how experienced developers stage working sets, execute coordinated multi-file edits, and maintain surgical control over complex codebases.


1. The Anatomy of the Working Set

The working set is the explicit boundary you give GitHub Copilot. It defines the files the AI is allowed to read for immediate context and directly mutate.

Without a working set, an LLM either hallucinates file paths or guesses where changes belong. With a sloppy working set, you flood the model's context window with irrelevant tokens, degrading prompt adherence and inviting unsolicited edits.

VS Code allows you to curate the working set through several entry points:

Working Set (Staged Files)
├── src/types/billing.ts       <-- Source of truth (Schema & Interfaces)
├── src/services/stripe.ts      <-- API integration logic
├── src/components/Checkout.tsx <-- UI consumer
└── tests/billing.test.ts       <-- Verification contract

At 365Finds, our primary rule for Copilot Edits is simple: stage three to five tightly coupled files at most. If your task touches schemas, API handlers, UI components, and unit tests, stage precisely those four files. Do not dump your entire repository tree into the working set.


2. Triggering Coordinated Multi-File Prompts

Once your working set is staged, Copilot Edits operates as a unified code generation engine. Rather than prompting file-by-file, you instruct the AI on the high-level intent, anchoring changes across the entire set.

Formulating the Cross-File Prompt

An effective Copilot Edits prompt establishes:

  1. The root change (e.g., a data contract modification).
  2. The cascading expectations (what must update in response).
  3. Explicit constraints (what patterns or error handling must remain intact).

Example Prompt: Refactoring a Data Contract

Refactor the customer billing model from single currency (USD) to multi-currency support:
1. In `src/types/billing.ts`, replace `amount: number` with `amount: number` and `currency: CurrencyCode` (use ISO 4217 strings).
2. In `src/services/stripe.ts`, update `createPaymentIntent` to pass the dynamic currency and handle unsupported currency validation errors.
3. Update `src/components/Checkout.tsx` to display the active currency symbol alongside the formatted price.
4. In `tests/billing.test.ts`, update mock payloads to include `currency: 'EUR'` and verify that currency mismatches throw a 400 error.

When submitted, Copilot processes the working set simultaneously. It calculates diffs across all staged files, streaming edits directly into the file buffers. If your prompt requires a new utility or mock, Copilot Edits will also propose creating the new file and automatically register it into the session.


3. The Pending State: In-Editor Review and Live Verification

One detail developers frequently overlook is that Copilot Edits does not just print diffs in a sidebar; it applies changes directly to your editor buffers in a pending review state.

In this pending state, the editor marks additions with green gutters and deletions with red markers. More importantly, the changes exist in your local filesystem. This creates a critical verification window.

[Copilot Edits Panel]
├── Modified: src/types/billing.ts       (+12, -3)
├── Modified: src/services/stripe.ts      (+28, -14)
├── Modified: src/components/Checkout.tsx (+15, -6)
└── Modified: tests/billing.test.ts       (+42, -18)

[Global Controls]
[ Keep (Ctrl+Enter) ]  [ Undo (Ctrl+Backspace) ]

The 365Finds Verification Workflow

Before clicking Keep or accepting any changes, execute real-world sanity checks:

  1. Check Compiler & Type Diagnostics: Look at the VS Code Problems tab (Ctrl+Shift+M / Cmd+Shift+M). Are there unresolved TypeScript errors or broken imports?
  2. Run Your Test Suite in the Terminal: Open the integrated terminal and execute your test runner:
    npm test tests/billing.test.ts
    
  3. Inspect Granular Diffs: Open the diff editor for each staged file. You can navigate between diff chunks using F7 (Next Difference) and Shift+F7 (Previous Difference).
  4. Accept or Revert Selectively:
    • Chunk level: Hover over an inline diff hunk to accept or discard individual hunks.
    • File level: Discard modifications on an individual file if Copilot misunderstood the UI component, while keeping the API and test changes.
    • Batch level: Use Keep (Ctrl+Enter / Cmd+Enter) to commit all pending edits, or Undo to roll back the entire batch to the pre-prompt state without losing chat history.

4. Iterative Refinement Without Starting Over

If tests fail or the compiler flags an issue while changes are pending, do not hit undo and start from scratch. Copilot Edits maintains session context.

Feed the compiler diagnostic directly back into the Edits input:

The TypeScript compiler returned error TS2322 in `src/components/Checkout.tsx` line 42:
"Type 'string' is not assignable to type 'CurrencyCode'."
Update the prop mapping so Checkout falls back to 'USD' if the passed currency string is invalid.

Copilot evaluates the current pending buffers against your follow-up instruction, amends the affected file, and keeps the rest of the working set intact.


5. Working Set vs. Copilot Chat: When to Use Which

To maximize productivity with GitHub Copilot, you must choose the right tool for the specific problem:

FeaturePrimary ScopeInteraction ModelBest Used For
Copilot Inline CompletionCurrent line or blockGhost text auto-suggestionsBoilerplate, regex, function bodies as you type
Copilot Chat (@workspace)Repository-wide contextRead-only conversational adviceArchitectural Q&A, codebase onboarding, debugging explanations
Copilot EditsExplicit working set (3–6 files)Multi-file inline buffer modificationCross-cutting refactors, API contract synchronization, test-driven implementations
Copilot Agent ModeWorkspace & terminal loopAutonomous multi-step executionEnd-to-end task solving, automated command execution, iterative bug fixing

6. Practical Takeaways and Common Traps

365Finds has identified three common mistakes teams make when adopting Copilot Edits:

  1. Tab Accumulation Pollution: Because VS Code automatically imports active tabs into the working set, keeping 15 unrelated tabs open will silently bloat the context window. Close unneeded editor tabs before initiating an Edit session.
  2. Blindly Clicking Keep: The greatest risk of multi-file AI generation is subtle semantic drift—where code compiles but business logic quietly breaks. Running automated tests against the pending buffer before accepting is mandatory.
  3. Ignoring Model Options: VS Code allows selecting the underlying model (such as Claude 3.5 Sonnet or GPT-4o) in the prompt interface. For complex architectural refactors across multiple files, reasoning-heavy models deliver significantly higher first-pass accuracy.

In VS Code, Copilot Edits transitions GitHub Copilot from an advisory autocomplete assistant into an active multi-file code compositor. By tightly scoping the working set and leveraging in-editor pending diffs, developers execute cross-layer changes in seconds while preserving full architectural control.

References