Programmatic Code Mode for Antigravity.
Replace raw MCP schema bloat and 20-turn tool chains with 4 fixed tools (~316 tokens),
a QuickJS-NG WebAssembly sandbox (1.61 ms warm p50), a 0 ms BM25 .d.ts indexer,
a Runtime Host Policy Broker, and a live aux_pane MCP App Inspector.
Unofficial open-source plugin; not affiliated with Google LLC or Anthropic, PBC. Requires Node.js >= 20. Zero node-gyp, zero Docker, zero runtime node_modules.
Token & Round-Trip Savings Calculator
Model your Antigravity workspace's connected MCP servers and multi-step tool workload. Estimates use the same deterministic ceil(utf8_bytes / 4) schema and payload scaling validated by node bench/run-bench.mjs --json.
*Illustrative input-token savings at $3.00 / 1M input tokens; actual savings depend on your Antigravity model pricing and prompt-cache hit rate.
4 Tools on the Surface. QuickJS-NG WASM Underneath.
Control and indexing stay in the host Node.js gateway while untrusted agent code runs inside an ephemeral WebAssembly linear-memory context with zero Node globals.
0 ms BM25 + .d.ts
Reads Antigravity's pre-cached ~/.gemini/antigravity/mcp/ schemas at startup without spawning upstream servers. cm_search returns compact TypeScript signatures.
QuickJS-NG WASM Pool
Strips TypeScript and runs workspace.*, mcp.*, and kv.* asynchronously over MessagePort inside a warm worker_threads WASM isolate.
Runtime Policy Broker
Checks every call after dynamic arguments resolve: readonly vs readwrite, fs.realpathSync jail, sensitive path denylist, budgets, and secret scrubbing.
$ref Spill & Inspector
Oversized results spill automatically to host $ref:<id> handles with safe jqPath slicing via cm_inspect and live telemetry in Antigravity's aux_pane.
BM25 + Fuzzy Tool Discovery
Query upstream MCP servers, workspace.*, and kv.* in 0.78 ms without dumping raw JSON Schema into context.
Single-Turn TS/JS Orchestration
Run loops, Promise.all fan-outs, and local JSON filtering off-context. Defaults safely to mode: "readonly".
Zero-Eval $ref Drill-Down
Paginate or project spilled payloads with safe jqPath expressions ($.records[0..4]) or inspect run telemetry.
Live aux_pane MCP App
Single-file @modelcontextprotocol/ext-apps inspector displaying token savings, call DAG traces, BM25 search, and policy audit logs.
Runtime Host Policy Broker & WASM Isolation
Static permission classifiers are blind to dynamically constructed paths and commands. Antigravity Code Mode enforces every boundary at runtime on resolved arguments.
Zero Node.js Globals
No process, require, fs, fetch, or Buffer inside QuickJS-NG WASM. Enforces 64 MB default (256 MB cap) memory and 256 KB stack limits.
Infinite-Loop Termination
Wall-clock timeoutMs (60s default, 600s max) terminates runaway workers with worker.terminate() and respawns a clean warm slot.
Symlink & Sensitive Path Guard
fs.realpathSync containment (plus ancestor checks for new files) blocks ../ and symlink escapes. Denies .env*, ~/.ssh, ~/.aws, *.pem/*.key, and auth* even in readwrite.
Host-Only Credentials & Redaction
Upstream MCP auth headers stay on the host. Output scrubbing strips ANSI escapes and masks Bearer tokens, JWTs, ghp_/sk-/npm_ keys, and ANTIGRAVITY_CSRF_TOKEN.
Real Benchmark Results
Measured with node bench/run-bench.mjs --json on Apple M1 Pro (darwin/arm64), Node.js v24.13.0, against 60 enterprise MCP schemas, 24 TypeScript files, and a 113 KB 200-incident JSON payload.
| Scenario | Naive Baseline | Antigravity Code Mode | Reduction | Measured Runtime |
|---|---|---|---|---|
| 60-Tool MCP Schema Catalog (5 servers) | 5,945 tok (23,778 B) · 2 turns |
601 tok (316 eager + 285 .d.ts) · 1 turn |
89.89% tokens | 0.53 ms index · 0.78 ms BM25 |
| 24-File TypeScript Workspace Audit | 6,626 tok (26,502 B) · 26 turns |
122 tok (488 B) · 1 turn |
98.16% tokens · 96.15% turns | 81.30 ms WASM (20 FS calls) |
| 113 KB Incident API Filter (200 → 5 P0) | 28,323 tok (113,290 B) · 4 turns |
181 tok (721 B) · 1 turn (512 tok $ref spill) |
99.36% tokens (98.19% spill) | 143.05 ms WASM |
| Aggregate Total (3 Workloads) | 40,894 tok · 32 turns |
904 tok · 3 turns |
97.79% tokens · 90.63% turns | 1.61 ms warm p50 · 27.37 ms cold |
How It Compares
Designed specifically for Antigravity Desktop App/IDE and Antigravity CLI—closing the off-context execution and runtime policy gap without leaving the Antigravity ecosystem.
| Dimension | CLAUDE_CODE_EXPERIMENTAL_CODE_MODE |
Native Antigravity Lazy-MCP | antigravity-code-mode |
|---|---|---|---|
| Client & Model Scope | Interactive Claude Code CLI + direct Anthropic API only | Antigravity Desktop IDE & CLI | Antigravity Desktop IDE & CLI (all configured models) |
| Tool Discovery | On-demand ToolSearch |
Lazy name list + per-call disk read_file turn |
0 ms pre-cached BM25 + compact .d.ts (~316 eager tok) |
| Sandbox & Policy | Host process; static pre-classifier blind to dynamic args | Host process | QuickJS-NG WASM linear memory + Runtime Host Policy Broker |
| Off-Context Data & State | Stateless per REPL invocation | Raw MCP payloads return into LLM context | Off-context filtering + automatic $ref SpillStore + TTL kv |
| Observability | Terminal Ctrl+O raw text |
Plain tool output logs | Live aux_pane MCP App Inspector UI |
Frequently Asked Questions
How is Antigravity Code Mode different from CLAUDE_CODE_EXPERIMENTAL_CODE_MODE?
Claude Code's experimental flag runs inside the host process behind a static permission pre-classifier and is limited to interactive Claude Code CLI sessions on direct Anthropic endpoints. Antigravity Code Mode targets Antigravity Desktop IDE & CLI across any configured model, isolates code inside QuickJS-NG WASM linear memory, authorizes every resolved call via a Runtime Host Policy Broker, supports cross-turn kv and $ref spill handles, and ships a live aux_pane Inspector.
Does it require node-gyp, Docker, Python, or Deno?
No. All runtime components—including quickjs.wasm, @modelcontextprotocol/sdk, @modelcontextprotocol/ext-apps, and sucrase—are prebundled into dist/ and ui/inspector.html with "dependencies": {}. Only Node.js >= 20 is needed.
How are API keys, .env files, and OAuth tokens protected?
process.env and upstream MCP credentials never enter the WASM sandbox, sensitive-paths.mjs blocks .env*, ~/.ssh, ~/.aws, *.pem/*.key, auth*, and devices.json even in readwrite mode, and redactSecrets() scrubs Bearer tokens, JWTs, API keys, and ANTIGRAVITY_CSRF_TOKEN from every return value and $ref spill.
When should the agent NOT use Code Mode?
For simple 1–2 step actions (reading one known file or running a single short command), native Antigravity tools are faster and avoid TypeScript generation overhead. The bundled rules/AGENTS.md keeps trivial calls native and activates Code Mode for 3+ step orchestrations, multi-file audits, and large-payload filtering.
How does 0 ms MCP tool indexing work without spawning every upstream server?
Antigravity caches lazy MCP tool JSON schemas at ~/.gemini/antigravity/mcp/<server>/<tool>.json. At startup, Antigravity Code Mode builds its BM25 index from those cached files in under 1 ms (0.53 ms for 60 tools) and connects to upstream Stdio or Streamable HTTP servers lazily on first cm_execute invocation.
What prevents an infinite loop or memory bomb from hanging Antigravity?
Each script runs in a worker_threads QuickJS-NG WASM isolate enforcing a 64 MB default (256 MB max) linear memory cap, 256 KB stack cap, 25-call default tool budget, and wall-clock timeout that terminates the worker via worker.terminate() and respawns a clean replacement.