Top 200 ReposEXPLORER
Browse agents, categories and pages
Back to results
Planned, not doneThe source describes an intention, not a finished result.

Create a Test-Fix-Retest Loop With Terminal Approvals

Overview

Give GitHub Copilot in VS Code custom instructions to write a failing test, run it, fix the code and rerun, while you approve or skip each terminal command it wants to run.

Problem or Objective

More in Coding and Code Review

AI Agents and Models

Tools and Integrations

Tools
GitHub Copilot · Visual Studio Code
Prerequisites
Visual Studio Code with GitHub Copilot, a project with a working test command, and a Git branch for the fix. Chat and agent work use GitHub AI credits from your plan.

How It Works

Create a branch for the fix. Add custom instructions to the project that describe the loop: reproduce the bug with a failing test first, run only that test, read the failure, change the code, rerun, add extra diagnostic output if it still fails, and stop after a set number of attempts with a summary. Open Chat in VS Code with an agent session, describe the bug and the test command, and let Copilot work. When an approval prompt appears for a terminal command, read the command and what it acts on, then choose Allow Once or Skip; skip anything that installs packages, deletes files or reaches the network unless you expected it. When the test passes, read the diff, remove leftover debug output, run the full test suite yourself and commit on the branch.

Implementation Workflow

Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.

  1. Choose the agentSet up GitHub Copilot.
  2. Connect the toolsConnect the tools this workflow relies on: GitHub Copilot, Visual Studio Code.
  3. Check the prerequisitesVisual Studio Code with GitHub Copilot, a project with a working test command, and a Git branch for the fix. Chat and agent work use GitHub AI credits from your plan.
  4. Gather your detailsCollect what the prompt asks for: The bug, Where the test goes, Command for one test, Attempt limit.
  5. Run the starter promptPaste the starter prompt below into GitHub Copilot and adapt it to your case.
  6. Check against the documentationCompare what you get with the documentation at code.visualstudio.com before you rely on it.

Practical Starter Prompt: Fix this bug test-first

Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].

Preview
Fix this bug: [The bug]. First write a test in [Where the test goes] that fails because of the bug, and run only that test with [Command for one test]. Read the failure, change the code, and rerun. If it still fails, add temporary diagnostic output and rerun. Stop after [Attempt limit] attempts and summarise what you tried. Wait for my approval before any command other than the test command, and do not commit, push or install packages.

Approve terminal commands one at a time with Allow Once and skip anything you did not expect. When the test passes, read the diff, remove debug output, run the full suite yourself and commit on your branch.

Expected Results and Benefits

This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.

This is a suggested workflow, not a reported outcome. The VS Code documentation says custom instructions tailor Copilot to a project, that tool approval decides whether a call runs without your confirmation, and that at an approval prompt you review the command and choose Allow Once or Skip. Whether a prompt appears depends on your permission level and saved approvals. No cited page describes how many rounds a fix takes; the attempt limit in the instructions keeps that bounded.

Limitations and Considerations

Saved approvals and higher permission levels can let commands run without a prompt, so check your approval settings before starting if you want to see every command. Stopping a request does not undo edits or commands that already ran, so work on a branch. A passing test only proves what the test checks: read the diff and run the whole suite. Chat and agent work use GitHub AI credits from your plan. Results depend on your setup and were not independently reproduced by Top 200 Repos.

Sources

  1. Use tools with agents (opens in a new tab)

    Project documentation · code.visualstudio.com · Undated · Source checked 27 Nov 2026, 13:25 UTC

    What this source supports
    • Tool approval determines whether a specific call can run without your confirmation.
    • If an approval prompt appears, review the tool's inputs and the command, file, or destination it will act on.
    • Choose Allow Once to approve that call, or Skip to decline it.
    • Your permission level, runtime decisions, and saved approvals affect whether a call needs review.
  2. Use chat in VS Code (opens in a new tab)

    Project documentation · code.visualstudio.com · Undated · Source checked 27 Nov 2026, 13:24 UTC

    What this source supports
    • tailor the AI's behavior to your project by adding custom instructions , creating reusable prompt files , or building custom agents for specialized workflows.
    • Stopping a request doesn't undo file edits, terminal commands, or other actions that already completed.
  3. GitHub Copilot · Your AI coding agent · GitHub · GitHub (opens in a new tab)

    Project documentation · github.com · Undated · Source checked 25 Nov 2026, 11:59 UTC

    What this source supports
    • You use credits when you chat with Copilot and work with agents.
Report a problem

More with GitHub Copilot

Planned, not done

Request Copilot Corrections on an Existing Pull Request

Open GitHub Copilot from an existing pull request, point it at that pull request's branch and ask for specific corrections, then confirm where the commits landed before asking for review.

docs.github.com
Planned, not done

Learn Terraform Through a Small Infrastructure Project

Learn Terraform by building a very small infrastructure project in steps with GitHub Copilot explaining each change, while you read every plan and run any apply yourself.

docs.github.com
Planned, not done

Update a Package Dependency Through a Copilot PR

Delegate a package upgrade to GitHub Copilot's coding agent, then review the pull request it prepares, checking the version change, the lockfile and the test results before you merge anything.

docs.github.com

View all: GitHub Copilot