explainx.ainewsletter3.5k
TrendingNewsPathwaysSkills
Pricing
explainx.ai

Upskill in AI — 16 free pathways, live workshops & bootcamps, and 50+ courses from practitioners. Plus the skills, tools, and MCP servers to practice on.

follow us

corporate training

support@explainx.ai

get started

Find your pathTake Free Evaluation

learn

pathways — start freeworkshopsbootcampscoursescertificationsmock testsexplainx universitycorporate traininglearn skills & mcp

discover

skillsmcp serversexplainx mcptoolsagentsllmsdesignsdictionaryagi trackerranks

company

aboutvisionmissionteaminstructorscommunityhackathonscareers

content

daily AI newsstate of AI — live resultsblogreleasespromptsgeneratorsresource libraryfor LLMsexplainx.ai kids

solutions

all solutionsdeveloper upskillingmarketing upskillingproduct manager upskillingleadership upskilling

newsletter · weekly

Get AI news, tools, and insights in your inbox.

supportcontactprivacytermsdata rightshow we create contentsubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

On this page

  • What people actually search after the hub post
  • The three loops inside GitHub Copilot
  • Loop 1: VS Code Agent mode (the inner think-act-observe cycle)
  • Loop 2: Copilot CLI Autopilot (the continuation loop)
  • Loop 3: experimental /every and /after (the schedule)
  • Programmatic loops: -p and the SDK agent loop
  • Honest limits
  • What this means for what you build or pay
  • Related reading
← Back to blog

explainx / blog

How to Run Loops in GitHub Copilot: VS Code Agent Mode and Copilot CLI

Run GitHub Copilot loops in VS Code Agent mode and Copilot CLI: think-act-observe, autopilot, experimental /every. Commands, credit burn, honest limits.

Aug 20, 2026·14 min read·Yash Thakker
Loop EngineeringGitHub CopilotVS CodeAI CodingAgent HarnessDeveloper Productivity
go deep
How to Run Loops in GitHub Copilot: VS Code Agent Mode and Copilot CLI

The loop-engineering hub is about designing the program that prompts a coding agent. This post is the Copilot map of that idea — not a rewrite of the hub, and not a clone of Claude Code's /loop skill.

GitHub Copilot already runs an agent loop. In VS Code it is the think-act-observe cycle behind Agent chat. In the terminal it is Autopilot, plus experimental /every and /after on Copilot CLI. If you type Claude Code's /loop 5m babysit my PRs into Copilot and expect the same product, you will be disappointed — and you might still burn credits.

This is the how-to: which Copilot surface is which loop, the copy-paste commands, and what that does to what you build or pay.

TL;DR

table · 2 cols
QuestionAnswer
Does Copilot have Claude Code /loop?No. Use Autopilot for continuation and experimental /every for a session-local schedule.
Fastest IDE loop?VS Code Chat → select Agent → give a verifiable goal. That is the inner tool loop.
Fastest CLI loop?copilot --autopilot --yolo --max-autopilot-continues 10 -p "PROMPT"
Recurring prompt?/every 30m check CI and fix failures after --experimental or /experimental
One-shot delay?/after 10m re-run the failing test
Does /every survive exit?No. The schedule dies with the CLI process. Use cron + copilot -p for overnight work.
What costs money?Every Autopilot continuation is a model call. Credits burn without you clicking.
Sister how-tosCursor · Claude Code · Codex CLI
Weekly digest3.5k readers

Catch up on AI

Curated AI updates on agents, skills, and MCP — delivered to your inbox. Unsubscribe anytime.

Course: Introduction to Loop Engineering covers ReAct, verification, and live loops. Copy-ready prompts live in the loops directory.


What people actually search after the hub post

Three questions show up the moment someone who lives in VS Code reads a Claude-shaped loop guide:

  1. Where is Agent mode, and is that already a loop? Yes — it is the inner tool-calling loop. You still author the outer loop (schedule, cap, stop condition).
  2. What is the Copilot CLI equivalent of /loop 30m …? Experimental /every INTERVAL PROMPT, plus Autopilot so each tick can keep working.
  3. Will this drain my Copilot quota while I am in a meeting? Yes, if Autopilot is on and --max-autopilot-continues is missing.

For the concept layer — observe, act, verify, stop — start with What Is Loop Engineering?. For harness choice, see Claude Code vs Cursor vs GitHub Copilot. This page is only Copilot's knobs.

