# Cline, Roo Code & Open-Source VS Code Agents

> Run transparent, BYOK, and local-model coding agents inside standard VS Code using Cline, Roo Code custom modes & Boomerang orchestration, Kilo Code, checkpoints, and MCP tools—with zero vendor lock-in.

- **Topic:** [AI Code Editors & IDEs](https://twelve-pages.com/topics/ai-ides)
- **Web Edition:** https://twelve-pages.com/guides/ai-ides/cline-roo-code-and-open-vscode-agents
- **Printable 12-Page PDF:** https://twelve-pages.com/guides/ai-ides/cline-roo-code-and-open-vscode-agents/Cline_Roo_Code_and_Open_VS_Code_Agents_Complete_How_To_Guide.pdf (829 KB)
- **Version:** v1.0 (Updated 2026-11)
- **Reading Time:** 12 minutes (12 pages)
- **Authorship:** AI-authored under human editorial direction & print QA (https://twelve-pages.com/editorial)
- **Tags:** Plan / Act Dual-Model · Custom Modes & .roomodes · Boomerang Sub-Tasks · BYOK & Local Ollama · Shadow Git Checkpoints · MCP & Browser Use

## Core Takeaways

- **Zero Vendor Lock-In:** Keep standard VS Code and your extensions. Route every turn via OpenRouter, Bedrock, Vertex AI, or local Ollama with raw API pricing.
- **Isolated Orchestration:** Split reasoning from execution using Cline Plan/Act or Roo/Kilo Orchestrator Boomerang sub-tasks with clean context windows.
- **Reversible Autonomy:** Every file edit and shell command lands inside a Shadow Git checkpoint with one-click diffing, headless browser checks, and hard cost caps.

## 1. Transparent, BYOK Autonomy Inside Standard VS Code

Proprietary AI IDE forks bundle hidden prompts, opaque credit meters, and fixed model menus. Open-source VS Code agents—led by Cline, the Roo Code custom-mode architecture, and its OpenCode-powered successor Kilo Code—keep you inside stock VS Code while exposing every token, diff, tool call, and API dollar in real time.

**Golden Rule: Inspect, Cap, Rollback**

### The Open-Source VS Code Agent Execution Loop

Whether you run Cline's `Plan/Act` split or Roo/Kilo's `Orchestrator` mode, every autonomous task flows through four transparent, user-controlled layers with zero hidden cloud proxy required:

#### A Why Open VS Code Agents Win

You retain native VS Code Remote-SSH, Dev Containers, and enterprise compliance. API keys stay in VS Code Secret Storage, traffic hits your chosen VPC endpoint (Bedrock/Vertex) or local GPU, and every prompt-cache hit is visible down to `$0.001`.

#### B The Context-Budget Discipline

Agent quality degrades sharply once a single thread crosses ~45% context fill. Open agents counter this with `/deep-planning`, **Intelligent Context Condensation**, and Boomerang sub-tasks that discard scratchpad noise and return only distilled summaries.

## 2. Open VS Code Agent Decision Matrix (Late 2026)

Cline, Roo Code, and Kilo Code share a common open-source lineage, while Continue anchors inline autocomplete. Understanding their late-2026 architecture and maintenance status prevents choosing a stalled workflow.

| Extension | 2026 Status & Engine | Orchestration & Modes | Cost Control & BYOK | Best-Fit Role |
| --- | --- | --- | --- | --- |
| **Cline** `saoudrizwan.claude-dev` | **Active (v4 + SDK)** Apache-2.0 original; 11M+ devs; VS Code, CLI & Desktop beta. | Explicit **Plan / Act** split with separate models per mode, `/deep-planning`, Shadow Git Checkpoints, Browser Use & MCP Marketplace. | 100% BYOK (OpenRouter, Bedrock, Vertex, Ollama, LM Studio) + live token/cache meter & max-request limits. | **Default primary agent** for transparent human-in-the-loop coding, enterprise VPCs, and MCP workflows. |
| **Roo Code** `rooveterinaryinc.roo-cline` | **Sunset May 2026** Commercial project ended; open-source forks & `.roomodes` spec live on. | Pioneered **Custom Modes** (Architect, Code, Ask, Debug, Orchestrator), **Boomerang sub-tasks**, `fileRegex` locks & Context Condensation. | Per-mode API profiles (e.g., Frontier Architect + local Ollama Coder) + per-task dollar & request caps. | **Reference pattern** for multi-mode specs; existing teams migrate `.roomodes` to Kilo Code or community forks. |
| **Kilo Code** `kilocode.kilo-code` | **Active (v7 OpenCode)** Former Roo fork rebuilt on OpenCode engine (GA Apr 2026); IDE + CLI + Cloud. | Full Custom Modes & Orchestrator parity with Roo Code, 15–30 min `.roomodes` migration, JetBrains & cloud sessions. | 500+ models at zero markup, full BYOK & local Ollama support, granular auto-approve & budget alerts. | **Best drop-in successor** for teams wanting Roo-style custom modes, Boomerang flows & active updates. |
| **Continue** `continue.continue` | **Acquired by Cursor** Open-source VS Code & JetBrains extension; light local-model footprint. | Inline Tab autocomplete, Chat, Edit & basic Agent mode; shines with small 7B–14B local FIM models via `config.yaml`. | Zero-cost local Ollama / LM Studio FIM completions + BYOK chat; minimal token overhead per keystroke. | **Companion Tab engine** installed alongside Cline or Kilo Code (which focus on multi-file tasks, not FIM). |

### The 2026 Family Tree & Recommended Pairing Strategy

#### 1 Solo & Enterprise Standard

Install **Cline v4** for structured Plan/Act tasks, strict approval gates, and AWS Bedrock / Vertex AI compliance. Pair with local **Continue** (Qwen2.5-Coder 7B FIM) for instant zero-cost Tab autocomplete.

#### 2 Multi-Mode Power User

Run **Kilo Code v7** (or a maintained Roo fork) when your repo relies on `.roomodes`, `fileRegex` edit locks, and Boomerang Orchestrator delegation across Architect, Code, Test, and Docs personas.

#### 3 100% Air-Gapped Local

Use **Cline** or **Kilo Code** pointed at local **Ollama / LM Studio** running a &ge;22B–32B tool-calling coder (e.g., Qwen3-Coder 30B-A3B or Devstral) with telemetry off and browser tools disabled.

#### Migrating Legacy Roo Code Repos in Late 2026

If your team still uses Roo Code's `.roomodes` and `.roo/rules/` directories, you do not lose your investment: **Kilo Code v7** natively imports Roo custom modes, `fileRegex` guards, and MCP server JSON configs in under 30 minutes, while **Cline** reads shared Markdown instructions via `.clinerules/` with minimal syntax changes.

## 3. The 7-Control Open Agent Sidebar HUD

Master these seven live controls in the Cline / Roo / Kilo VS Code sidebar to monitor token burn, enforce least-privilege approvals, inspect Shadow Git diffs, and steer multi-step runs without babysitting every click.

**VS CODE • CLINE / ROO AGENT SIDEBAR**

Task #482 MCP: 3 Active

Live Context & Cost Meter $0.14 / $1.00 cap

Context: 72k / 200k (36%) Cache Hit: 84% (&minus;$0.41 saved)

**Mode & Profile:** Plan (Sonnet 4.6) Act (Qwen3-Coder)

▾ Orchestrator

Checkpoint #4 • Shadow Git

Compare Restore ↺

Snapshot after `src/auth/jwt.ts` edit • Main git tree untouched

Auto-Approve Toggles Max Req: 15

✓ Read ✓ Safe Cmds ✗ Edit Files ✗ Browser

`@file:src/api.ts` `@problems` `@git-changes` Refactor token refresh & add Vitest coverage...

Rules active: `.clinerules/01-ts.md` Send ⏎

Streaming Diff & Approval Gate src/auth/jwt.ts

14 export function verifyToken(raw: string) {

-15 return jwt.verify(raw, process.env.SECRET!);

+15 return jwt.verify(raw, getSigningKey(), {

+16 algorithms: ["RS256"], clockTolerance: 5

+17 });

18 }

Approve Edit Reject + Feedback

Shell Integration & MCP Drawer Exit 0 (1.8s)

$ pnpm vitest run src/auth/jwt.test.ts
 ✓ 14 passed (14) • MCP: `postgres-ro` queried schema

#### 1 Live Token, Cache & Dollar Meter

Tracks input/output tokens, prompt-cache savings, and cumulative task spend. Trigger Context Condensation or start a fresh Boomerang task before the bar crosses 60%.

#### 2 Plan / Act & Custom Mode Switcher

Swaps both system prompt and API provider profile in one click—e.g., Frontier reasoning in `Plan/Architect`, cheap/local models in `Act/Code`.

#### 3 Shadow Git Checkpoint Strip

Commits workspace state to an isolated shadow repo after every tool call. Click **Compare** to view VS Code's multi-file diff or **Restore** to rewind files and/or chat.

#### 4 Granular Auto-Approve & Max Requests

Separately gates workspace reads, file edits, safe vs. arbitrary shell commands, MCP calls, and browser actions. Set `Max Requests` to pause runaway loops.

#### 5 Deterministic `@` Context Mentions

Pin exact files (`@file`), VS Code diagnostics (`@problems`), terminal output (`@terminal`), or uncommitted diffs (`@git-changes`) instead of letting the agent grep blindly.

#### 6&thinsp;7 Diff Gate, Shell & MCP Telemetry

Every patch streams into VS Code's native diff viewer before disk write, while VS Code Shell Integration captures exit codes and MCP server payloads automatically.

## 4. Plan/Act, Custom Modes & Boomerang Sub-Tasks

Single-thread agents fail on large refactors because planning chatter, test logs, and failed diffs pollute one overflowing context window. Open VS Code agents solve this with two complementary patterns: Plan/Act and Boomerang Orchestration.

*[Illustration: Isometric illustration of Boomerang orchestration dispatching arcs from a central violet hub to isolated amber Architect, teal Code, and magenta Debug glass chambers]*

**Boomerang Delegation:** The central `Orchestrator` pauses the parent thread, spawns an isolated child task in a specialized mode (Architect, Code, or Debug), and receives only a compact completion summary back—keeping parent context clean.

#### 1 Cline's Plan / Act Split (+ `/deep-planning`)

- **Plan Mode (Read-Only):** Agent inspects files, traces symbols, and writes an explicit markdown blueprint. Zero file edits or shell mutations allowed.
- **Act Mode (Execution):** Flip the toggle once the plan is approved; Cline executes step-by-step using a faster/cheaper coding model if dual-model routing is enabled.
- **Best for:** 1–15 file features, bug fixes, and interactive architecture reviews where you stay in one thread.

#### 2 Roo / Kilo Boomerang Sub-Tasks

- **Orchestrator Mode:** Decomposes epics into sequential child tasks using the `new_task` tool.
- **Fresh Context Windows:** Each child (`architect` -> `code` -> `debug`) starts at 0% context fill with mode-specific rules and its own API profile.
- **Distilled Handoff:** When the child calls `attempt_completion`, only its concise summary boomerangs back to the parent Orchestrator.

### The 5 Built-In Custom Modes & Handoff Chain

| Mode Slug | Allowed Tool Groups | Ideal Model Tier | When to Dispatch via Boomerang |
| --- | --- | --- | --- |
| `orchestrator` | Task delegation only (no direct edits) | Frontier Planner (Claude / GPT-5 / Gemini Pro) | Multi-module epics requiring 3+ isolated implementation and verification phases. |
| `architect` | `read`, `edit` (`\.md$` only), `mcp` | High-reasoning model w/ extended thinking | Drafting RFCs, migration checklists, and API contracts before touching source code. |
| `code` | `read`, `edit`, `command`, `mcp` | Fast coder (Sonnet, DeepSeek, Qwen3-Coder) | Implementing one bounded spec module + unit tests inside a clean context window. |
| `debug` | `read`, `edit`, `command`, `browser` | High-reasoning + log/stacktrace specialist | Reproducing flaky tests, reading headless browser console errors, and isolating root causes. |
| `ask` | `read`, `mcp` (strictly read-only) | Fast/local model (Ollama / Flash / Mini) | Onboarding Q&A, tracing call graphs, and explaining legacy code with zero mutation risk. |

## 5. 5-Part Anatomy of .roomodes & .clinerules/

Commit mode definitions and rules straight into Git so every teammate's VS Code agent inherits identical architectural guardrails, file-edit boundaries, and style conventions automatically.

#### Color-Coded `.roomodes` Specification (Project Root • Validated JSON/YAML Tuple Format)

customModes:
 - slug: "test-writer" | name: "QA Test Engineer"
 roleDefinition: "You write deterministic Vitest & Playwright tests with zero flaky sleeps."
 groups:
 - "read" - "command" - "mcp"
 - [ "edit", { fileRegex: "\\.(test|spec)\\.(ts|tsx)$", description: "Test files only" } ]
 customInstructions: "Run pnpm test:unit after every edit; never modify src/ production files."

#### 1 Slug & Name

Kebab-case `slug` binds the mode to its rule folder (`.roo/rules-test-writer/`) and lets Orchestrator dispatch it by exact identifier.

#### 2 Role Definition

Replaces the base persona prompt. Keep it crisp (&le;2 sentences) so you do not waste system tokens on every turn.

#### 3 Tool Groups

Grants only the minimum capability tuple from `read`, `edit`, `command`, `browser`, and `mcp`.

#### 4 Tuple `fileRegex` Write Lock

Enforces hard filesystem sandboxing at the tool layer. If a QA or Docs mode attempts to edit `src/billing.ts`, the extension blocks the write before touching disk—even if the LLM hallucinates.

#### 5 Mode & Workspace Rules

Appends project-specific build commands, linting contracts, and verification loops. Keep under ~1,200 tokens total so prompt caching stays hot.

### Directory Precedence: `.clinerules/` vs. `.roo/rules/`

| Rule Location | Agent | Load Order & Scope | Best Practice |
| --- | --- | --- | --- |
| `.clinerules/*.md` | Cline | Workspace alphabetical; toggleable per file in UI | Split into numbered files: `01-architecture.md`, `02-testing.md`, `03-security.md`. |
| `~/.roo/rules/` | Roo / Kilo | Global user defaults across all repositories | Store personal preferences (concise diffs, commit style, preferred package manager). |
| `.roo/rules/` | Roo / Kilo | Workspace-wide; overrides global rules | Repo invariants: TypeScript strictness, monorepo filter flags, forbidden libraries. |
| `.roo/rules-{slug}/` | Roo / Kilo | Mode-specific; loaded only when `slug` is active | Load heavy domain checklists (e.g., SQL migration safety) only when needed to save tokens. |

#### Cross-Agent Rule Portability Tip

Store your core repository engineering standards in a single canonical `AGENTS.md` or `docs/agent-rules.md` file, then symlink or reference it from both `.clinerules/00-core.md` and `.roo/rules/00-core.md` so Cline, Kilo Code, and CLI agents never drift out of sync.

## 6. BYOK Multi-Provider & Local Model Routing

Paying frontier reasoning rates for boilerplate edits burns budgets fast. Open VS Code agents let you assign a Frontier Planner to Plan/Architect mode and a Fast API or Local Ollama Coder to Act/Code mode—cutting daily spend by 60–85% while keeping architectural rigor intact.

### Provider Routing Matrix

| Provider | Strengths & Compliance | Prompt Caching & Cost | Recommended Role in VS Code |
| --- | --- | --- | --- |
| **OpenRouter** | Single API key for 300+ models; automatic fallback routing & zero-data-retention (ZDR) filter. | Passes through Anthropic/DeepSeek/Gemini caching; pay exact provider rates + small routing fee. | Best all-in-one BYOK hub for switching between Claude, GPT-5, Gemini, and open-weight coders. |
| **AWS Bedrock & Vertex AI** | IAM / ADC auth, VPC private endpoints, SOC2/HIPAA/BAA, zero training on prompts. | Native prompt caching on Claude & Gemini; billed directly to existing cloud commit. | Enterprise default for regulated codebases; configure via AWS Profile or `gcloud` credentials. |
| **Ollama / LM Studio** | 100% offline local inference on Apple Silicon (M3/M4 Max) or RTX 4090/5090 GPUs. | **$0.00 marginal token cost**; KV-cache reuse across consecutive turns. | Private Act/Code execution, Ask mode Q&A, and offline travel coding with 22B–70B tool-calling models. |
| **Direct Anthropic / OpenAI / DeepSeek** | Lowest latency, earliest access to new thinking budgets & native structured tool calls. | Up to **90% discount** on cached system prompts & repo context reads. | High-precision Plan/Architect & Debug modes where 1-shot accuracy beats cheaper retries. |

### The Dual-Model Playbook (How to Cut Agent Spend by ~75%)

#### 1 Tiered Mode Assignment

- **Plan / Architect / Debug:** Frontier model (e.g., Claude Sonnet/Opus, GPT-5, Gemini Pro) to analyze architecture, catch edge cases, and write crisp diffs.
- **Act / Code / Test-Writer:** High-throughput value coder (DeepSeek-V3/R1, Qwen3-Coder via OpenRouter, or local Ollama `qwen3-coder:30b`).
- **Ask / Commit / Docs:** Ultra-fast mini/flash or local 14B model.

#### 2 Local Ollama Setup for Reliable Tool Calls

```
<code># 1. Pull a tool-calling coder (>=22B recommended)
ollama pull qwen3-coder:30b

# 2. Override default 4k context (CRITICAL for agents!)
OLLAMA_CONTEXT_LENGTH=32768 OLLAMA_FLASH_ATTENTION=1 \
  OLLAMA_KV_CACHE_TYPE=q8_0 ollama serve

# 3. In Cline/Kilo Provider Settings:
# Provider: Ollama | Base URL: http://localhost:11434
# Context Window: 32768 | Diff Strategy: Search/Replace</code>
```

#### Prompt Caching Golden Rule: Never Churn System Prompts Mid-Task

Anthropic, Gemini, and DeepSeek prompt caches drop to 0% hit rate whenever the prefix changes. Avoid toggling MCP servers or editing `.clinerules/` mid-conversation, and keep active MCP tool schemas lean (&le;25 tools total) so your static prefix stays cached for 5–60 minutes at a 75–90% input discount.

## 7. Shadow Checkpoints, Headless Browser & MCP Tools

Three open-agent superpowers turn VS Code into a self-verifying engineering loop: Shadow Git Checkpoints for fearless rollback, Headless Browser Use for visual/DOM QA, and Model Context Protocol (MCP) for live external tools.

*[Illustration: Isometric illustration of a reversible violet and teal checkpoint timeline rail connected to a frosted-glass browser verification sandbox with three glowing MCP cables]*

**Reversible Closed-Loop Verification:** Shadow Git captures every intermediate state in VS Code global storage while the agent inspects live DOM renders and queries MCP servers—letting you branch or rewind without touching your real Git history.

#### 1 Shadow Git Checkpoints

Stored inside VS Code's global storage (separate from your repo's `.git`). Every tool execution creates an atomic snapshot.

- **Compare:** Multi-file VS Code diff vs. workspace.
- **Restore Files & Task:** Full rewind to retry cleanly.
- **Restore Task Only:** Keep code, rephrase prompt.

#### 2 Headless Browser Use

Launches local Chromium to load `localhost:3000`, click UI flows, capture screenshots, and stream console/network errors back to the agent.

- Catches CSS regressions & hydration errors automatically.
- Restrict to `localhost` / staging to block prompt injection.

#### 3 MCP Marketplace & Servers

Connects stdio or Streamable HTTP/SSE servers directly to Cline, Roo, or Kilo—giving the agent structured tools instead of brittle bash scraping.

- **High-ROI Servers:** Context7 docs, GitHub, Postgres (RO), Sentry, Playwright.
- Disable unused servers per workspace to save context tokens.

#### Monorepo Performance Tip: Exclude Build Artifacts from Shadow Git

In giant monorepos (50k+ files), Shadow Git checkpoint initialization can slow down or time out if untracked build directories are scanned. Ensure `node_modules/`, `dist/`, `.next/`, and `target/` are in `.gitignore`, or disable Checkpoints in Feature Settings and rely on lightweight `git stash` / worktrees for multi-gigabyte repos.

## 8. 5 Battle-Tested .roomodes, .clinerules & MCP Recipes

Drop these verified, minimal configurations straight into your repository root to unlock file-locked custom modes, strict coding standards, and read-only MCP database/docs tooling on day one.

| Recipe | Target File Path | What It Enforces |
| --- | --- | --- |
| **1. Docs-Only Architect** | `.roomodes` | Blocks all source code edits via `fileRegex: "\\.md$"` so planning never mutates `src/`. |
| **2. Strict TS + Test Gate** | `.clinerules/01-stack.md` | Forces strict TypeScript, zero `any`, and mandatory `pnpm test` before task completion. |
| **3. Boomerang Epic Prompt** | Orchestrator chat input | Splits a feature into Architect -> Code -> QA sub-tasks with clean context handoffs. |
| **4. Read-Only MCP Stack** | `cline_mcp_settings.json` | Wires Context7 live docs + read-only Postgres with auto-approved read tools only. |
| **5. Secret & Artifact Shield** | `.clineignore` / `.rooignore` | Hides `.env*`, PEM keys, lockfiles, and build folders from context indexing. |

### Recipe 1 & 2: `.roomodes` + `.clinerules/01-stack.md`

```
<code># .roomodes (Roo Code / Kilo Code)
customModes:
  - slug: spec-architect
    name: "Spec Architect"
    roleDefinition: "Draft concise RFCs and file plans."
    groups:
      - read
      - - edit
        - fileRegex: "\\.md$"
          description: "Markdown specs only"
    customInstructions: "List exact files & test cases."</code>
```

```
<code># .clinerules/01-stack.md
- Runtime: Node 22, TypeScript 5.8 (strict, zero `any`).
- Package manager: `pnpm` only (never run `npm install`).
- Verification: Before `attempt_completion`, run:
  `pnpm typecheck && pnpm vitest run <touched-tests>`.
- Diffs: Keep functions <50 lines; never touch `.env*`.</code>
```

### Recipe 4 & 5: MCP Settings + Ignore Shield

```
<code>// cline_mcp_settings.json (or .roo/mcp.json)
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp"],
      "autoApprove": ["resolve-library-id", "get-library-docs"]
    },
    "postgres-ro": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres",
               "postgresql://ro_user@localhost:5432/app"]
    }
  }
}</code>
```

```
<code># .clineignore / .rooignore
.env*
**/*.pem
**/*.key
dist/
coverage/
pnpm-lock.yaml</code>
```

#### Recipe 3 • Copy-Paste Boomerang Orchestrator Starter Prompt

`"In Orchestrator mode, break OAuth2 PKCE login into 3 sequential subtasks: (1) dispatch spec-architect to write docs/pkce-plan.md; (2) dispatch code to implement src/auth/pkce.ts strictly per the plan; (3) dispatch test-writer to add Vitest + Playwright tests and confirm exit 0. Return a final diff summary."`

## 9. Auto-Approve Guardrails, Secrets & Hard Cost Caps

An autonomous VS Code agent runs with your local OS user permissions. Treat it like a fast junior contractor: grant read-only velocity by default, sandbox mutations, and cap every task's blast radius and dollar spend.

#### 1 Recommended Auto-Approve Baseline

| Action Category | Workstation | Dev Container / VM |
| --- | --- | --- |
| Read workspace files | **Auto** | **Auto** |
| Read outside workspace | Prompt | Prompt |
| Edit workspace files | Prompt (or Auto + Checkpoints) | **Auto** |
| Execute safe commands | Allowlist only | **Auto** |
| Execute arbitrary shell | **NEVER Auto** | Prompt / Allowlist |
| Headless Browser / MCP write | Prompt | Localhost only |

#### 2 Safe Shell Command Allowlist

Whitelist deterministic, non-destructive verification commands so the agent can iterate on tests without triggering destructive shell calls:

```
<code># Safe Auto-Approve Prefixes (Roo / Kilo / Cline)
pnpm test, pnpm vitest, pnpm typecheck, pnpm lint
pytest, go test, cargo test, git status, git diff

# Always Denied / Prompt-Required
rm -rf, curl | sh, git push <span class="nowrap">--force</span>, chmod, sudo</code>
```

**Note:** In Cline, updating `Max Requests` applies cleanly on the *next* task—close and reopen the task if you tighten limits mid-session.

### Four Hard Defense-in-Depth Layers

#### 3 Secret Hygiene & Hook-Level Blocking

Store API keys exclusively in **VS Code Secret Storage** (never commit keys to `.vscode/settings.json`). Use `.clineignore` / `.rooignore` for context filtering, and pair with pre-tool-call hooks or Dev Container bind-mount exclusions to hard-block reads of `~/.ssh`, `~/.aws`, and `.env.production`.

#### 4 Per-Task Dollar & Request Ceilings

Set two safety valves: (a) **IDE-side** Max Auto-Approved Requests (15–25) and Max Cost per Task ($1.00–$2.50); and (b) **Provider-side** hard monthly key limits in OpenRouter, Anthropic, or AWS Budgets so a stuck retry loop can never burn an uncapped card.

#### 5 Browser & MCP Prompt-Injection Defense

Any third-party web page or untrusted GitHub issue fetched via Browser Use or MCP can embed hidden instructions. Disable Browser Use on sensitive repos, restrict MCP database credentials to `READ ONLY` roles, and require manual approval for every external write tool.

#### 6 Zero-Telemetry & ZDR Verification

Disable extension telemetry in VS Code settings, toggle **Zero Data Retention (ZDR)** in OpenRouter provider routing (or route via Bedrock/Vertex VPC), and audit open-source extension updates before auto-updating in regulated environments.

## 10. Cross-Tool Synergy: Local + Cloud Agent Pipeline

Combine local Ollama speed, OpenRouter frontier reasoning, Roo/Kilo Orchestration (or Cline Plan/Act), MCP live docs, and Shadow Git Checkpoints into a repeatable four-stage feature delivery pipeline inside standard VS Code.

### Concrete 15-Minute Feature Runbook

#### 1 Ground & Plan (~$0.05)

Start in **Plan** or **Spec-Architect** mode with a Frontier model. Mention `@file` for the 2–3 entry points and ask Context7 MCP for current framework APIs. Approve the written plan before any source edit occurs.

#### 2 Execute in Clean Sub-Tasks (~$0.04 or $0 Local)

Switch to **Act** (or let **Orchestrator** boomerang to `code`) using a fast OpenRouter coder or local Ollama `qwen3-coder:30b`. Keep Shadow Checkpoints active so every file batch is reversible.

#### 3 Closed-Loop Test & DOM Check (~$0.03)

Dispatch `test-writer` (locked via `fileRegex` to `*.test.ts`) to run allowlisted `pnpm vitest` and, for UI routes, let Headless Browser verify zero console errors on `localhost`.

#### 4 Audit, Squash & Open PR

Click **Compare** on the final Shadow Checkpoint to review every line in VS Code's native diff viewer. Stage only intentional hunks, commit cleanly, and push your PR with zero vendor metadata attached.

#### Real-World Economics: Flat $200/mo Subscription vs. Tiered Open BYOK

A typical 40-turn feature built via tiered BYOK (Frontier Plan + Value/Local Act + 80% prompt caching) averages **$0.12–$0.35 per feature**—roughly $15–$40/month for heavy daily engineering, with full model choice and zero rate-limit lockouts.

## 11. Troubleshooting Clinic (Top 7 Fixes) & Pre-Flight

Diagnose the seven most common open-agent failure modes in seconds, then run the 6-point pre-flight checklist before handing any multi-file refactor to an autonomous VS Code agent.

| Symptom | Root Cause | Exact Fix |
| --- | --- | --- |
| **1. Diff / Search-Replace Loops** | Model hallucinates stale line numbers or small local model (<22B) botches patch formatting. | Switch to `Search/Replace` diff strategy, upgrade local coder to &ge;30B, or restore last Checkpoint and re-pin `@file`. |
| **2. Ollama Cuts Off / Forgets Rules** | Ollama defaults to a 4,096-token context window, truncating system prompts and tool schemas. | Set `OLLAMA_CONTEXT_LENGTH=32768` (or Modelfile `num_ctx 32768`) and match Context Window in extension settings. |
| **3. Runaway Token / Dollar Burn** | Unbounded single thread >100k tokens with repeated failed test retries and cold prompt cache. | Trigger Context Condensation or Boomerang a fresh subtask; cap `Max Requests = 15` and set a provider key limit. |
| **4. Shadow Git Hangs / `.git_disabled`** | Massive untracked artifacts (`node_modules`, `target/`) choke Shadow Git snapshot init. | Add build folders to `.gitignore`; if stuck, disable Checkpoints in Feature Settings and rename `.git_disabled` back to `.git`. |
| **5. `.roomodes` Schema Error** | Using legacy `allowedPaths` array instead of the tuple `["edit", { fileRegex }]` syntax. | Use the exact tuple format shown on Page 6 and ensure `slug` is kebab-case with `roleDefinition ≥ 10` chars. |
| **6. Shell Output Invisible to Agent** | VS Code Terminal Shell Integration is disabled or broken by custom Zsh/Fish prompt themes. | Enable `terminal.integrated.shellIntegration.enabled` and add a minimal fallback prompt when `$TERM_PROGRAM == "vscode"`. |
| **7. MCP Server Fails or Bloats Context** | Missing `npx` PATH in GUI VS Code, or 50+ MCP tools eating 15k tokens on every turn. | Use absolute Node binary paths in `mcp_settings.json` and toggle off unused MCP servers per workspace. |

### 6-Point Pre-Flight Checklist Before Autonomous Runs

✓

**Clean Git Working Tree:** Commit or stash WIP changes so Shadow Checkpoints and `git diff` stay crystal clear.

✓

**Dual-Model Profile Active:** Confirm Frontier model is bound to `Plan/Architect` and Value/Local model to `Act/Code`.

✓

**Ignore & Secret Shield Verified:** `.clineignore` / `.rooignore` blocks `.env*`, keys, and lockfiles; API keys live in VS Code Secret Storage.

✓

**Auto-Approve & Cost Caps Set:** Arbitrary shell & external writes require prompt; `Max Requests` (&le;20) and provider budget caps are active.

✓

**Lean Rules & MCP Footprint:** Workspace rules under ~1,200 tokens and only 2–4 task-relevant MCP servers enabled to maximize prompt caching.

✓

**Deterministic Verification Command:** Your prompt or rules name the exact test/typecheck command the agent must pass before completion.

---

## Edition Note & Attribution

This 12-page handbook, its topic structure, and its illustrations were generated with AI under human editorial direction and print-layout QA. Verify commands, pricing tiers, and security settings against official vendor documentation before production use.

- AI & Editorial Disclosure: https://twelve-pages.com/editorial
- Terms & Licensing: https://twelve-pages.com/terms
- Privacy & Cookie Notice: https://twelve-pages.com/privacy
