LoopGuard

April 8, 2026 · View on GitHub

LoopGuard

LoopGuard

Stop wasting time and money on AI coding loops.

VS Code Marketplace Installs Build License: MIT


LoopGuard is a local-first VS Code extension that catches repeated AI-assisted fix loops before they silently consume your next half hour — and keeps prompts dramatically smaller so you spend less on tokens.

The Problem

You paste an error into Claude, Copilot, or Cursor. You apply the fix. The same error comes back. You paste it again. Twenty minutes later you're still in the same loop, burning time and API credits on identical context.

LoopGuard catches this automatically, shows you how long you've been stuck, and gives you a focused context snapshot instead of the whole file.

What It Does

Loop detectionWatches VS Code diagnostics and edit patterns — alerts when you've hit the same error multiple times
Sidebar panelPersistent Activity Bar panel (VS Code, Cursor, Windsurf) — live session metrics without opening a separate window
Time wasted counterShows elapsed loop time in the status bar so the cost is always visible
Focused context copyCopies only the relevant lines around the current error, not the whole file
MCP integrationExposes a local loopguard-ctx helper for Claude Code, Cursor, Windsurf, and Codex CLI
Shell hooksCleans terminal output before it reaches AI models
Web dashboardOptional sync of anonymized session metrics — source code never leaves your device

Install

VS Code Marketplace:

ext install LoopGuard.loopguard

Search LoopGuard in the Extensions sidebar, or install from the Marketplace page.

Quick Start

Editor

  1. Install the extension — it activates automatically on workspace open.
  2. Work normally. When you hit a loop, the status bar shows time wasted and an alert fires.
  3. Run LoopGuard: Copy Optimized Context to get a focused prompt instead of pasting the whole file.

Agent / MCP

  1. Install the local helper:
    # Homebrew (macOS / Linux)
    brew tap rodthenewcomer/loopguard https://github.com/rodthenewcomer/loopguard
    brew install loopguard-ctx
    
    # npm (any platform with Node 16+)
    npm install -g loopguard-ctx
    
    # curl
    curl -fsSL https://loopguard.vercel.app/install.sh | sh
    
  2. Wire your agent in one command — installs MCP config, hooks, CLAUDE.md rules, and shell aliases:
    loopguard-ctx setup --agent=claude   # Claude Code
    loopguard-ctx setup --agent=cursor   # Cursor
    loopguard-ctx setup --agent=codex    # Codex CLI
    loopguard-ctx setup                  # All detected editors
    
  3. Verify every layer is green:
    loopguard-ctx doctor
    

Commands

CommandWhat It Does
LoopGuard: Show DashboardOpen the in-editor session overview
LoopGuard: Copy Optimized ContextCopy focused context for the current file and error
LoopGuard: Configure MCP ServerSet up the local MCP helper for your AI tool
LoopGuard: Install Shell HooksAdd shell hooks to clean output before AI calls
LoopGuard: Focus SidebarOpen or focus the sidebar panel in the Activity Bar
LoopGuard: Reset SessionClear loop state and timer
LoopGuard: Toggle DetectionPause or resume loop detection
LoopGuard: Sign InOptional — enables web dashboard sync

Advanced Helper Tools

Available via loopguard-ctx MCP to all supported tools (Claude Code, Cursor, Windsurf, Codex CLI):

ToolWhat It Does
ctx_loop_hint(error_text) / loopguard-ctx hint "<error>"Root cause hint — diagnoses the error pattern, returns fix suggestion. No LLM call.
ctx_forecast(task) / loopguard-ctx forecast "<task>"Token cost estimator — complexity + cost table across Sonnet, Haiku, GPT-4o, Gemini Flash
ctx_memory(action, ...) / loopguard-ctx memory <action>Local fix memory — record/query/list fix patterns. Shown in extension dashboard.
ctx_predict(task, path?) / loopguard-ctx predict "<task>"Predictive file ranking — scores workspace files by relevance before any reads

Session protocol (Claude Code / Cursor / Windsurf):

1. ctx_session load     — restore previous task + findings
2. ctx_forecast(task)   — estimate token cost before starting
3. ctx_predict(task)    — rank relevant files before reading
4. ctx_overview(task)   — get project map for context
5. ctx_wrapped          — session savings summary at end

After resolving a loop:

ctx_memory(action="record", error_text="...", fix_file="file:line", fix_description="what fixed it")

Settings

SettingDefaultDescription
loopguard.sensitivitymediumLoop trigger speed: low (5 hits), medium (3), high (2)
loopguard.loopThreshold3Custom count, overrides sensitivity preset
loopguard.enableContextEnginetrueFilter context before AI calls
loopguard.enableNotificationstrueShow popup alerts on loop detection

Supported Editors & Workflows

  • VS Code
  • Cursor
  • Windsurf
  • Codex CLI
  • Claude Code
  • GitHub Copilot (VS Code MCP)
  • bash · zsh · fish (via shell hooks)

Privacy

Your code never leaves your machine.

Loop detection and context selection run entirely locally. If you sign in, the backend stores only anonymized metrics — loop counts, session durations, token-saved estimates. No source code, no file contents.

Full policy: loopguard.vercel.app/privacy

Honest Positioning

  • LoopGuard cuts focused prompt size by 70%+ in normal use, especially with the native helper active.
  • The 93% figure in product copy is a measured high-end result, not a universal promise.
  • Exact savings vary by file, workflow, and read mode.
  • The value is not compression — it is saving time, trimming tokens, and making AI sessions cheaper to run.

Roadmap

VersionStatusFocus
v1 — Extension CoreShippedLoop detection, status bar, focused context copy, VS Code/Cursor/Windsurf
v2 — CLI + Sync PipelineShippedloopguard-ctx binary, MCP tools, Homebrew, anonymous device sync, /wrapped
v3 — Intelligence LayerShippedRoot cause hints, predictive context, session memory, cost forecasting, sidebar panel
v4 — Multi-session MemoryIn developmentCross-session pattern memory, proactive loop prediction, smarter context recall

Full details at loopguard.vercel.app/roadmap.

Architecture

apps/
  extension/        VS Code extension — core product (TypeScript)
  web/              Next.js landing page + web dashboard
  api/              Auth, sync, and support APIs (Supabase + Express)

packages/
  core/             Loop detection + context selection logic
  context-engine/   Native Rust helper binary + MCP tooling
  types/            Shared TypeScript interfaces
  utils/            Shared utilities

Key constraints:

  • Core runs locally — no cloud round-trips required
  • Extension activates in < 500ms, loop checks in < 5ms
  • Backend stores no source code — anonymized metrics only

Development

npm install
npm run build
npm run type-check
cd apps/web && npm run dev           # web dashboard
cd apps/extension && npm run build   # extension
cd packages/context-engine/rust && cargo check  # Rust binary

License

MIT — see LICENSE.