The three loops inside GitHub Copilot

Treat Copilot as three nested clocks, not one slash command.

table · 4 cols
LoopWhereWhat repeatsWhat stops it
Inner agent loopVS Code Agent mode (and CLI tool-use)Think → act → observe; prompt rebuilt every roundNo more tool calls, tool-call limit, cancellation, stop hooks
Autopilot continuationCopilot CLI AutopilotNew model turns until the task is marked completetask_complete, Ctrl+C, a blocking error, --max-autopilot-continues
Scheduled promptExperimental /every / /afterThe same prompt on a timerYou delete the schedule, or the CLI session exits

Loop engineering is the job of writing those stop conditions on purpose. The coding agent is the subroutine. The agent harness — Copilot in VS Code, Copilot CLI in the terminal — is the car around the model.

On May 15, 2026, Julia Kasper, Megan Rogge, and Aaron Munger wrote the inner loop down in The Coding Harness Behind GitHub Copilot in VS Code:

At its core, when you use an agent in VS Code, a tool-calling loop happens: a "think → act → observe → think again" cycle.

That sentence is Copilot's real /loop. Everything else in this guide is how you keep that cycle running without sitting in the chat box.

How to run loops in GitHub Copilot: a charcoal flywheel with one neon-green spoke completing each rotation, showing Agent mode think-act-observe plus CLI Autopilot

Do not confuse /every with Claude Code /loop

GitHub's schedule-prompts docs currently list /loop as an alias of /every. If you type /loop 30m run tests in Copilot CLI (experimental on), you are scheduling a session-local prompt — the same mechanism as /every. You are not loading Claude Code's bundled /loop skill, worktree babysitting, or cloud /schedule.

On this site, say /every when you mean Copilot. Say Claude Code /loop when you mean the other product. Mixing the names is how teams copy a prompt from the hub and then wonder why nothing runs overnight.


Loop 1: VS Code Agent mode (the inner think-act-observe cycle)

Official concept page: VS Code's Agents docs. The product name in Chat is Agent.

How to start it

  1. Open Copilot Chat in VS Code.
  2. Select Agent (not Ask, not Edit-only — Agent is the one that calls tools in a loop).
  3. Give a verifiable goal, not a vibe: "make npm test pass on this branch" beats "improve the auth module."
  4. Stay on the session. You can send a follow-up to redirect; you do not need to re-select Agent each message.

That is enough to run the inner agent loop. VS Code's own description of the stages is Understand → Act → Validate. A single user turn can contain many rounds. Kasper, Rogge, and Munger define the terms this way:

  • A turn is the chat exchange you see: one message in, a response out.
  • A round is one pass through the harness: rebuild the prompt, call the model, run tools, record results.
  • A run is all the rounds for that turn.

What the harness actually does each round

From the May 15, 2026 harness post — these are the controls you are trusting when you walk away from the editor:

table · 2 cols
Inner-loop controlWhy it matters
Prompt rebuild every roundThe model sees current files, not the tree from three edits ago.
Tool-call limitThe loop cannot spin forever on read_file / run_in_terminal.
Cancellation between roundsStop is a first-class check, not a hope.
Stop hooksExtensions can inspect state and either allow finish or push another round.
SummarizationWhen history blows the context window, earlier rounds compress so the agent can keep going.

You customize that loop with custom agents, agent skills, and hooks — VS Code's customization docs cover personas and lifecycle commands. For Copilot-the-product vs other GitHub Copilot surfaces, Agent mode is still the one that acts.

A prompt that behaves like a loop

Agent mode will iterate, but it will also happily "finish" after a plausible diff if you never name the gate. Paste something with a stop condition:

text
Goal: npm test exits 0 on this branch.

Do this in a loop:
1. Run npm test.
2. If it fails, read the failure, patch only the failing files, run npm test again.
3. Stop when tests pass, or after you have made three unsuccessful fix attempts
   with the same error output.
4. Do not start new features. Do not commit unless I ask.

When you stop, report: tests passing (yes/no), files changed, last error if any.

That is loop engineering inside one Agent turn: action, verification, no-progress cap. The free agent-loop generator will turn a messier workflow into Trigger / Goal / Actions / Verification / Memory if you want the structure first.


Loop 2: Copilot CLI Autopilot (the continuation loop)

Install from GitHub's Copilot CLI install doc. npm requires Node.js 22 or later:

bash
npm install -g @github/copilot

If ignore-scripts=true is in ~/.npmrc:

bash
npm_config_ignore_scripts=false npm install -g @github/copilot

Documented alternatives: brew install --cask copilot-cli (macOS/Linux) and winget install GitHub.Copilot (Windows). First launch: /login, or a fine-grained PAT with Copilot Requests exported as COPILOT_GITHUB_TOKEN / GH_TOKEN / GITHUB_TOKEN.

You need an active Copilot subscription. Org/enterprise admins can disable the CLI in policy — if copilot authenticates and then refuses, that is usually policy, not a broken install.

Shift+Tab: standard / plan / autopilot

In an interactive session, Shift+Tab cycles modes until you reach autopilot, then you type the prompt. Same key cycles back to standard interactive mode.

GitHub's analogy: standard mode is a coworker who checks back; Autopilot is "here's what I need — tell me when you're finished." Autopilot keeps going until one of these is true:

  • The agent determines the task is complete.
  • A problem blocks further progress.
  • You press Ctrl+C.
  • The maximum continuation limit is reached (if you set one).

Autopilot is sticky by default: when a task completes, the next prompt is also Autopilot. Set stayInAutopilot to false via /settings stayInAutopilot false or "stayInAutopilot": false in ~/.copilot/settings.json if you want to fall back to interactive after each task.

Copy-paste: Autopilot from the shell

GitHub's documented programmatic form:

bash
copilot --autopilot --yolo --max-autopilot-continues 10 -p "YOUR PROMPT HERE"
table · 2 cols
FlagMeaning
--autopilotKeep working until task_complete (then return to interactive in a live session).
--yoloAlias of --allow-all: all tools, paths, and URLs without per-call approval.
--max-autopilot-continues 10Hard cap on continuation steps. Put this on every unattended run.
-p / --promptHeadless prompt; CLI processes it and exits (with Autopilot, after the continuation loop).

--allow-all without --autopilot is not Autopilot. It only skips permission prompts. The agent still stops at decision points. --no-ask-user suppresses clarifying questions but, per GitHub, does not continue through successive model turns the way Autopilot does — so it should not spend extra GitHub AI credits without your involvement the way Autopilot will.

Interactive equivalent once you are already in a session:

text
/allow-all

/yolo is the same permission grant. GitHub notes these slash commands do not toggle off — running them again does not revoke permissions.

When Autopilot starts without full permissions, the CLI offers: (1) enable all permissions, (2) continue with limited permissions, (3) cancel. Limited mode auto-denies tools that need approval, which often stalls the loop. Sandbox if you enable all permissions: local sandbox completes in-sandbox work; anything that must leave the sandbox is denied.

Typical workflow: plan, then Autopilot

GitHub's recommended shape:

  1. copilot --allow-all --max-autopilot-continues 10
  2. Trust the folder if prompted.
  3. Shift+Tab to plan, write the outcome, iterate on the plan.
  4. Accept Accept plan and build on autopilot.
  5. Enable all permissions if asked.
  6. Walk away. Check in. Do not skip the continuation cap.

That is the Copilot version of "design the loop, then let the coding agent run inside it."


Loop 3: experimental /every and /after (the schedule)

Official how-to: Scheduling prompts in GitHub Copilot CLI.

These commands are experimental. Enable them with:

bash
copilot --experimental

or, inside a session:

text
/experimental on

GitHub says once experimental mode is on, the setting persists in config so later launches do not need the flag.

Recurring: /every

text
/every INTERVAL PROMPT
text
/every 1h run the test suite and summarize any new failures
text
/every 30m check for new comments on my open pull requests

The prompt fires after the first interval, then on that cadence until you delete the entry or end the session.

One-shot: /after

text
/after DELAY PROMPT
text
/after 30m Give me details of changes to README.md made in the last 30 minutes

The prompt fires once, then drops off the list.

Interval syntax

table · 3 cols
SuffixUnitExample
sseconds30s
mminutes5m
hhours2h
ddays1d

A bare number is minutes. Minimum interval is 10 seconds. Maximum is 1 day (24 hours).

You can schedule a user-invocable skill (/every 1d /refactor-plan …). You cannot schedule built-in commands such as /clear.

Triggered prompts show a tag like [Scheduled prompt #4]. GitHub documents cancelling by id (for example stop prompt 4). A bare /every or /after opens the session's schedule manager (list and remove). Do not treat that dialog as a place to add jobs — add from the prompt line with arguments.

Session-local: this is the limit that surprises people

Schedules live on that CLI process. Close the terminal and they stop. --continue / --resume restarts them, with the next interval measured from reopen. An /after that never fired can still fire after the delay in the reopened session.

That is not cron. For a prompt with no human session, GitHub's own escape hatch is an external scheduler calling:

bash
copilot -p "YOUR PROMPT"

Overnight CI babysitting belongs there, usually with Autopilot flags:

bash
copilot --autopilot --yolo --max-autopilot-continues 8 -p "Run npm test. If it fails, fix only failing tests. Stop when green or after 8 continues. Summarize."

Wire that to cron / Task Scheduler / CI. /every is for a focused block while the TUI stays up.

/goal and /fleet on Copilot CLI

/goal exists on Copilot CLI too (experimental, aliased with /autopilot [OBJECTIVE] in the command reference). Example shape:

text
/goal Refactor the auth module --max-ai-credits 5

When the credit cap hits, Autopilot pauses and shows usage against the cap. /goal on / /goal off toggle Autopilot without setting an objective and do not take --max-ai-credits. This is Copilot's /goal, not Claude Code's.

/fleet fans out parallel subagents. Use it when a tick of /every is "analyze security, performance, and a11y" — not as a substitute for a stop condition.


Programmatic loops: -p and the SDK agent loop

-p / --prompt is the CLI's non-interactive entry. Combine it with --autopilot when you want the continuation loop, not a single shot.

The Copilot SDK is a JSON-RPC transport. GitHub's agent-loop doc is explicit: the CLI runs the tool-use loop; the SDK does not. Each iteration is one LLM API call (assistant.turn_start / assistant.turn_end). There are no hidden planning calls.

Two completion signals:

table · 3 cols
SignalGuaranteeUse it for
session.idleAlways emitted when the tool-use loop ends. Ephemeral."The agent stopped processing." sendAndWait() waits on this.
session.task_completeOptional. Model must signal it. Persisted. May include a summary."The agent thinks the overall task is done." Best-effort.

Autopilot nudges for task_complete. If the tool-use loop ends without that call, the CLI injects a synthetic user message (GitHub's wording): you have not marked the task complete with the task_complete tool; stop planning and implement; you are not done until the task is fully completed. That restart is another billed loop. The nudge also tells the model not to call task_complete while questions, errors, or remaining steps are open.

In ordinary interactive chat the CLI does not nudge. The model may answer and idle without ever emitting task_complete. For scripts, wait on session.idle (and session.error); treat task_complete as semantic, not mechanical.

typescript
session.on("session.task_complete", (event) => {
  console.log("Task done:", event.data.summary);
});

Count LLM calls with the session event log GitHub documents:

bash
grep -c "assistant.turn_start" ~/.copilot/session-state/<sessionId>/events.jsonl

That count is the credit-relevant loop length.


Honest limits

  • /every is not a daemon. Laptop lid, SSH drop, or exit kills the schedule. Teams that treat it like systemd will miss ticks and then over-correct with tighter intervals, which only burns more credits when the session is up.
  • Experimental means the surface can move. Command shape, schedule-manager keys, and /goal credit panels can change. Design the prompt and the cap so you can retarget cron tomorrow.
  • --yolo is a permission grant, not a quality grant. Autopilot with full permissions can edit and delete files. GitHub's Autopilot doc says you should know that before you enable it. Prefer a sandbox or a throwaway worktree for the first unattended run.
  • Vague goals produce expensive junk. GitHub says Autopilot is for well-defined tasks (tests, refactors, CI failures), not open-ended product exploration. A loop with nothing that can say no — tests, types, a real error — is the agent agreeing with itself. That warning is as old as the hub post.
  • Limited permissions stall Autopilot. Auto-deny on approval-gated tools looks like a hung agent. It is often the permission mode.
  • Sticky Autopilot surprises the next prompt. If you forget you are still in Autopilot, the next one-liner also continues until task_complete.
  • VS Code Agent mode is still one chat turn's inner loop. It will iterate tools. It will not re-wake at 2 a.m. unless you add CLI Autopilot, /every, or an external scheduler.
  • Do not scrape Copilot UI screenshots into internal wikis as if they were your IP. GitHub/VS Code chrome is their UI. Use this post's commands and the flywheel diagram; keep your own terminal output if you need a screenshot.

What this means for what you build or pay

Copilot loops change who clicks, not whether tokens are billed.

GitHub's Autopilot documentation states the cost clearly: each interaction consumes AI credits from tokens processed, and in Autopilot Copilot initiates those interactions without your direct involvement. --max-autopilot-continues is a loop-engineering control, not a nicety. Experimental /goal … --max-ai-credits N is the dollar-shaped twin of that cap.

What to actually do:

table · 2 cols
If you…Pay / build implication
Run Agent mode on a greenfield spikeYou are in the inner loop. Cost is visible because you are watching. Verification still matters.
Run Autopilot on a flaky suite with no continuation capContinuations can chew a month of premium requests in an afternoon. Set the cap. Prefer a worktree.
Use /every 10s because "tighter is better"You will pay for idle ticks. Match interval to how fast the world changes (CI, PR comments). Floor is 10s; that does not mean you should use 10s.
Put copilot --autopilot --yolo -p in CIYou are now running an unattended agent harness on a bot identity. Scope the PAT, cap continues, and fail the job on session.error.
Need overnight PR babysittingDo not use /every. Use cron/CI + -p, or a sibling harness whose scheduler is actually durable — Claude Code loops, Cursor, Codex CLI.
Already pay for Copilot seatsAutopilot does not add a second product SKU; it spends the same credit pool faster. Budget the loop, not the seat.

If the honest answer is "we cannot name a test that would stop this," do not Autopilot it. Write a better Agent-mode prompt, or do not loop.


Related reading

This series

  • How to run loops in Cursor
  • How to run loops in Claude Code
  • How to run loops in Codex CLI
  • Claude Code vs Cursor vs GitHub Copilot

Loop engineering

  • Loop Engineering: coding agent loops that run while you sleep
  • What Is Loop Engineering for AI Agents?
  • How to build your first agent loop
  • How to turn agent skills into loops
  • explainx.ai loops directory
  • Loop Engineering course

Copilot

  • GitHub Copilot SDK: multi-platform agents

Official docs (GitHub / VS Code)

  • VS Code: Agents (agent loop, subagents, memory, planning)
  • The coding harness behind GitHub Copilot in VS Code (Julia Kasper, Megan Rogge, Aaron Munger, May 15, 2026)
  • Copilot CLI Autopilot
  • Scheduling prompts (/every, /after)
  • Install Copilot CLI
  • SDK agent loop (task_complete)

Dictionary: loop engineering · agent loop · GitHub Copilot · coding agent · agent harness

Copilot CLI flags, experimental /every / /after / /goal, Autopilot credit behavior, and VS Code Agent harness details are accurate as of August 20, 2026 against GitHub and VS Code documentation. Experimental surfaces change; re-check the linked official pages before you wire unattended jobs.

Spotted something out of date? Let us know.
Yash Thakker

Written by

Yash Thakker

Yash is an AI expert with over 300K learners. Join his workshops →

Related posts

Jun 9, 2026

Loop Engineering: How to Design Coding Agent Loops That Run While You Sleep (2026 Guide)

Peter Steinberger's June 8 tweet—6.5M views—said stop prompting agents and start designing loops. This guide answers the thread's top question ("how do we do that?") with lineage, /loop examples, verification, and guardrails.

Aug 14, 2026

A Real Claude Code Loop Orchestrator: Heartbeats, Tickets, and Silent Bugs

u/croovies posted a working Claude Code loop orchestrator ("Lloyd," built on scape.work) that checks email, scans app logs for silent bugs, and manages 600+ tickets in a SQLite table every heartbeat. explainx.ai breaks down the pattern — heartbeat vs cron, read-only investigation agents, and a ticket-memory schema you can replicate with plain Claude Code.

Aug 20, 2026

Cursor Ships Event-Driven Cloud Agents and Isolated VMs for AI Coding Swarms

Cursor pushed a changelog update on August 19, 2026 that lets cloud agents "subscribe" to an event source — a PR, a Slack thread, a cron schedule — and wake up when something happens, instead of waiting for a manual prompt. Paired with subagents that each get their own isolated VM, it adds up to what Cursor is calling AI coding swarms. Here's what's actually new, what it costs, and how it compares to Claude Code and Codex's own cloud agent options.