{
  "name": "Kagex",
  "url": "https://kagex.vercel.app",
  "cutawayUrl": "https://kagex.vercel.app/cutaway",
  "guidesUrl": "https://kagex.vercel.app/guides",
  "topicsUrl": "https://kagex.vercel.app/topics",
  "repository": "https://github.com/CodewithEvilxd/kagex",
  "author": "codewithevilxd",
  "portfolio": "https://nishantgaurav.site",
  "license": "MIT",
  "costUsd": 0,
  "updatedAt": "2026-11-29T00:00:00.000Z",
  "tagline": "Give every coding agent its own instant Linux microVM—locally, offline-safe, for $0.",
  "description": "Spin up disposable Ubuntu 24.04 microVMs in milliseconds on macOS, Windows, and Linux. Isolate writes, lock down egress, keep secrets out of guest RAM, and wire your coding agent in one command.",
  "install": {
    "macos": [
      "git clone https://github.com/CodewithEvilxd/kagex && cd kagex",
      "make images build",
      "./_out/bin/sandboxd install --artifacts _out"
    ],
    "windows": [
      "git clone https://github.com/CodewithEvilxd/kagex; cd kagex",
      "powershell -ExecutionPolicy Bypass -File .\\scripts\\setup-windows.ps1"
    ],
    "linux": [
      "git clone https://github.com/CodewithEvilxd/kagex && cd kagex",
      "make images build",
      "sudo ./_out/bin/sandboxd install --artifacts _out"
    ],
    "project": "~/code/app",
    "mcp": {
      "antigravity": "./_out/bin/sandboxctl mcp install antigravity --project ~/code/app",
      "cursor": "./_out/bin/sandboxctl mcp install cursor --project ~/code/app",
      "claude": "./_out/bin/sandboxctl mcp install claude --project ~/code/app",
      "codex": "./_out/bin/sandboxctl mcp install codex --project ~/code/app"
    }
  },
  "keywords": [
    "Kagex",
    "kagex.vercel.app",
    "local AI agent sandbox",
    "zero-trust microVM sandbox",
    "disposable Ubuntu 24.04 microVM",
    "AI coding agent isolation",
    "Antigravity MCP sandbox",
    "Cursor AI agent microVM",
    "Claude Code local sandbox MCP",
    "OpenAI Codex CLI sandbox MCP",
    "Apple Virtualization.framework Go",
    "Code-Hex vz microVM",
    "Firecracker v1.12.1 AI sandbox",
    "Windows 11 WSL2 KVM microVM",
    "Windows 10 Home Firecracker setup",
    "E2B open source local alternative",
    "Docker container alternative for AI agents",
    "Modal Sandbox alternative local",
    "Daytona local microVM alternative",
    "GitHub Codespaces local alternative",
    "Ghost Secrets Vault sbxph",
    "ECDSA P-256 MITM proxy secrets",
    "prevent AI agent API key leak",
    "prevent prompt injection RCE exfiltration",
    "allowlist egress firewall microVM",
    "DNS rebinding protection sandbox",
    "block AWS metadata 169.254.169.254",
    "no virtio-fs shared folder attack",
    "safefs RemoveUnder confinement",
    "one-way workspace sync AF_VSOCK",
    "3-way git merge-file agent apply",
    "sandboxctl diff apply pull undo",
    "git smart HTTP branch push glob guard",
    "strip .git/config tokens sandbox",
    "32ms warm pool microVM boot",
    "APFS clonefile CoW VM disk",
    "FICLONE SEEK_DATA sparse CoW",
    "0.5s golden snapshot restore",
    "parallel microVM fork c.Fork",
    "best-of-N AI coding harness Go",
    "Python stdlib Unix socket SSE sandbox",
    "OpenAPI /v1/openapi.yaml sandboxd",
    "AF_VSOCK port 52 gRPC guest agent",
    "PID 1 static Go initd initramfs",
    "nested dockerd inside microVM",
    "loopback port forwarding 127.0.0.1 sandbox",
    "OpenTelemetry OTLP microVM tracing",
    "Prometheus Grafana sandbox fleet dashboard",
    "SQLite WAL sqlc Go daemon",
    "SO_PEERCRED LOCAL_PEERCRED Unix auth",
    "Kagex MK-IV 3D hypervisor cutaway",
    "MIT open source free AI sandbox $0"
  ],
  "keyPointPillars": [
    {
      "id": "isolation-kernel",
      "title": "MicroVM Kernel & Compute Isolation",
      "badge": "Hypervisor",
      "guideSlug": "macos-apple-silicon-virtualization-framework",
      "points": [
        "Every Kagex sandbox boots a dedicated single-tenant Ubuntu 24.04 Linux kernel rather than sharing the host OS kernel.",
        "macOS 14+ (Apple Silicon) runs natively via Apple Virtualization.framework (Code-Hex/vz/v3) with rootless ad-hoc entitlements in infra/vz.entitlements.",
        "Linux amd64 and arm64 hosts run Firecracker v1.12.1 over /dev/kvm with per-VM Linux network namespaces and nftables packet filters.",
        "Windows 10 (19041+) and Windows 11 (x64/arm64, Home/Pro/Enterprise) supervise Firecracker KVM inside WSL2 without requiring Hyper-V Pro or Admin privileges.",
        "Guest base kernels are sha256-verified via infra/scripts/fetch-kernel.sh before registration into _out/images/vmlinux-<arch>.",
        "Every microVM boots from an immutable Ubuntu 24.04 ext4 rootfs built reproducibly with Docker or native debootstrap.",
        "Nested dockerd and Compose workloads execute inside the isolated guest kernel with zero exposure of host /var/run/docker.sock.",
        "internal/scheduler arbitrates vCPU and RAM via a lock-free single-goroutine actor ledger with priority queuing and automatic pressure eviction.",
        "Default host memory reserve locks ~50% RAM on macOS/Linux (and safe WSL2 VHDX headroom on Windows), overridable via budgets.max_mem_mb.",
        "Active sandboxes pause gracefully to disk on Ctrl-C during foreground sandboxd serve runs and recover safely after crashes via internal/service/recover.go."
      ]
    },
    {
      "id": "speed-cow-pool",
      "title": "Warm Pools, Copy-on-Write Snapshots & Forks",
      "badge": "Latency",
      "guideSlug": "32ms-warm-pool-microvm-boot",
      "points": [
        "Warm pool standby microVMs attach fresh workspaces and run initial commands in 20–50 ms on Apple M4 hardware.",
        "Golden snapshot restores complete in 0.5–0.6 seconds including incremental workspace delta synchronization.",
        "Pausing and resuming an active sandbox to/from disk finishes in 0.5–0.7 seconds while retaining guest memory state.",
        "Parallel CoW forks clone a running sandbox N times concurrently in ~0.8 seconds per child for best-of-N AI evaluation.",
        "Cold Linux kernel boot from initramfs to PID 1 sandbox-agent ready completes in ~1.2 seconds.",
        "Trivial exec RPC round trips complete in under 5 milliseconds over multiplexed gRPC on AF_VSOCK port 52.",
        "macOS clones multi-gigabyte disk images instantaneously via APFS clonefile CoW blocks without duplicating storage.",
        "Linux & WSL2 leverage FICLONE reflinks on XFS/Btrfs or sparse SEEK_DATA + CopyFileRange cloning on ext4.",
        "Template auto-detection (template='auto') caches repo bootstrap toolchains established during --setup runs.",
        "sandboxctl trace <sbx_id|exe_id> renders exact millisecond waterfalls across scheduler.reserve, vm.restore, guest.configure, workspace.sync, and exec."
      ]
    },
    {
      "id": "workspace-sync-undo",
      "title": "One-Way Workspace Sync, 3-Way Apply & Undo",
      "badge": "Repo Safety",
      "guideSlug": "one-way-workspace-sync-3way-apply-undo",
      "points": [
        "Host folders are never shared or mounted into guest microVMs — virtio-fs and 9p mounts are intentionally disabled.",
        "Workspace synchronization moves strictly one way (host -> VM) over explicit AF_VSOCK tar streams checked by guest/files.",
        "Running rm -rf /workspace inside a sandbox has zero effect on the developer's repository on disk.",
        "Before every sandbox_exec, incremental host file changes delta-sync automatically into guest /workspace.",
        "Diff previews compare VM edits cleanly against repository git HEAD without mutating host git refs, index, or checked-out branches.",
        "Applying approved patches uses temporary git merge-file 3-way merges rather than blind file overwrites.",
        "Every host write via sandboxctl apply or pull archives all affected original host files first into a restorable artifact bundle.",
        "Instant rollback restores pre-apply host state in one command: sandboxctl undo <artifact_id>.",
        "sandboxctl pull refuses to overwrite files modified concurrently on the host since last sync unless explicitly forced.",
        "Path validation inside guest/files, apply, and pull rejects absolute paths, '..' segments, escaping symlinks, and .git/ internal writes."
      ]
    },
    {
      "id": "ghost-secrets-vault",
      "title": "Ghost Secrets Vault & Zero-Leak Proxy",
      "badge": "Secrets",
      "guideSlug": "ghost-secrets-vault-mitm-proxy",
      "points": [
        "Real API tokens and credentials stay encrypted/stored solely on the host with 0600 permissions under daemon data roots.",
        "Sandboxes receive only synthetic harmless placeholder tokens formatted as sbxph_<name>_<hex>.",
        "Outbound HTTPS requests targeting approved secret hosts terminate TLS cleanly at a per-daemon ECDSA P-256 local CA proxy.",
        "Host egress proxy swaps real credentials in transit strictly when both host allowlist and secret destination rules match.",
        "Echoed secrets inside upstream HTTP response bodies or debug headers are redacted automatically back into placeholders via scrubReader.",
        "Cleartext HTTP requests attempting to carry secret placeholders are dropped immediately before touching the wire.",
        "Daemon rejects CLI commands, environment variables, stdin payloads, and synced files containing raw stored secret values.",
        "Workspace delta sync automatically skips .env*, *.pem, *.key, id_*, .npmrc, .aws, and .ssh credential paths.",
        "Synced .git/config files have credential helpers, HTTP Authorization extraheaders, include paths, and embedded URL tokens stripped.",
        "Git smart-HTTP tokens created via sandboxctl secret set-git enforce allowed owner/repo patterns and push branch globs like sbx/*."
      ]
    },
    {
      "id": "egress-firewall-dns",
      "title": "Allowlist Egress Firewall & DNS Defense",
      "badge": "Network",
      "guideSlug": "allowlist-egress-firewall-dns-rebinding",
      "points": [
        "Default outbound network mode is allowlist-only, granting access solely to approved package registries, GitHub, and Ubuntu mirrors.",
        "Loopback (127.0.0.0/8), RFC1918 private LAN subnets, link-local/cloud metadata (169.254.0.0/16), and CGNAT (100.64.0.0/10) are always blocked.",
        "internal/network/dns inspects all resolved A/AAAA answers and drops records pointing to loopback, LAN, IMDS, or CGNAT ranges to neutralize DNS rebinding.",
        "SNI and Host headers are cross-verified at the egress proxy to prevent HTTP Host-header domain fronting bypasses.",
        "Harnesses support separate setup bootstrap rules (--setup) that permit temporary package installation before engaging strict runtime lockdown.",
        "When a coding agent hits a blocked registry (403 Denied), it calls sandbox_network to prompt explicit human approval rather than bypassing firewall rules.",
        "Host-forwarded preview listeners mapped via sandboxctl port bind strictly to 127.0.0.1 and never expose 0.0.0.0 on local Wi-Fi.",
        "Unix API middleware validates caller identity via kernel OS peer credentials (SO_PEERCRED on Linux / LOCAL_PEERCRED on macOS).",
        "Loopback TCP listeners enforce cryptographic Bearer authentication (sandboxd token) and drop browser Origin CSRF attempts.",
        "On Linux KVM, per-VM network namespaces combine with nftables enforcement at kernel level."
      ]
    },
    {
      "id": "mcp-harness-wiring",
      "title": "11-Tool MCP Server & One-Command IDE Wiring",
      "badge": "Agents & MCP",
      "guideSlug": "mcp-tools-reference-guide",
      "points": [
        "sandbox-mcp implements JSON-RPC 2.0 over stdio and bridges seamlessly into sandboxd over Unix domain sockets or loopback TCP.",
        "sandboxctl mcp install antigravity creates .agents/plugins/kagex/ (or ~/.gemini/config/plugins/kagex/ with --global) containing plugin.json, mcp_config.json, rules/AGENTS.md, and skills/sandbox/SKILL.md.",
        "sandboxctl mcp install cursor configures .cursor/mcp.json (or ~/.cursor/mcp.json) alongside always-applied .cursor/rules/sandbox.mdc.",
        "sandboxctl mcp install claude writes .claude/skills/sandbox/SKILL.md and registers the MCP server via claude mcp add with --scope project or --scope user.",
        "sandboxctl mcp install codex backs up ~/.codex/config.toml to config.toml.bak, appends [mcp_servers.sandbox] (30s startup, 900s tool timeout), and updates AGENTS.md.",
        "Eleven specialized tools cover full dev workflows: sandbox_exec, sandbox_read_file, sandbox_write_file, sandbox_diff, sandbox_apply, sandbox_pull, sandbox_snapshot, sandbox_network, sandbox_port, sandbox_status, and sandbox_destroy.",
        "Shared policy flags (--auto-pull, --setup, --secrets) are locked by the user at install time so models cannot weaken isolation parameters.",
        "On Windows, sandbox-mcp automatically translates Windows paths like D:\\repo into corresponding WSL2 paths cleanly.",
        "Operators monitor every agent tool invocation, file sync, diff, and firewall block live via sandboxctl events.",
        "Custom Go, Python, and REST harnesses receive identical isolation primitives using pkg/client or docs/openapi.yaml."
      ]
    },
    {
      "id": "guest-agent-runtime",
      "title": "Guest Agent (PID 1) & AF_VSOCK Protocol",
      "badge": "Guest OS",
      "guideSlug": "virtio-vsock-grpc-guest-agent",
      "points": [
        "sandbox-agent is compiled with CGO_ENABLED=0 as a static Linux binary for both linux/amd64 and linux/arm64.",
        "Delivered via a compact initramfs, guest/initd initializes virtual mounts, brings up networking via netlink, arms a deadman timer, and performs switch_root.",
        "As PID 1 inside every microVM, guest/proc runs a singleton SIGCHLD zombie-process reaper preventing PID exhaustion during heavy builds.",
        "guest/execd executes commands inside isolated process groups with PTY or pipe streams and reads /proc/vmstat to flag memory/OOM kills accurately.",
        "guest/spool persists execution output frames on disk so detached or reconnecting clients recover every log byte reliably.",
        "Host-guest RPC communication uses strongly typed protobuf schemas defined in internal/proto/guest/v1/guest.proto over AF_VSOCK port 52.",
        "guest/files performs traversal-verified tar extraction and file read/write operations inside guest filesystems.",
        "Zero SSH daemons, authorized_keys files, or open guest TCP control ports are ever needed inside sandboxes.",
        "Linux guest process unit tests run reproducibly inside Docker containers via make test-linux.",
        "Artifact versioning embeds build metadata into both sandboxd and sandbox-agent cleanly."
      ]
    },
    {
      "id": "sdks-api-storage",
      "title": "OpenAPI, Go/Python SDKs & WAL Storage",
      "badge": "SDKs & API",
      "guideSlug": "sandboxd-http-rest-sse-openapi-guide",
      "points": [
        "sandboxd serves a versioned REST/JSON + SSE API contracted cleanly in docs/openapi.yaml and live at GET /v1/openapi.yaml.",
        "Public Go SDK in pkg/client requires zero cgo and handles automatic platform discovery across macOS, Linux, and Windows.",
        "Python integration requires zero third-party pip packages — stdlib http.client + socket AF_UNIX / TCP streams SSE cleanly (docs/examples/python-harness/harness.py).",
        "Asynchronous executions via wait=false stream chunked stdout, stderr, and final exit payloads over GET /v1/executions/{exec_id}/stream.",
        "Oversized command logs stay searchable directly via GET /v1/executions/{exec_id}/grep without overflowing LLM token windows.",
        "Persistence uses pure-Go SQLite (modernc.org/sqlite) in WAL mode with 1 writer and an 8-reader connection pool.",
        "Type-safe database queries are generated via sqlc in internal/store/db with embedded SQL migrations in internal/store/migrations.",
        "All daemon state, SQLite DBs, rootfs clones, and backup artifacts live cleanly outside git repos (~/Library/Application Support/sandboxd/, /var/lib/sandboxd/, %LOCALAPPDATA%\\sandboxd\\).",
        "Uninstall preserves existing templates and snapshots unless the user explicitly runs sandboxd uninstall --purge --yes.",
        "Prometheus /metrics and OTLP --otlp-endpoint http://127.0.0.1:4318 work out of the box with infra/observability/docker-compose.yml."
      ]
    }
  ],
  "glossary": [
    {
      "term": "MicroVM",
      "category": "Compute",
      "definition": "A lightweight hardware-virtualized VM running its own Linux kernel and memory space per task.",
      "guideSlug": "kagex-vs-docker-for-ai-agents"
    },
    {
      "term": "Apple Virtualization.framework",
      "category": "Hypervisor",
      "definition": "Native macOS 14+ hypervisor API used rootlessly by Kagex on Apple Silicon via Code-Hex/vz.",
      "guideSlug": "macos-apple-silicon-virtualization-framework"
    },
    {
      "term": "Firecracker v1.12.1",
      "category": "Hypervisor",
      "definition": "Open-source KVM microVM monitor powering Linux and Windows WSL2 sandboxes inside Kagex.",
      "guideSlug": "linux-firecracker-kvm-microvms"
    },
    {
      "term": "AF_VSOCK (Port 52)",
      "category": "Transport",
      "definition": "Direct host-to-guest socket address family carrying gRPC control & tar file streams without guest IPs.",
      "guideSlug": "virtio-vsock-grpc-guest-agent"
    },
    {
      "term": "gVisor tap-vsock",
      "category": "Network",
      "definition": "Userspace virtual network stack inspecting every packet leaving macOS microVMs before egress.",
      "guideSlug": "macos-apple-silicon-virtualization-framework"
    },
    {
      "term": "APFS clonefile",
      "category": "Storage",
      "definition": "Instantaneous copy-on-write file cloning on macOS disks without duplicating unchanged rootfs gigabytes.",
      "guideSlug": "32ms-warm-pool-microvm-boot"
    },
    {
      "term": "FICLONE & SEEK_DATA",
      "category": "Storage",
      "definition": "Linux reflink and sparse-hole copying primitives keeping Firecracker CoW snapshots lightweight.",
      "guideSlug": "linux-firecracker-kvm-microvms"
    },
    {
      "term": "Ghost Secrets Vault",
      "category": "Security",
      "definition": "Host-side 0600 credential store that keeps real secrets out of VM RAM using placeholder substitution.",
      "guideSlug": "ghost-secrets-vault-mitm-proxy"
    },
    {
      "term": "sbxph_<name>_<hex>",
      "category": "Security",
      "definition": "Synthetic placeholder token injected into guest sandboxes instead of raw API credentials.",
      "guideSlug": "ghost-secrets-vault-mitm-proxy"
    },
    {
      "term": "ECDSA P-256 Local CA",
      "category": "Security",
      "definition": "Per-daemon TLS certificate authority enabling host-side secret substitution only on allowed domains.",
      "guideSlug": "ghost-secrets-vault-mitm-proxy"
    },
    {
      "term": "scrubReader",
      "category": "Security",
      "definition": "Streaming HTTP response sanitizer that scrubs echoed raw secrets back into placeholders before returning to guest VMs.",
      "guideSlug": "ghost-secrets-vault-mitm-proxy"
    },
    {
      "term": "DNS Rebinding Guard",
      "category": "Network",
      "definition": "Resolver filter rejecting DNS records pointing toward loopback, RFC1918 LAN, IMDS, or CGNAT.",
      "guideSlug": "allowlist-egress-firewall-dns-rebinding"
    },
    {
      "term": "IMDS (169.254.169.254)",
      "category": "Network",
      "definition": "Link-local cloud instance metadata IP range permanently blocked across all Kagex sandboxes.",
      "guideSlug": "allowlist-egress-firewall-dns-rebinding"
    },
    {
      "term": "No virtio-fs",
      "category": "Isolation",
      "definition": "Deliberate ban on shared host folder mounts so untrusted VM syscalls cannot traverse host files.",
      "guideSlug": "safefs-zero-shared-folders-isolation"
    },
    {
      "term": "safefs.RemoveUnder",
      "category": "Isolation",
      "definition": "Symlink-resolving confinement helper gating every deletion targeting paths under daemon directories.",
      "guideSlug": "safefs-zero-shared-folders-isolation"
    },
    {
      "term": "3-Way Apply (git merge-file)",
      "category": "Workflow",
      "definition": "Non-destructive patch merge running on temp files after archiving backups for instant rollback.",
      "guideSlug": "one-way-workspace-sync-3way-apply-undo"
    },
    {
      "term": "sandboxctl undo",
      "category": "Workflow",
      "definition": "One-command rollback restoring host files from pre-apply tar backup artifacts (art_...).",
      "guideSlug": "one-way-workspace-sync-3way-apply-undo"
    },
    {
      "term": "Warm Pool",
      "category": "Performance",
      "definition": "Background pool of booted standby Ubuntu 24.04 microVMs enabling 20–50 ms task attaches.",
      "guideSlug": "32ms-warm-pool-microvm-boot"
    },
    {
      "term": "Golden Snapshot",
      "category": "Performance",
      "definition": "Pre-provisioned disk/memory snapshot capturing base OS or repo setup layers for ~0.5 s restores.",
      "guideSlug": "cow-golden-snapshots-pause-resume"
    },
    {
      "term": "Parallel Fork (c.Fork)",
      "category": "Performance",
      "definition": "CoW cloning of an active running sandbox into multiple independent workers (~0.8 s each).",
      "guideSlug": "parallel-agent-forking-workflows"
    },
    {
      "term": "SO_PEERCRED / LOCAL_PEERCRED",
      "category": "Auth",
      "definition": "Kernel OS peer credential verification authenticating same-user Unix domain socket clients.",
      "guideSlug": "zero-trust-ai-code-execution"
    },
    {
      "term": "MCP (Model Context Protocol)",
      "category": "Agents",
      "definition": "Open JSON-RPC stdio protocol used by sandbox-mcp to expose 11 tools to IDE coding agents.",
      "guideSlug": "mcp-tools-reference-guide"
    },
    {
      "term": "SQLite WAL + sqlc",
      "category": "Storage",
      "definition": "Write-Ahead Log database persistence powering sandboxes, artifacts, and execution history.",
      "guideSlug": "sandboxd-http-rest-sse-openapi-guide"
    },
    {
      "term": "OTLP / Prometheus /metrics",
      "category": "Observability",
      "definition": "OpenTelemetry tracing (port 4318) and Prometheus gauges paired with a prebuilt Grafana dashboard.",
      "guideSlug": "opentelemetry-prometheus-grafana-microvm-metrics"
    }
  ],
  "comparisons": [
    {
      "dimension": "Isolation boundary",
      "kagex": "Dedicated Ubuntu 24.04 Linux kernel",
      "docker": "Shared host Linux kernel",
      "cloudVm": "Remote microVM",
      "rawHost": "None (full user/host access)"
    },
    {
      "dimension": "Warm spawn latency",
      "kagex": "20–50 ms (local warm pool)",
      "docker": "150–600 ms",
      "cloudVm": "300–1500 ms + WAN upload",
      "rawHost": "0 ms (unsafe)"
    },
    {
      "dimension": "Code stays on laptop",
      "kagex": "100% local & offline-capable",
      "docker": "Local",
      "cloudVm": "Uploaded to remote vendor",
      "rawHost": "Local"
    },
    {
      "dimension": "Monthly & usage cost",
      "kagex": "$0 (MIT open source)",
      "docker": "$0 / Desktop license",
      "cloudVm": "Per-minute vCPU/RAM billing",
      "rawHost": "$0"
    },
    {
      "dimension": "API keys in VM RAM",
      "kagex": "Never (sbxph_ placeholders)",
      "docker": "Exposed if passed via env",
      "cloudVm": "Often inside remote VM env",
      "rawHost": "Full host ~/.ssh & .env exposed"
    },
    {
      "dimension": "Host folder mutation risk",
      "kagex": "Zero (1-way sync + diff/apply/undo)",
      "docker": "High with -v bind mounts",
      "cloudVm": "Sync lag / manual download",
      "rawHost": "Unprotected rm -rf / git reset"
    },
    {
      "dimension": "Default egress firewall",
      "kagex": "Allowlist-only + DNS rebind guard",
      "docker": "Unrestricted bridge by default",
      "cloudVm": "Varies by provider",
      "rawHost": "Full LAN & internet access"
    },
    {
      "dimension": "macOS, Linux & Windows parity",
      "kagex": "Native vz + KVM + Win WSL2 KVM",
      "docker": "Linux VM wrapper on Mac/Win",
      "cloudVm": "Cloud-hosted Linux",
      "rawHost": "OS-dependent"
    },
    {
      "dimension": "Parallel branching / fork",
      "kagex": "~0.8 s CoW fork (sandboxctl fork)",
      "docker": "No memory state fork",
      "cloudVm": "Vendor API dependent",
      "rawHost": "Requires manual git clones"
    },
    {
      "dimension": "IDE MCP integration",
      "kagex": "1-cmd Antigravity, Cursor, Claude, Codex",
      "docker": "Manual scripting required",
      "cloudVm": "Custom plugins",
      "rawHost": "Host shell directly"
    }
  ],
  "diagnostics": [
    {
      "q": "How do I verify my host, hypervisor, and base images are healthy before debugging anything else?",
      "a": "Run both doctor commands: sandboxd doctor inspects OS hypervisor capability (Virtualization.framework entitlement, /dev/kvm, or WSL2 KVM), APFS/sparse disk space, kernel/rootfs checksums, and sockets; sandboxctl doctor checks the live daemon and warm pool budget.",
      "cmd": "./_out/bin/sandboxd doctor && ./_out/bin/sandboxctl doctor"
    },
    {
      "q": "Why did an agent get 403 Denied when running curl or pip/npm install inside a microVM?",
      "a": "Kagex blocks unlisted outbound domains by default. Either install dependencies during --setup, approve the agent's sandbox_network prompt, or explicitly allow the host via sandboxctl net allow <id> <host>.",
      "cmd": "sandboxctl net allow <sbx_id> pypi.org files.pythonhosted.org"
    },
    {
      "q": "How do I recover if a bug caused an unwanted change after running sandboxctl apply?",
      "a": "Every apply/pull creates a backup tar artifact and prints an undo token. Run sandboxctl artifacts to list recent backups and sandboxctl undo <art_id> to restore exact pre-apply host files cleanly.",
      "cmd": "sandboxctl artifacts && sandboxctl undo <art_id>"
    },
    {
      "q": "Can Windows 10 or Windows 11 Home users run Kagex without Hyper-V Pro?",
      "a": "Yes. Kagex's scripts/setup-windows.ps1 provisions Firecracker and nftables cleanly inside WSL2 (/dev/kvm) with non-Admin HKCU login auto-start and authenticated loopback TCP on 127.0.0.1:17070.",
      "cmd": "powershell -NoProfile -ExecutionPolicy Bypass -File .\\scripts\\setup-windows.ps1"
    },
    {
      "q": "How can custom scripts or CI pipelines get the Bearer token for TCP daemon access?",
      "a": "Use sandboxd token to print the active cryptographic Bearer token, or read metadata inside %LOCALAPPDATA%\\sandboxd\\ on Windows.",
      "cmd": "sandboxd token"
    },
    {
      "q": "How do I reclaim disk space from stopped sandboxes or old golden snapshots safely?",
      "a": "Preview unused resources first with --dry-run using sandboxctl gc --dry-run, then run sandboxctl gc when ready.",
      "cmd": "sandboxctl gc --dry-run"
    }
  ],
  "topicClusters": [
    {
      "group": "AI Coding Harnesses & MCP",
      "guideSlug": "antigravity-mcp-sandbox",
      "topics": [
        "Antigravity plugin.json + mcp_config.json",
        "Cursor .cursor/mcp.json & sandbox.mdc",
        "Claude Code SKILL.md & --scope user",
        "Codex config.toml & AGENTS.md",
        "11 MCP tools stdio server",
        "sandbox_exec isolated bash",
        "sandbox_diff unified patch",
        "sandbox_apply 3-way merge",
        "sandbox_network interactive approval",
        "Auto-pull lockfiles safely"
      ]
    },
    {
      "group": "Hypervisors & Host OS Engines",
      "guideSlug": "macos-apple-silicon-virtualization-framework",
      "topics": [
        "Apple Silicon macOS 14+ Virtualization.framework",
        "Rootless ad-hoc signed sandboxd",
        "APFS clonefile instant CoW images",
        "Linux x86_64 & arm64 Firecracker v1.12.1",
        "Per-VM network namespaces & nftables",
        "FICLONE & SEEK_DATA sparse CoW",
        "Windows 10/11 WSL2 /dev/kvm engine",
        "Windows HKCU startup without Admin",
        "Path translation D:\\ -> /mnt/d",
        "Nested dockerd inside Ubuntu 24.04 VM"
      ]
    },
    {
      "group": "Zero-Trust Security & Secret Vault",
      "guideSlug": "ghost-secrets-vault-mitm-proxy",
      "topics": [
        "Host-only 0600 credential storage",
        "Synthetic placeholders sbxph_<name>_<hex>",
        "ECDSA P-256 local MITM CA",
        "Response secret scrubbing (scrubReader)",
        "Cleartext HTTP placeholder drop",
        "Git smart-HTTP branch push globs",
        "Stripped .git/config credentials",
        "Loopback RFC1918 IMDS 169.254.0.0/16 block",
        "No shared host folders (no virtio-fs)",
        "safefs symlink-safe deletion fence"
      ]
    },
    {
      "group": "Comparisons, Speed & SDKs",
      "guideSlug": "kagex-vs-e2b-local-microvm",
      "topics": [
        "Kagex vs E2B local zero-cost VM",
        "MicroVMs vs Docker containers for AI",
        "Kagex vs Modal & Daytona sandboxes",
        "20-50 ms warm pool spawn latency",
        "0.5 s golden snapshot CoW clone",
        "~0.8 s parallel fork candidate racing",
        "Go pkg/client Fork + Diff workflow",
        "Python stdlib Unix/TCP SSE streaming",
        "OpenAPI /v1/openapi.yaml REST contract",
        "Jaeger Tempo OTLP + Grafana metrics"
      ]
    }
  ],
  "guides": [
    {
      "slug": "antigravity-mcp-sandbox",
      "title": "Run Google Antigravity Coding Agents Inside Isolated Kagex MicroVMs",
      "shortTitle": "Antigravity MCP Integration",
      "category": "Agent Integrations",
      "badge": "MCP · 11 Tools",
      "readTime": "4 min",
      "calloutFocus": 1,
      "description": "Wire Google Antigravity IDE and agents to disposable Ubuntu 24.04 microVMs in one command with sandboxctl mcp install antigravity, complete with rules/AGENTS.md and SKILL.md.",
      "summary": "Connect Antigravity over stdio MCP so file edits, test suites, dependency installs, and risky shell commands stay inside an ephemeral Linux microVM while your host tree stays untouched until sandbox_apply.",
      "keywords": [
        "Antigravity MCP sandbox",
        "Antigravity kagex plugin",
        "AI agent microVM Antigravity",
        "plugin.json mcp_config.json sandbox",
        "sandboxctl mcp install antigravity"
      ],
      "highlights": [
        {
          "label": "Setup command",
          "value": "sandboxctl mcp install antigravity --project ."
        },
        {
          "label": "Generated dir",
          "value": ".agents/plugins/kagex/ (or ~/.gemini/config/plugins/kagex/)"
        },
        {
          "label": "Tools exposed",
          "value": "11 MCP tools (exec, diff, apply, pull, fork, net, port)"
        }
      ],
      "codeTitle": "Configure Antigravity per-project or globally",
      "code": "# Per-project plugin bundle (.agents/plugins/kagex/)\n./_out/bin/sandboxctl mcp install antigravity --project ~/code/app\n\n# Global plugin install (~/.gemini/config/plugins/kagex/) with secret & setup guardrails\n./_out/bin/sandboxctl mcp install antigravity --global \\\n  --setup \"npm ci\" \\\n  --secrets GITHUB_TOKEN,OPENAI_API_KEY \\\n  --auto-pull",
      "sections": [
        {
          "heading": "Automatic Plugin, Rules, and Skill Scaffolding",
          "body": "Running sandboxctl mcp install antigravity writes plugin.json, mcp_config.json, rules/AGENTS.md, and skills/sandbox/SKILL.md in a single step. Antigravity discovers sandbox-mcp immediately on reload without manual JSON edits."
        },
        {
          "heading": "Host-Controlled Setup & Allowlist Security",
          "body": "Flags like --setup, --secrets, and --auto-pull are baked into the host MCP environment rather than chosen by the model. Dependency installation finishes during open setup, then the egress firewall locks down before agent prompts execute."
        }
      ],
      "faqs": [
        {
          "q": "Where does Kagex install Antigravity files with --global?",
          "a": "It writes the complete plugin bundle into ~/.gemini/config/plugins/kagex/ including plugin.json, mcp_config.json, rules/AGENTS.md, and skills/sandbox/SKILL.md."
        },
        {
          "q": "Can Antigravity subagents share or fork a sandbox?",
          "a": "Yes. Agents can call sandbox_snapshot with action=checkpoint or action=fork to branch isolated microVM copies in under a second."
        },
        {
          "q": "Does it work natively on Windows for Antigravity?",
          "a": "Yes. sandbox-mcp automatically translates Windows workspace paths into WSL2 KVM paths while talking to sandboxd over loopback 127.0.0.1:17070 with a Bearer token."
        }
      ],
      "related": [
        "cursor-mcp-sandbox",
        "claude-code-mcp-sandbox",
        "ghost-secrets-vault-mitm-proxy"
      ]
    },
    {
      "slug": "cursor-mcp-sandbox",
      "title": "Isolate Cursor AI Agent Commands Inside Local Linux MicroVMs",
      "shortTitle": "Cursor MCP Setup",
      "category": "Agent Integrations",
      "badge": "Cursor · MCP",
      "readTime": "4 min",
      "calloutFocus": 1,
      "description": "Configure Cursor with Kagex MCP (.cursor/mcp.json + .cursor/rules/sandbox.mdc) so Composer and Agent runs execute inside ~32 ms isolated Ubuntu 24.04 microVMs.",
      "summary": "Prevent Cursor agent loops from corrupting host dependencies or reading ~/.ssh by routing every terminal command through sandbox-mcp and reviewing unified patches with sandbox_diff.",
      "keywords": [
        "Cursor MCP sandbox",
        "Cursor AI microVM",
        ".cursor/mcp.json sandbox",
        "sandbox.mdc Cursor rules",
        "safe Cursor Composer execution"
      ],
      "highlights": [
        {
          "label": "MCP config",
          "value": ".cursor/mcp.json or ~/.cursor/mcp.json"
        },
        {
          "label": "Agent rule",
          "value": ".cursor/rules/sandbox.mdc"
        },
        {
          "label": "Warm attach",
          "value": "20–50 ms per task"
        }
      ],
      "codeTitle": "Install Cursor MCP + always-on sandbox.mdc rule",
      "code": "./_out/bin/sandboxctl mcp install cursor --project ~/code/app\n# Or install once globally across all repositories:\n./_out/bin/sandboxctl mcp install cursor --global",
      "sections": [
        {
          "heading": "Always-Applied .mdc Rule Generation",
          "body": "Alongside registering the stdio server in mcp.json, Kagex generates .cursor/rules/sandbox.mdc instructing Composer to use sandbox_exec, sandbox_diff, and sandbox_apply instead of host shells."
        },
        {
          "heading": "Safe Host Lockfile Sync",
          "body": "Pass --auto-pull if you want updated package-lock.json or go.sum files mirrored back automatically with backup artifacts for instant sandboxctl undo."
        }
      ],
      "faqs": [
        {
          "q": "How do I verify Cursor connected to Kagex?",
          "a": "Open Cursor Settings -> MCP, ensure the sandbox server toggle is active, and monitor live calls in your terminal via sandboxctl events."
        },
        {
          "q": "Can Cursor preview dev servers started inside the VM?",
          "a": "Yes. Cursor calls sandbox_port to bind any guest listener cleanly onto 127.0.0.1 without exposing host LAN interfaces."
        },
        {
          "q": "What happens if Cursor edits files outside /workspace inside the VM?",
          "a": "Only changes inside /workspace are surfaced by sandbox_diff and sandbox_apply; system modifications disappear automatically when the microVM is destroyed."
        }
      ],
      "related": [
        "antigravity-mcp-sandbox",
        "claude-code-mcp-sandbox",
        "one-way-workspace-sync-3way-apply-undo"
      ]
    },
    {
      "slug": "claude-code-mcp-sandbox",
      "title": "Claude Code Local MicroVM Sandboxing with Kagex MCP & SKILL.md",
      "shortTitle": "Claude Code MCP Setup",
      "category": "Agent Integrations",
      "badge": "Claude Code",
      "readTime": "4 min",
      "calloutFocus": 1,
      "description": "Give Claude Code full Ubuntu 24.04 root inside a zero-trust local microVM using sandboxctl mcp install claude, .claude/skills/sandbox/SKILL.md, and ghost secret injection.",
      "summary": "Keep Claude Code fast and autonomous without exposing host API keys or git credentials. Install the sandbox skill once and approve blocked egress domains interactively.",
      "keywords": [
        "Claude Code sandbox",
        "Claude Code MCP microVM",
        "claude mcp add sandbox",
        "Anthropic Claude safe code execution",
        "Claude SKILL.md sandbox"
      ],
      "highlights": [
        {
          "label": "Installer",
          "value": "sandboxctl mcp install claude --project ."
        },
        {
          "label": "Skill written",
          "value": ".claude/skills/sandbox/SKILL.md"
        },
        {
          "label": "Session check",
          "value": "/mcp inside Claude Code"
        }
      ],
      "codeTitle": "Register Kagex with Claude Code CLI",
      "code": "./_out/bin/sandboxctl mcp install claude --project ~/code/app --secrets ANTHROPIC_API_KEY,GITHUB_TOKEN\n# Verify active MCP status inside Claude Code:\n/mcp",
      "sections": [
        {
          "heading": "Automatic CLI Registration & Fallback",
          "body": "sandboxctl mcp install claude writes .claude/skills/sandbox/SKILL.md and registers sandbox-mcp via claude mcp add. Support for --scope project and --scope user (--global) works identically."
        },
        {
          "heading": "Reversible Experiments with Checkpoints",
          "body": "Claude Code can checkpoint before major dependency upgrades using sandbox_snapshot and roll back to a clean memory state in ~0.5 s if tests regress."
        }
      ],
      "faqs": [
        {
          "q": "What if claude CLI is not on PATH during install?",
          "a": "Kagex writes the skill file and prints the exact claude mcp add command so you can paste and run it whenever ready."
        },
        {
          "q": "Does Claude Code see my host .env file?",
          "a": "No. Workspace sync excludes .env*, *.pem, *.key, .aws, and .ssh by default so sensitive host credentials never cross into guest memory."
        },
        {
          "q": "How can Claude reach a new package registry if blocked?",
          "a": "Claude calls sandbox_network to request access to the blocked host; Claude Code prompts you for explicit approval before adding it to the session allowlist."
        }
      ],
      "related": [
        "antigravity-mcp-sandbox",
        "codex-cli-mcp-sandbox",
        "allowlist-egress-firewall-dns-rebinding"
      ]
    },
    {
      "slug": "codex-cli-mcp-sandbox",
      "title": "OpenAI Codex CLI Sandboxing via Kagex MicroVMs & AGENTS.md",
      "shortTitle": "Codex MCP Integration",
      "category": "Agent Integrations",
      "badge": "Codex CLI",
      "readTime": "4 min",
      "calloutFocus": 1,
      "description": "Wire OpenAI Codex CLI to Kagex local microVMs via ~/.codex/config.toml and AGENTS.md for isolated Linux execution, snapshot checkpoints, and safe 3-way merges.",
      "summary": "Pair OpenAI Codex CLI with hardware-enforced Ubuntu microVMs on macOS, Linux, or Windows WSL2 without paying for cloud sandboxes.",
      "keywords": [
        "Codex CLI MCP sandbox",
        "OpenAI Codex microVM",
        "codex config.toml mcp_servers",
        "AGENTS.md sandbox rules",
        "local Linux VM for Codex"
      ],
      "highlights": [
        {
          "label": "Config target",
          "value": "~/.codex/config.toml (+ .bak backup)"
        },
        {
          "label": "Rules file",
          "value": "AGENTS.md (project or global)"
        },
        {
          "label": "Timeout budget",
          "value": "startup 30s · tool 900s"
        }
      ],
      "codeTitle": "Configure Codex CLI cleanly",
      "code": "./_out/bin/sandboxctl mcp install codex --project ~/code/app\n# Appends [mcp_servers.sandbox] to ~/.codex/config.toml (keeping config.toml.bak)",
      "sections": [
        {
          "heading": "Safe Config Backup & Rule Injection",
          "body": "Kagex preserves ~/.codex/config.toml.bak before appending [mcp_servers.sandbox] and updates AGENTS.md safely without overwriting your existing repository guidelines."
        },
        {
          "heading": "Full Build & Test Parity",
          "body": "Long test suites run cleanly within the 900-second MCP tool timeout while sandboxd streams output reliably over an on-disk frame spool inside the guest."
        }
      ],
      "faqs": [
        {
          "q": "Will Codex CLI overwite my existing AGENTS.md?",
          "a": "No. Kagex appends the sandbox section cleanly while keeping backups and existing instructions intact."
        },
        {
          "q": "Can Codex run multi-minute builds without dropping output?",
          "a": "Yes. Inside the VM, guest/spool buffers stdout/stderr frames on disk and tool_timeout_sec defaults to 900 seconds."
        },
        {
          "q": "Can I watch Codex actions live in another terminal?",
          "a": "Run sandboxctl events to stream real-time sync, exec, firewall, and apply telemetry."
        }
      ],
      "related": [
        "claude-code-mcp-sandbox",
        "antigravity-mcp-sandbox",
        "custom-go-agent-harness-sdk"
      ]
    },
    {
      "slug": "mcp-tools-reference-guide",
      "title": "Complete Guide to Kagex's 11 MCP Sandbox Tools",
      "shortTitle": "11 MCP Tools Reference",
      "category": "Agent Integrations",
      "badge": "MCP Spec",
      "readTime": "6 min",
      "calloutFocus": 1,
      "description": "Detailed architecture and usage reference for all 11 Kagex MCP tools: sandbox_exec, read_file, write_file, diff, apply, pull, snapshot, network, port, status, and destroy.",
      "summary": "Understand how sandbox-mcp maps JSON-RPC stdio tool calls from coding agents directly into sandboxd orchestration operations and host-approved safety gates.",
      "keywords": [
        "sandbox-mcp tools",
        "Model Context Protocol sandbox tools",
        "sandbox_exec sandbox_diff sandbox_apply",
        "AI agent MCP server Go",
        "11 MCP tools Kagex"
      ],
      "highlights": [
        {
          "label": "Transport",
          "value": "JSON-RPC over stdio -> Unix sock / 127.0.0.1:17070"
        },
        {
          "label": "Tool count",
          "value": "11 specialized sandbox tools"
        },
        {
          "label": "Path handling",
          "value": "Auto Windows <-> WSL2 path normalization"
        }
      ],
      "codeTitle": "Run sandbox-mcp directly or inspect MCP tests",
      "code": "go test ./cmd/sandbox-mcp/... ./cmd/sandboxctl/...\n# Or inspect live tool events from any connected IDE:\n./_out/bin/sandboxctl events",
      "sections": [
        {
          "heading": "Execution, Files, and Reversible Repo Merges",
          "body": "sandbox_exec ensures host workspace deltas sync in before running commands. sandbox_diff returns unified diffs against git HEAD, while sandbox_apply and sandbox_pull run 3-way merges on temp files after backing up host targets."
        },
        {
          "heading": "Network Governance & Snapshot Control",
          "body": "sandbox_network requires explicit human confirmation in the IDE before relaxing allowlist entries, preventing unapproved exfiltration even under prompt injection."
        }
      ],
      "faqs": [
        {
          "q": "Does sandbox_write_file modify files on my host laptop?",
          "a": "No. Both sandbox_write_file and sandbox_exec operate solely on the microVM filesystem unless you invoke sandbox_apply or sandbox_pull."
        },
        {
          "q": "Why are there separate apply and pull tools?",
          "a": "apply merges code patches tracked via git diff/merge-file semantics, whereas pull copies generated artifacts like lockfiles or formatted assets back safely."
        },
        {
          "q": "Does sandbox-mcp embed Go SDK calls directly?",
          "a": "Yes. cmd/sandbox-mcp uses pkg/client over the local Unix socket or authenticated Windows TCP loopback endpoint."
        }
      ],
      "related": [
        "antigravity-mcp-sandbox",
        "sandboxd-http-rest-sse-openapi-guide",
        "one-way-workspace-sync-3way-apply-undo"
      ]
    },
    {
      "slug": "custom-go-agent-harness-sdk",
      "title": "Build Parallel AI Agent Harnesses with the Kagex Go SDK (pkg/client)",
      "shortTitle": "Go SDK & Parallel Forks",
      "category": "Agent Integrations",
      "badge": "Go SDK",
      "readTime": "5 min",
      "calloutFocus": 2,
      "description": "Use github.com/codewithevilxd/kagex/pkg/client in Go to launch microVMs, clone parallel forks with c.Fork, run candidate patches concurrently, and inspect winning diffs.",
      "summary": "Embed Kagex directly inside custom Go agent orchestrators, eval pipelines, and automated PR fixers with idiomatic context-aware clients for macOS, Linux, and Windows.",
      "keywords": [
        "Kagex Go SDK",
        "pkg/client Go microVM",
        "parallel AI agent fork Go",
        "c.CreateSandbox c.Fork Go",
        "local sandbox SDK Golang"
      ],
      "highlights": [
        {
          "label": "Import path",
          "value": "github.com/codewithevilxd/kagex/pkg/client"
        },
        {
          "label": "Example",
          "value": "docs/examples/go-harness/main.go"
        },
        {
          "label": "Concurrency",
          "value": "Native c.Fork(ctx, id, N)"
        }
      ],
      "codeTitle": "Race candidate bug fixes in parallel forks (Go)",
      "code": "c, _ := client.New(client.Options{Name: \"go-harness\"})\nsb, _ := c.CreateSandbox(ctx, client.CreateSandboxRequest{\n  Template:  \"auto\",\n  Workspace: &client.WorkspaceSpec{HostPath: abs, Mode: \"sandbox\"},\n})\ndefer c.DestroySandbox(context.Background(), sb.ID)\n\nfork, _ := c.Fork(ctx, sb.ID, 2) // 2 parallel CoW sandboxes\n// Run tests inside each fork and keep only the passing diff!",
      "sections": [
        {
          "heading": "Cross-Platform Client Auto-Discovery",
          "body": "pkg/client automatically locates the Unix domain socket on macOS/Linux or reads the Windows loopback endpoint and Bearer token metadata from %LOCALAPPDATA%\\sandboxd\\ without manual platform branching."
        },
        {
          "heading": "Deterministic Eval & Tree-Search Workflows",
          "body": "Because c.Fork branches a running sandbox via CoW in ~0.8 s, autonomous bug-fixing harnesses can evaluate multiple hypotheses in parallel and apply only verified diffs."
        }
      ],
      "faqs": [
        {
          "q": "Does pkg/client require cgo?",
          "a": "No. pkg/client is pure Go HTTP/JSON over Unix sockets or loopback TCP."
        },
        {
          "q": "Can I run multiple goroutines issuing Exec calls concurrently?",
          "a": "Yes. Both client.Client and guest/server over multiplexed vsock support safe concurrent operations."
        },
        {
          "q": "Where can I run the working Go example?",
          "a": "Execute go run ./docs/examples/go-harness -repo test/node-app while sandboxd is running."
        }
      ],
      "related": [
        "parallel-agent-forking-workflows",
        "python-sse-agent-sandbox",
        "sandboxd-http-rest-sse-openapi-guide"
      ]
    },
    {
      "slug": "python-sse-agent-sandbox",
      "title": "Stream AI Sandbox Commands from Python over Unix Socket & SSE",
      "shortTitle": "Python & SSE Automation",
      "category": "Agent Integrations",
      "badge": "Python · SSE",
      "readTime": "4 min",
      "calloutFocus": 3,
      "description": "Integrate Python AI workflows (LangGraph, CrewAI, AutoGen, custom eval loops) with Kagex over AF_UNIX or TCP using stdlib http.client and real-time Server-Sent Events.",
      "summary": "Zero external packages needed: stream live stdout/stderr over /v1/executions/{id}/stream, search huge build logs via /grep, and clean up sandboxes reliably in Python.",
      "keywords": [
        "Python microVM sandbox",
        "Python SSE code execution",
        "Unix socket http.client sandbox",
        "AI agent Python sandbox local",
        "sandboxd Python harness"
      ],
      "highlights": [
        {
          "label": "Example",
          "value": "docs/examples/python-harness/harness.py"
        },
        {
          "label": "Dependencies",
          "value": "Python 3 stdlib only (no pip required)"
        },
        {
          "label": "Log search",
          "value": "GET /v1/executions/{id}/grep"
        }
      ],
      "codeTitle": "Run the built-in Python stdlib SSE harness",
      "code": "# macOS / Linux Unix socket:\npython3 docs/examples/python-harness/harness.py ./test/node-app\n\n# Windows / Docker TCP + Bearer token:\nSANDBOXD_URL=http://127.0.0.1:17070 SANDBOXD_TOKEN=\"$(sandboxd token)\" \\\n  python3 docs/examples/python-harness/harness.py",
      "sections": [
        {
          "heading": "Real-Time Streaming & Structured Output Search",
          "body": "Pass wait=false when calling /v1/sandboxes/{id}/exec to get an immediate exec_id, then consume chunked stdout/stderr/exit frames via Server-Sent Events or query large logs with regex grep without blowing agent context windows."
        },
        {
          "heading": "Drop-In Replacement for Cloud Evaluators",
          "body": "Swap cloud code-interpreter API calls in SWE-bench or Python agent loops with HTTP calls to localhost sandboxd for instant zero-cost iteration."
        }
      ],
      "faqs": [
        {
          "q": "Does Python need root or Docker access?",
          "a": "No. Python talks solely to the sandboxd HTTP socket using OS peer credentials on Unix or a local Bearer token on TCP."
        },
        {
          "q": "Can Python harness scripts stream multi-thousand-line test logs?",
          "a": "Yes. SSE delivers frames continuously and truncated responses stay searchable on the host via GET /v1/executions/{exec_id}/grep."
        },
        {
          "q": "Can I use httpx or aiohttp instead of stdlib?",
          "a": "Yes — any HTTP/1.1 client supporting Unix domain sockets or loopback TCP Bearer headers works seamlessly against docs/openapi.yaml."
        }
      ],
      "related": [
        "sandboxd-http-rest-sse-openapi-guide",
        "custom-go-agent-harness-sdk",
        "kagex-vs-e2b-local-microvm"
      ]
    },
    {
      "slug": "macos-apple-silicon-virtualization-framework",
      "title": "Rootless Apple Silicon MicroVMs with Virtualization.framework & APFS CoW",
      "shortTitle": "macOS Virtualization.framework",
      "category": "Platforms & Hypervisors",
      "badge": "macOS 14+",
      "readTime": "5 min",
      "calloutFocus": 6,
      "description": "How Kagex runs Ubuntu 24.04 microVMs natively on macOS 14+ Apple Silicon with Virtualization.framework, APFS clonefile CoW disks, and gVisor userspace networking — zero root or Docker runtime required.",
      "summary": "No Lima VM tax, no Docker Desktop license, and no sudo required at runtime. Kagex uses Apple's native hypervisor entitlement with APFS copy-on-write cloning for ~32 ms sandbox starts.",
      "keywords": [
        "Apple Virtualization.framework Go",
        "macOS microVM sandbox",
        "APFS clonefile CoW VM",
        "Code-Hex/vz microVM",
        "M1 M2 M3 M4 local AI sandbox"
      ],
      "highlights": [
        {
          "label": "Hypervisor",
          "value": "Apple Virtualization.framework (Code-Hex/vz/v3)"
        },
        {
          "label": "Disk CoW",
          "value": "APFS clonefile (~instant snapshot copies)"
        },
        {
          "label": "Egress stack",
          "value": "gVisor tap-vsock userspace netstack"
        }
      ],
      "codeTitle": "Build, ad-hoc sign, and start sandboxd on macOS",
      "code": "git clone https://github.com/CodewithEvilxd/kagex.git && cd kagex\nmake images build   # fetches kernel, builds rootfs, signs with infra/vz.entitlements\n./_out/bin/sandboxd install --artifacts _out\n./_out/bin/sandboxd doctor",
      "sections": [
        {
          "heading": "Rootless Entitlement Signing",
          "body": "make build automatically runs codesign with infra/vz.entitlements so sandboxd boots native Linux guests as your regular unprivileged macOS user."
        },
        {
          "heading": "APFS Clonefile & Memory Budget Reserve",
          "body": "Each golden image clone or fork allocates disk blocks via APFS copy-on-write without duplicating gigabytes. By default, scheduler reserves ~50% of Mac unified memory safely."
        }
      ],
      "faqs": [
        {
          "q": "Does macOS need Docker Desktop running while using Kagex?",
          "a": "No. Docker Desktop is only used once if building the Ubuntu base rootfs locally via make images; runtime microVMs have zero Docker dependency."
        },
        {
          "q": "Does sandboxd auto-start on login on macOS?",
          "a": "Yes. Running sandboxd install --artifacts _out installs a LaunchAgent under your user account (or pass --no-service for foreground testing)."
        },
        {
          "q": "Can nested Docker containers run inside the macOS microVM?",
          "a": "Yes! Because the guest runs a real Linux kernel inside Virtualization.framework, nested dockerd works cleanly inside the sandbox."
        }
      ],
      "related": [
        "linux-firecracker-kvm-microvms",
        "windows-11-wsl2-kvm-agent-sandbox",
        "32ms-warm-pool-microvm-boot"
      ]
    },
    {
      "slug": "linux-firecracker-kvm-microvms",
      "title": "Linux KVM & Firecracker v1.12.1 MicroVMs with Per-VM Netns & nftables",
      "shortTitle": "Linux Firecracker KVM",
      "category": "Platforms & Hypervisors",
      "badge": "Linux KVM",
      "readTime": "5 min",
      "calloutFocus": 8,
      "description": "Deploy Firecracker v1.12.1 microVMs on amd64 and arm64 Linux hosts with isolated network namespaces, nftables egress filtering, and FICLONE copy-on-write disks.",
      "summary": "Hardware KVM virtualization paired with dedicated per-VM netns/nftables firewalls gives autonomous agents isolated Linux kernels with near-zero memory overhead.",
      "keywords": [
        "Firecracker v1.12.1 AI sandbox",
        "Linux KVM microVM Go",
        "nftables per-VM network namespace",
        "FICLONE sparse CoW rootfs",
        "arm64 amd64 Firecracker agent"
      ],
      "highlights": [
        {
          "label": "VMM",
          "value": "Firecracker v1.12.1 over /dev/kvm"
        },
        {
          "label": "Network",
          "value": "Per-VM netns + nftables + MITM proxy"
        },
        {
          "label": "Architectures",
          "value": "Linux x86_64 (amd64) & arm64"
        }
      ],
      "codeTitle": "Provision KVM prerequisites and build on Linux",
      "code": "sudo ./infra/scripts/setup-linux.sh   # Firecracker, nftables, iproute2, e2fsprogs\nmake images build                     # Builds kernel, rootfs (Docker/debootstrap) & binaries\nsudo ./_out/bin/sandboxd install --artifacts _out",
      "sections": [
        {
          "heading": "Defense-in-Depth Per-VM Namespaces",
          "body": "Every Firecracker instance receives an isolated Linux network namespace wired via nftables rules so raw packet spoofing, LAN probes, and metadata requests (169.254.169.254) drop at kernel level before reaching host proxies."
        },
        {
          "heading": "Sparse SEEK_DATA & FICLONE CoW Storage",
          "body": "On XFS/Btrfs filesystems supporting reflink, snapshots clone instantly via FICLONE; on ext4, Kagex falls back to sparse SEEK_DATA/CopyFileRange copies keeping disk usage minimal."
        }
      ],
      "faqs": [
        {
          "q": "Does Linux rootfs build require Docker?",
          "a": "No. infra/scripts/build-rootfs.sh works with Docker when present or native debootstrap directly on Linux."
        },
        {
          "q": "Does arm64 Linux work too?",
          "a": "Yes. Both amd64 and arm64 KVM hosts are first-class targets verified in CI."
        },
        {
          "q": "Can sandboxd manage systemd startup automatically?",
          "a": "Yes. sandboxd install --artifacts _out configures systemd cleanly unless --no-service is passed."
        }
      ],
      "related": [
        "windows-11-wsl2-kvm-agent-sandbox",
        "macos-apple-silicon-virtualization-framework",
        "allowlist-egress-firewall-dns-rebinding"
      ]
    },
    {
      "slug": "windows-11-wsl2-kvm-agent-sandbox",
      "title": "Windows 10 & 11 Local Firecracker MicroVMs via Non-Admin WSL2 KVM",
      "shortTitle": "Windows WSL2 KVM Setup",
      "category": "Platforms & Hypervisors",
      "badge": "Windows 10/11",
      "readTime": "5 min",
      "calloutFocus": 6,
      "description": "Run real Firecracker KVM Ubuntu 24.04 microVMs on Windows 10/11 Home, Pro, or Enterprise with native .exe CLI/MCP binaries, one-command PowerShell setup, and automatic WSL2 path translation.",
      "summary": "Full parity on Windows without needing Hyper-V Pro or Docker Desktop: one PowerShell script builds Windows & WSL2 binaries, configures Firecracker/nftables inside WSL2, and registers HKCU startup.",
      "keywords": [
        "Windows 11 AI agent sandbox",
        "WSL2 Firecracker KVM",
        "setup-windows.ps1 Kagex",
        "Windows Home microVM sandbox",
        "127.0.0.1:17070 sandboxd bearer token"
      ],
      "highlights": [
        {
          "label": "One-shot installer",
          "value": "scripts\\setup-windows.ps1"
        },
        {
          "label": "Control API",
          "value": "127.0.0.1:17070 + Bearer token"
        },
        {
          "label": "Privilege needed",
          "value": "Non-Admin (HKCU per-user startup)"
        }
      ],
      "codeTitle": "Provision Windows 10/11 + WSL2 KVM in one script",
      "code": "wsl --install -d Ubuntu-24.04   # Once if no WSL2 distro exists yet\ngit clone https://github.com/CodewithEvilxd/kagex.git; cd kagex\npowershell -NoProfile -ExecutionPolicy Bypass -File .\\scripts\\setup-windows.ps1",
      "sections": [
        {
          "heading": "Seamless Windows <-> Linux Path Translation",
          "body": "internal/winwsl automatically converts Windows workspace paths (including paths with spaces) into WSL2 paths, manages physical VHDX headroom checks, and forwards commands seamlessly over authenticated loopback TCP."
        },
        {
          "heading": "100% Feature Parity Across All 11 MCP Tools",
          "body": "Checkpoints, parallel forks, --auto-pull, bidirectional sandboxctl cp, nested dockerd inside guests, and IDE integrations work identically on Windows 10/11 Home & Pro."
        }
      ],
      "faqs": [
        {
          "q": "Does Windows require Administrator rights or Windows Pro?",
          "a": "No. Kagex runs cleanly on Windows 10/11 Home, Pro, and Enterprise via WSL2 KVM and registers a per-user HKCU startup entry."
        },
        {
          "q": "How does authentication work over loopback TCP?",
          "a": "sandboxd generates a cryptographic per-daemon Bearer token stored under %LOCALAPPDATA%\\sandboxd\\ and rejects unauthorized hosts or browser CSRF origins."
        },
        {
          "q": "What if port 17070 is busy?",
          "a": "sandboxd automatically selects a free loopback port starting at 127.0.0.1:17070 and updates local client discovery metadata."
        }
      ],
      "related": [
        "linux-firecracker-kvm-microvms",
        "antigravity-mcp-sandbox",
        "nested-docker-inside-microvm"
      ]
    },
    {
      "slug": "nested-docker-inside-microvm",
      "title": "Run Nested dockerd & Testcontainers Safely Inside MicroVM Sandboxes",
      "shortTitle": "Nested Docker Inside VMs",
      "category": "Platforms & Hypervisors",
      "badge": "Nested Docker",
      "readTime": "4 min",
      "calloutFocus": 4,
      "description": "Execute Docker builds, Compose stacks, and integration containers safely inside an isolated Kagex Ubuntu 24.04 microVM without granting AI agents access to your host Docker socket.",
      "summary": "Mounting /var/run/docker.sock gives an agent instant root on your laptop. Inside Kagex, agents run a dedicated dockerd inside the guest kernel — zero host exposure.",
      "keywords": [
        "nested docker microVM",
        "safe docker.sock alternative AI agent",
        "Testcontainers inside microVM",
        "isolated Docker builds Firecracker",
        "Docker in Virtualization.framework"
      ],
      "highlights": [
        {
          "label": "Socket safety",
          "value": "Zero host /var/run/docker.sock exposure"
        },
        {
          "label": "Daemon script",
          "value": "infra/image/start-docker + wrapper"
        },
        {
          "label": "Reset time",
          "value": "Disposable on sandbox rm / restore"
        }
      ],
      "codeTitle": "Run Docker workflows inside an ephemeral sandbox",
      "code": "ID=$(sandboxctl create -w ~/code/service-api | awk '{print $1}')\nsandboxctl exec \"$ID\" -- 'docker compose -f compose.test.yml up --abort-on-container-exit'\nsandboxctl rm \"$ID\"",
      "sections": [
        {
          "heading": "Why /var/run/docker.sock Breaks Security",
          "body": "Any process able to talk to the host Docker daemon can bind-mount / and become host root in seconds. Kagex boots dockerd cleanly inside a disposable guest VM kernel instead."
        },
        {
          "heading": "Disposable Sidecars & Databases",
          "body": "Agents can spin up PostgreSQL, Redis, or Playwright containers during test suites knowing container state evaporates cleanly when the microVM exits."
        }
      ],
      "faqs": [
        {
          "q": "Does nested Docker work on macOS Apple Silicon microVMs?",
          "a": "Yes. Both Apple Virtualization.framework and Linux/WSL2 Firecracker guests boot full Ubuntu kernels with dockerd support."
        },
        {
          "q": "Can agents pull images from Docker Hub or GHCR?",
          "a": "Container registries are part of the configurable egress allowlist policy, while internal LAN access remains blocked."
        },
        {
          "q": "How do I preserve pulled layers across runs?",
          "a": "Promote a configured sandbox with warmed dependencies to a golden template snapshot via sandboxctl."
        }
      ],
      "related": [
        "kagex-vs-docker-for-ai-agents",
        "macos-apple-silicon-virtualization-framework",
        "allowlist-egress-firewall-dns-rebinding"
      ]
    },
    {
      "slug": "virtio-vsock-grpc-guest-agent",
      "title": "How sandbox-agent Works: PID 1 Linux Guest Agent & gRPC over AF_VSOCK",
      "shortTitle": "AF_VSOCK Guest Agent",
      "category": "Platforms & Hypervisors",
      "badge": "PID 1 · gRPC",
      "readTime": "5 min",
      "calloutFocus": 3,
      "description": "Inside Kagex's initramfs PID 1 guest runtime (internal/guest): AF_VSOCK port 52 transport, zombie process reaping, PTY streams, frame spooling, and traversal-safe file RPCs.",
      "summary": "No SSH daemon, no open TCP guest ports, no brittle expect scripts. Kagex embeds a tiny static Go agent as PID 1 inside every microVM over hardware-isolated AF_VSOCK.",
      "keywords": [
        "AF_VSOCK gRPC microVM",
        "PID 1 Go initd initramfs",
        "sandbox-agent guest runtime",
        "vsock port 52 communication",
        "SIGCHLD zombie reaper Go"
      ],
      "highlights": [
        {
          "label": "Transport",
          "value": "gRPC over AF_VSOCK port 52"
        },
        {
          "label": "Proto contract",
          "value": "internal/proto/guest/v1/guest.proto"
        },
        {
          "label": "Components",
          "value": "initd, proc, execd, spool, files, server"
        }
      ],
      "codeTitle": "Regenerate protobuf bindings & run guest tests",
      "code": "make proto         # buf generate in internal/proto\nmake test-linux    # runs internal/guest/proc tests in ubuntu:24.04 container",
      "sections": [
        {
          "heading": "Initramfs Boot & Zombie Process Reaping",
          "body": "guest/initd mounts virtual filesystems, configures netlink networking, performs switch_root into Ubuntu 24.04, and supervises a singleton SIGCHLD reaper (guest/proc) alongside a deadman timer."
        },
        {
          "heading": "OOM Detection & Frame Spooling",
          "body": "guest/execd isolates every invocation in its own process group, monitors /proc/vmstat OOM counters, and persists output frames in guest/spool so streaming reconnects never lose terminal logs."
        }
      ],
      "faqs": [
        {
          "q": "Why use AF_VSOCK instead of SSH?",
          "a": "AF_VSOCK works independently of guest IP configuration or firewall rules, boots instantly in milliseconds, and needs zero SSH keys inside the VM."
        },
        {
          "q": "Does the guest agent run commands as root or non-root?",
          "a": "Workloads run inside a dedicated guest microVM kernel with full sandbox control and clean process-group cleanup."
        },
        {
          "q": "Where are the protobuf contracts defined?",
          "a": "See internal/proto/guest/v1/guest.proto and generated bindings in internal/proto/gen/guest/v1."
        }
      ],
      "related": [
        "safefs-zero-shared-folders-isolation",
        "3d-mk4-hypervisor-cutaway-architecture",
        "opentelemetry-prometheus-grafana-microvm-metrics"
      ]
    },
    {
      "slug": "ghost-secrets-vault-mitm-proxy",
      "title": "Ghost Secrets Vault: Keeping API Keys & Tokens Out of AI Sandbox RAM",
      "shortTitle": "Ghost Secrets Vault",
      "category": "Security & Zero-Trust",
      "badge": "Zero-Leak",
      "readTime": "6 min",
      "calloutFocus": 7,
      "description": "Protect GitHub PATs, OpenAI/Anthropic keys, and deploy tokens even when an AI agent has root inside its microVM using synthetic placeholders (sbxph_...) and host ECDSA P-256 TLS swapping.",
      "summary": "Even if prompt injection compromises an AI agent inside the VM and inspects every byte of /proc or environment memory, real API secrets never exist inside guest RAM.",
      "keywords": [
        "ghost secrets AI sandbox",
        "sbxph placeholder injection",
        "prevent prompt injection API key leak",
        "MITM TLS proxy secrets Go",
        "sandboxctl secret set"
      ],
      "highlights": [
        {
          "label": "Placeholder form",
          "value": "sbxph_<name>_<hex>"
        },
        {
          "label": "TLS CA",
          "value": "Per-daemon ECDSA P-256 local CA"
        },
        {
          "label": "Leak defense",
          "value": "scrubReader + cleartext drop + raw input reject"
        }
      ],
      "codeTitle": "Store host secrets & bind to allowlisted domains",
      "code": "# Store secret safely on host (0600); never copied raw into VMs\nsandboxctl secret set OPENAI_API_KEY --hosts api.openai.com\nsandboxctl secret set-git GITHUB_TOKEN --repos codewithevilxd/* --branches 'sbx/*'\n\n# Attach placeholders cleanly when starting a sandbox:\nsandboxctl create -w ~/code/app --secrets OPENAI_API_KEY,GITHUB_TOKEN",
      "sections": [
        {
          "heading": "Host-Side Substitution & Response Scrubbing",
          "body": "When the VM calls https://api.openai.com with Bearer sbxph_..., the host egress proxy terminates TLS via a local ECDSA P-256 CA, swaps the real key solely for verified host patterns, and scrubs echoed secrets via scrubReader before returning HTTP responses."
        },
        {
          "heading": "Exfiltration Prevention Across Channels",
          "body": "If an attacker attempts to curl an unauthorized webhook or downgrade to cleartext HTTP carrying a placeholder, Kagex drops the request. Commands, stdin, env vars, and synced files containing raw secret values are rejected up front."
        }
      ],
      "faqs": [
        {
          "q": "Can code inside the VM print env vars to steal my real OpenAI key?",
          "a": "No. Printing env or reading memory inside the VM only reveals sbxph_..., which is invalid outside the host egress proxy."
        },
        {
          "q": "What if an API echoes back Authorization headers inside an error response?",
          "a": "Kagex passes upstream HTTP bodies through scrubReader so real credentials are redacted back into placeholders before reaching the guest."
        },
        {
          "q": "Does Kagex protect .env files already in my repository?",
          "a": "Yes. Workspace delta sync skips .env*, *.pem, *.key, id_*, .npmrc, .aws, and .ssh automatically."
        }
      ],
      "related": [
        "allowlist-egress-firewall-dns-rebinding",
        "git-smart-http-branch-push-guard",
        "zero-trust-ai-code-execution"
      ]
    },
    {
      "slug": "allowlist-egress-firewall-dns-rebinding",
      "title": "Default-Deny Allowlist Egress Firewall & DNS Rebinding Defense",
      "shortTitle": "Egress Allowlist & DNS",
      "category": "Security & Zero-Trust",
      "badge": "Firewall",
      "readTime": "5 min",
      "calloutFocus": 9,
      "description": "How Kagex blocks LAN lateral movement, AWS/GCP IMDS metadata endpoints (169.254.169.254), loopback probes, and DNS rebinding attacks for autonomous coding agents.",
      "summary": "Packages and approved APIs pass through cleanly while internal company networks, localhost services, CGNAT, and untrusted webhooks fail closed.",
      "keywords": [
        "AI sandbox egress firewall",
        "DNS rebinding protection microVM",
        "block 169.254.169.254 IMDS sandbox",
        "allowlist outbound proxy Go",
        "sandboxctl net allowlist"
      ],
      "highlights": [
        {
          "label": "Always denied",
          "value": "127.0.0.0/8 · RFC1918 · 169.254.0.0/16 · 100.64.0.0/10"
        },
        {
          "label": "Policy modes",
          "value": "allowlist (default) · none · full · @presets"
        },
        {
          "label": "SNI check",
          "value": "Host + SNI + resolved IP verification"
        }
      ],
      "codeTitle": "Manage allowlists during setup and execution",
      "code": "# Inspect or test egress rules live:\nsandboxctl net status \"$ID\"\nsandboxctl net allow \"$ID\" pypi.org files.pythonhosted.org\n\n# Setup dependencies openly during bootstrap, then auto-lockdown:\nsandboxctl mcp install cursor --setup \"pip install -r requirements.txt\" --project .",
      "sections": [
        {
          "heading": "Stopping SSRF & DNS Rebinding Before Connect",
          "body": "internal/network/dns intercepts lookups and discards any A/AAAA record resolving to loopback, private LAN, link-local metadata, or CGNAT ranges. Even wildcard DNS tricks pointing to 127.0.0.1 or 10.0.0.0/8 cannot slip through."
        },
        {
          "heading": "Setup Phase vs Strict Runtime Phase",
          "body": "Use --setup for package fetches that touch diverse CDNs once per fresh template, then let Kagex transition automatically into minimal allowlist enforcement."
        }
      ],
      "faqs": [
        {
          "q": "Can an agent hit localhost databases running on my host?",
          "a": "No. Loopback (127.0.0.0/8) and host LAN interfaces are unconditionally blocked from inside microVMs."
        },
        {
          "q": "What hosts are permitted under the default allowlist?",
          "a": "Common developer ecosystems including major package registries, GitHub, and Ubuntu package mirrors."
        },
        {
          "q": "Can a coding agent modify its own allowlist silently?",
          "a": "No. sandbox_network requires interactive human approval in the IDE client before opening any blocked domain."
        }
      ],
      "related": [
        "ghost-secrets-vault-mitm-proxy",
        "3d-mk4-hypervisor-cutaway-architecture",
        "zero-trust-ai-code-execution"
      ]
    },
    {
      "slug": "one-way-workspace-sync-3way-apply-undo",
      "title": "Reversible AI Edits: One-Way Host Sync, Diff, 3-Way Apply, and Undo",
      "shortTitle": "Diff, 3-Way Apply & Undo",
      "category": "Security & Zero-Trust",
      "badge": "CoW Sync",
      "readTime": "5 min",
      "calloutFocus": 10,
      "description": "Never wake up to a wiped git repo: Kagex mirrors workspaces host-to-VM one way over vsock, previews diffs, runs safe git merge-file 3-way applies, and archives backups for one-command undo.",
      "summary": "Even if an agent executes rm -rf /workspace inside its microVM, zero bytes change on your laptop. Verified edits return strictly through transactional backups.",
      "keywords": [
        "one-way git sandbox sync",
        "3-way merge AI edits git merge-file",
        "reversible AI coding agent changes",
        "sandboxctl diff apply undo",
        "prevent AI wiping local repo"
      ],
      "highlights": [
        {
          "label": "Sync direction",
          "value": "Strictly Host -> VM (AF_VSOCK tar)"
        },
        {
          "label": "Host merge",
          "value": "git merge-file on temp files (index untouched)"
        },
        {
          "label": "Rollback",
          "value": "sandboxctl undo <artifact_id>"
        }
      ],
      "codeTitle": "Review, merge, and roll back agent patches safely",
      "code": "sandboxctl exec \"$ID\" -- npm run lint -- --fix\nsandboxctl diff \"$ID\"          # Inspect clean patch vs HEAD\nsandboxctl apply \"$ID\"         # Prints: \"undo with: sandboxctl undo art_...\"\nsandboxctl undo art_01J...     # Restores exact pre-apply host snapshot",
      "sections": [
        {
          "heading": "Non-Destructive Git Tree Protection",
          "body": "Kagex never executes git commit, checkout, reset, or index mutations in your local repository. Three-way merges run on temporary files via git merge-file and verify symlink/traversal safety before writing."
        },
        {
          "heading": "Conflict Guard on Concurrent Host Edits",
          "body": "If you edited a file on your laptop while the agent modified the same file inside the VM, pull refuses to clobber your work unless explicitly merged or forced."
        }
      ],
      "faqs": [
        {
          "q": "Does rm -rf . inside the sandbox affect my host folder?",
          "a": "Not at all. Guest filesystems sit in an isolated VM disk copy with no host folder mount."
        },
        {
          "q": "What files are excluded during workspace sync?",
          "a": "Sensitive files such as .env*, *.pem, *.key, id_*, .npmrc, .aws, and .ssh are excluded, and .git/config has credentials stripped."
        },
        {
          "q": "How do I undo an apply after reviewing it?",
          "a": "Copy the art_... ID printed by sandboxctl apply and run sandboxctl undo art_... (list past backups via sandboxctl artifacts)."
        }
      ],
      "related": [
        "safefs-zero-shared-folders-isolation",
        "ghost-secrets-vault-mitm-proxy",
        "cursor-mcp-sandbox"
      ]
    },
    {
      "slug": "git-smart-http-branch-push-guard",
      "title": "Scoped Git Credentials & Branch Push Guardrails for Autonomous Agents",
      "shortTitle": "Git Proxy & Branch Guard",
      "category": "Security & Zero-Trust",
      "badge": "Git Safety",
      "readTime": "4 min",
      "calloutFocus": 7,
      "description": "Strip raw .git/config tokens on sync and enforce repository + branch glob policies (like sbx/*) on autonomous git pushes via Kagex's smart-HTTP Git proxy.",
      "summary": "Let agents clone private repos or open experimental branches safely while blocking force pushes or writes to main.",
      "keywords": [
        "safe git push AI agent",
        "strip git credentials sandbox",
        "restrict AI agent branch glob sbx/*",
        "sandboxctl secret set-git",
        "git smart HTTP proxy Go"
      ],
      "highlights": [
        {
          "label": "Sync strip",
          "value": "Credential helpers, auth headers & URL creds stripped"
        },
        {
          "label": "Push scope",
          "value": "Allowed owner/repo + branch globs (e.g. sbx/*)"
        },
        {
          "label": "CLI setup",
          "value": "sandboxctl secret set-git"
        }
      ],
      "codeTitle": "Scope Git pushes strictly to sandbox branches",
      "code": "sandboxctl secret set-git GITHUB_TOKEN \\\n  --repos \"codewithevilxd/*\" \\\n  --branches \"sbx/*,agent/*\"",
      "sections": [
        {
          "heading": "Sanitized .git/config Inside Every VM",
          "body": "Before copying your repository into /workspace, internal/workspace/sync strips credential helpers, HTTP Authorization extraheaders, includes, and embedded URL tokens from .git/config."
        },
        {
          "heading": "Proxy-Enforced Branch Rules",
          "body": "Outbound git smart-HTTP traffic routes through the host vault, injecting the token only for matching repositories and rejecting pushes targeting main or protected branches."
        }
      ],
      "faqs": [
        {
          "q": "Can an agent push directly to main if my PAT has repo write access?",
          "a": "No. If you bind the token with --branches 'sbx/*', Kagex rejects pushes to any other branch ref at the host proxy."
        },
        {
          "q": "Does the guest see my git credential helper?",
          "a": "No. All credential helpers and include directives are sanitized when syncing .git/config."
        },
        {
          "q": "What happens if an agent puts the token inside git remote set-url?",
          "a": "Since the guest never holds the real PAT (only a placeholder), remote URL substitution works safely without exposing real credentials."
        }
      ],
      "related": [
        "ghost-secrets-vault-mitm-proxy",
        "one-way-workspace-sync-3way-apply-undo",
        "zero-trust-ai-code-execution"
      ]
    },
    {
      "slug": "safefs-zero-shared-folders-isolation",
      "title": "Why Kagex Bans virtio-fs & Uses safefs Symlink-Fenced Host Writes",
      "shortTitle": "No virtio-fs & safefs",
      "category": "Security & Zero-Trust",
      "badge": "Defense-in-Depth",
      "readTime": "4 min",
      "calloutFocus": 5,
      "description": "Learn why Kagex disables shared host folders (no virtio-fs or 9p mounts), validates every tar path against symlink escapes in guest/files, and fences cleanup via internal/safefs.",
      "summary": "Shared folders introduce TOCTOU symlink races and accidental host deletions. Explicit vsock transfers plus safefs.RemoveUnder close the entire bug class.",
      "keywords": [
        "no virtio-fs AI sandbox",
        "safefs RemoveUnder symlink attack",
        "path traversal defense microVM",
        "guest/files tar copy validation",
        "AI agent filesystem isolation"
      ],
      "highlights": [
        {
          "label": "Host mounts",
          "value": "None (zero virtio-fs / 9p shares)"
        },
        {
          "label": "Guest transfer",
          "value": "Traversal-checked tar streams over vsock"
        },
        {
          "label": "Host cleanup",
          "value": "internal/safefs.RemoveUnder"
        }
      ],
      "codeTitle": "Verify safefs path-confinement unit tests",
      "code": "go test -v ./internal/safefs/... ./internal/workspace/...",
      "sections": [
        {
          "heading": "Eliminating Shared-Folder Escape Surfaces",
          "body": "Mounting host folders into untrusted guests relies on continuous path translation across kernel boundaries. Copying explicit deltas over AF_VSOCK gives a strict air-gap between VM syscalls and host inodes."
        },
        {
          "heading": "Symlink-Resolved Deletion Fencing",
          "body": "Every daemon cleanup operation outside temporary paths goes through safefs.RemoveUnder(root, path), verifying real resolved canonical targets never escape the daemon data root."
        }
      ],
      "faqs": [
        {
          "q": "Does banning virtio-fs make repo sync slow?",
          "a": "No. Delta tar sync pushes only modified files over memory-backed vsock in milliseconds."
        },
        {
          "q": "Can a malicious symlink created inside the VM read /etc/passwd on the host on apply?",
          "a": "No. guest/files, apply, and pull reject absolute paths, '..' segments, escaping symlinks, and .git/ paths."
        },
        {
          "q": "Where is host sandbox state stored?",
          "a": "macOS uses ~/Library/Application Support/sandboxd/, Linux/WSL2 uses /var/lib/sandboxd/, and Windows metadata lives in %LOCALAPPDATA%\\sandboxd\\."
        }
      ],
      "related": [
        "one-way-workspace-sync-3way-apply-undo",
        "virtio-vsock-grpc-guest-agent",
        "zero-trust-ai-code-execution"
      ]
    },
    {
      "slug": "zero-trust-ai-code-execution",
      "title": "Zero-Trust Architecture for Autonomous Coding Agents in 2026",
      "shortTitle": "Zero-Trust Agent Execution",
      "category": "Security & Zero-Trust",
      "badge": "Threat Model",
      "readTime": "6 min",
      "calloutFocus": 7,
      "description": "End-to-end threat model covering prompt injection, dependency supply-chain scripts (postinstall), credential harvesting, LAN reconnaissance, and destructive shell commands inside AI coding sandboxes.",
      "summary": "Assume every LLM tool call can execute arbitrary attacker-controlled scripts from untrusted repos or npm packages — Kagex contains every layer automatically.",
      "keywords": [
        "zero-trust AI coding agent",
        "prompt injection sandbox defense",
        "malicious npm postinstall isolation",
        "AI agent security threat model",
        "safe autonomous coding environment"
      ],
      "highlights": [
        {
          "label": "Untrusted code",
          "value": "Isolated single-tenant Ubuntu 24.04 kernel"
        },
        {
          "label": "API keys",
          "value": "Host enclave placeholders only"
        },
        {
          "label": "Daemon auth",
          "value": "SO_PEERCRED / LOCAL_PEERCRED + CSRF origin checks"
        }
      ],
      "codeTitle": "Audit all host & security settings",
      "code": "sandboxd config    # Inspect active egress, memory, and vault configuration\nsandboxctl doctor  # Verify daemon health and isolation boundaries",
      "sections": [
        {
          "heading": "Defending Against Malicious Repositories & Prompt Injection",
          "body": "Opening an unfamiliar repository in Cursor, Antigravity, or Claude Code exposes agents to malicious Makefiles, npm postinstall hooks, and hidden README instructions. In Kagex, postinstall hooks have zero access to host files, SSH keys, or LAN services."
        },
        {
          "heading": "Daemon API Hardening Against Browser CSRF",
          "body": "internal/api/middleware checks Unix peer UID credentials (SO_PEERCRED / LOCAL_PEERCRED), enforces TCP Bearer tokens, and rejects unexpected Origin or Host headers to block browser-based localhost attacks."
        }
      ],
      "faqs": [
        {
          "q": "Why aren't agent system prompt rules enough for security?",
          "a": "Prompt instructions can be bypassed by prompt injection inside issues, code comments, or logs. Kagex enforces boundaries in hypervisor, kernel, network, and host Go code."
        },
        {
          "q": "Can a webpage in my browser send requests to localhost sandboxd?",
          "a": "No. Middleware drops requests carrying browser Origin headers or mismatched Host headers and requires Bearer auth on TCP."
        },
        {
          "q": "Where should security vulnerabilities be reported?",
          "a": "Follow the private disclosure policy in docs/SECURITY.md directly via codewithevilxd@gmail.com."
        }
      ],
      "related": [
        "ghost-secrets-vault-mitm-proxy",
        "allowlist-egress-firewall-dns-rebinding",
        "kagex-vs-docker-for-ai-agents"
      ]
    },
    {
      "slug": "kagex-vs-e2b-local-microvm",
      "title": "Kagex vs E2B: Local Zero-Cost MicroVMs vs Cloud Sandboxes",
      "shortTitle": "Kagex vs E2B Comparison",
      "category": "Comparisons",
      "badge": "Comparison",
      "readTime": "5 min",
      "calloutFocus": 6,
      "description": "Compare Kagex vs E2B for AI coding agents: latency (20–50 ms local warm pool), cost ($0 vs cloud VM billing), privacy (source never leaves your laptop), and Ghost Secrets.",
      "summary": "Think 'E2B, but running natively on your own Mac, Linux box, or Windows PC' — proprietary code stays on disk, builds run offline-safe, and parallel forks cost $0.",
      "keywords": [
        "Kagex vs E2B",
        "open source E2B alternative local",
        "self-hosted E2B microVM macOS",
        "free local AI code sandbox",
        "offline microVM coding agent"
      ],
      "highlights": [
        {
          "label": "Cost",
          "value": "$0 (MIT local hardware)"
        },
        {
          "label": "Warm boot",
          "value": "20–50 ms locally"
        },
        {
          "label": "Privacy",
          "value": "100% on-device code & secrets"
        }
      ],
      "codeTitle": "Launch a warm local sandbox in ~32 ms",
      "code": "ID=$(sandboxctl create -w ~/code/my-app | awk '{print $1}')\nsandboxctl exec \"$ID\" -- npm test\nsandboxctl rm \"$ID\"",
      "sections": [
        {
          "heading": "Keep Proprietary Code & Build Caches Local",
          "body": "Cloud sandboxes require uploading workspace trees on every session and paying per-vCPU-minute bills. Kagex boots Ubuntu 24.04 microVMs directly on Apple Silicon or x86/arm64 KVM with instant local warm pools."
        },
        {
          "heading": "When to Choose Kagex vs Cloud E2B",
          "body": "Choose Kagex for interactive IDE agents (Antigravity, Cursor, Claude Code, Codex), enterprise compliance keeping code on-prem, or unlimited local eval loops; choose cloud APIs when orchestrating thousands of stateless remote workers beyond one workstation's RAM."
        }
      ],
      "faqs": [
        {
          "q": "Is Kagex open source and free for commercial teams?",
          "a": "Yes. Kagex is MIT-licensed with zero per-seat or usage fees."
        },
        {
          "q": "Can Kagex work on airplanes or offline networks?",
          "a": "Yes. Once base images and dependencies are cached in a golden snapshot or warm pool, sandboxes start and execute offline."
        },
        {
          "q": "Does Kagex provide programmatic SDKs like E2B?",
          "a": "Yes — native MCP tools, a public Go SDK (pkg/client), and an OpenAPI HTTP/SSE interface for Python, TypeScript, or curl."
        }
      ],
      "related": [
        "kagex-vs-docker-for-ai-agents",
        "kagex-vs-modal-daytona-devpod",
        "32ms-warm-pool-microvm-boot"
      ]
    },
    {
      "slug": "kagex-vs-docker-for-ai-agents",
      "title": "MicroVMs vs Docker Containers: Why Containers Fall Short for AI Agents",
      "shortTitle": "MicroVMs vs Docker",
      "category": "Comparisons",
      "badge": "Comparison",
      "readTime": "5 min",
      "calloutFocus": 4,
      "description": "Technical comparison of Kagex microVMs vs Docker containers for autonomous coding agents: kernel boundary vs shared host kernel, virtio-fs vs one-way sync, and nested dockerd.",
      "summary": "Docker excels at packaging trusted services, not isolating untrusted LLM-generated commands next to developer SSH keys and local ports.",
      "keywords": [
        "microVM vs Docker AI agents",
        "Firecracker vs Docker container security",
        "why not Docker for AI code execution",
        "shared kernel exploit AI sandbox",
        "Kagex Docker alternative"
      ],
      "highlights": [
        {
          "label": "Kernel",
          "value": "Dedicated Ubuntu 24.04 kernel vs shared host"
        },
        {
          "label": "File mount",
          "value": "1-way vsock sync vs bind mount risks"
        },
        {
          "label": "Egress control",
          "value": "Built-in allowlist + Ghost Vault vs host bridge"
        }
      ],
      "codeTitle": "Run tests cleanly without bind mounts",
      "code": "# Unlike 'docker run -v $PWD:/app', host files never expose symlinks or .env:\nsandboxctl exec \"$ID\" -- pytest -q\nsandboxctl diff \"$ID\"",
      "sections": [
        {
          "heading": "Hardware Hypervisor vs Shared Kernel Namespace",
          "body": "Linux containers share one host kernel; bind-mounting your repo requires constant caution around UID mapping, docker.sock leaks, and direct filesystem overwrites. Kagex enforces full VM memory & kernel isolation plus one-way sync."
        },
        {
          "heading": "Built-In Diff/Apply & Secret Placeholder Proxy",
          "body": "Docker gives you raw containers without built-in 3-way git diffing, host secret swapping, or IDE MCP rules. Kagex delivers the full agent loop out of the box."
        }
      ],
      "faqs": [
        {
          "q": "Can I still test my project's Dockerfile inside Kagex?",
          "a": "Yes — nested dockerd runs inside Kagex's microVM kernel safely separated from your laptop."
        },
        {
          "q": "Are warm Kagex microVMs slower than docker run?",
          "a": "From the warm pool, Kagex attaches ready Ubuntu microVMs in 20–50 ms — competitive with or faster than spawning fresh containers cleanly."
        },
        {
          "q": "Does Docker need to stay running for Kagex to work?",
          "a": "No. At runtime Kagex depends only on Virtualization.framework (macOS) or Firecracker KVM (Linux/WSL2)."
        }
      ],
      "related": [
        "nested-docker-inside-microvm",
        "kagex-vs-e2b-local-microvm",
        "zero-trust-ai-code-execution"
      ]
    },
    {
      "slug": "kagex-vs-modal-daytona-devpod",
      "title": "Kagex vs Cloud Dev Environments (Modal, Daytona, Codespaces)",
      "shortTitle": "Kagex vs Cloud Dev Sandboxes",
      "category": "Comparisons",
      "badge": "Comparison",
      "readTime": "4 min",
      "calloutFocus": 2,
      "description": "When to use Kagex sub-second local microVMs vs remote cloud sandboxes like Modal, Daytona, or GitHub Codespaces for daily AI agent workflows.",
      "summary": "Heavy remote dev containers suit team-wide cloud IDEs, whereas Kagex gives your local coding assistant instant ~32 ms throwaway execution right beside your editor.",
      "keywords": [
        "Kagex vs Daytona",
        "Kagex vs Modal Sandboxes",
        "local alternative GitHub Codespaces AI",
        "instant agent sandbox vs devcontainer",
        "zero latency local AI coding VM"
      ],
      "highlights": [
        {
          "label": "Provisioning",
          "value": "20–50 ms local warm pool"
        },
        {
          "label": "Editor loop",
          "value": "Instant local IDE MCP + 3-way apply"
        },
        {
          "label": "Vendor lock",
          "value": "None (OpenAPI + Go + MIT)"
        }
      ],
      "codeTitle": "Attach instant sandboxes per prompt or repo",
      "code": "sandboxctl templates list\nsandboxctl create -w ~/code/frontend-app",
      "sections": [
        {
          "heading": "Zero Network Round-Trip for Editor Iterations",
          "body": "Remote sandboxes pay WAN synchronization latency every time your agent edits local files or runs fast unit tests. Kagex syncs deltas over local memory/vsock in milliseconds."
        },
        {
          "heading": "Reversible Diffing Built for Git Workflows",
          "body": "Instead of syncing an entire IDE workspace into the cloud, keep editing natively in Cursor, Antigravity, or terminal while offloading untrusted execution to Kagex."
        }
      ],
      "faqs": [
        {
          "q": "Does Kagex replace heavy GPU training boxes like Modal?",
          "a": "No — use GPU clouds for large ML training jobs, and use Kagex for daily code editing, testing, Playwright/backend verification, and MCP tool execution on your workstation."
        },
        {
          "q": "How does template caching compare to devcontainers?",
          "a": "Running --setup creates reusable golden CoW snapshots per repo setup so subsequent sandboxes restore pre-installed node_modules or virtualenvs in ~0.5 s."
        },
        {
          "q": "Is telemetry vendor-locked?",
          "a": "No — metrics and traces use open Prometheus (/metrics) and OTLP standards."
        }
      ],
      "related": [
        "kagex-vs-e2b-local-microvm",
        "cow-golden-snapshots-pause-resume",
        "32ms-warm-pool-microvm-boot"
      ]
    },
    {
      "slug": "local-microvm-vs-cloud-sandbox-cost",
      "title": "The Economics of Local AI Agent Sandboxing: Saving 100% on Cloud VM Bills",
      "shortTitle": "$0 Local Sandbox Economics",
      "category": "Comparisons",
      "badge": "Zero Cost",
      "readTime": "4 min",
      "calloutFocus": 6,
      "description": "Calculate how parallel autonomous agents, SWE-bench loops, and CI reproducers burn cloud VM spend vs running unlimited microVMs locally at $0 on Kagex.",
      "summary": "Modern multi-agent swarms spawn dozens of branches and retry loops per task. Running them locally leverages your Apple Silicon or multi-core Linux RAM for $0/month.",
      "keywords": [
        "reduce AI sandbox cost",
        "free coding agent VM",
        "multi-agent concurrency local RAM",
        "budgets.max_mem_mb Kagex",
        "cost-effective LLM evaluation sandbox"
      ],
      "highlights": [
        {
          "label": "Hourly VM cost",
          "value": "$0.00 / hr"
        },
        {
          "label": "RAM allocation",
          "value": "1–2 GB / VM (50% host auto reserve)"
        },
        {
          "label": "CoW storage",
          "value": "Shared APFS / FICLONE blocks"
        }
      ],
      "codeTitle": "Tune concurrency quotas in config.yaml",
      "code": "# View effective daemon budgets and active pool pressure:\nsandboxd config\nsandboxctl top",
      "sections": [
        {
          "heading": "Memory-Backed Concurrency Without Storage Bloat",
          "body": "Thanks to APFS clonefile (macOS) and FICLONE/sparse copies (Linux/WSL2), running 4 to 8 concurrent microVMs shares immutable base rootfs blocks cleanly."
        },
        {
          "heading": "Priority Queueing & Automatic Pool Eviction",
          "body": "internal/scheduler maintains a deterministic vCPU/RAM ledger, evicting idle warm slots safely under memory pressure so your desktop stays responsive."
        }
      ],
      "faqs": [
        {
          "q": "Can Kagex starve my IDE or browser of RAM?",
          "a": "No. Scheduler reserves ~50% of host memory automatically and enforces strict quotas in budgets.max_mem_mb."
        },
        {
          "q": "How do I reclaim disk space from stopped sandboxes?",
          "a": "Run sandboxctl gc --dry-run to preview reclaimable snapshots/sandboxes, then sandboxctl gc to clean up."
        },
        {
          "q": "What if I run parallel agents in Antigravity or Go?",
          "a": "The fair scheduler queues bursts cleanly when host capacity is full instead of crashing."
        }
      ],
      "related": [
        "kagex-vs-e2b-local-microvm",
        "parallel-agent-forking-workflows",
        "32ms-warm-pool-microvm-boot"
      ]
    },
    {
      "slug": "32ms-warm-pool-microvm-boot",
      "title": "Inside Kagex's 20–50 ms Warm Pool Engine & Instant Agent Attachment",
      "shortTitle": "32 ms Warm Pool Boot",
      "category": "Speed & Workflows",
      "badge": "20–50 ms",
      "readTime": "4 min",
      "calloutFocus": 2,
      "description": "How internal/service/pool.go pre-warms Ubuntu 24.04 microVMs in standby memory so attaching workspaces and executing commands finishes in 20–50 milliseconds.",
      "summary": "Eliminate multi-second container pulls and cold VM boots by pairing background warm standby pools with fast delta workspace mirroring.",
      "keywords": [
        "32ms microVM boot",
        "warm pool Firecracker Go",
        "fast AI agent code execution latency",
        "pre-warmed Linux VM pool",
        "sub-50ms sandbox spawn"
      ],
      "highlights": [
        {
          "label": "Warm attach",
          "value": "20–50 ms"
        },
        {
          "label": "Cold kernel boot",
          "value": "1.2 s baseline"
        },
        {
          "label": "Exec RPC",
          "value": "< 5 ms over AF_VSOCK"
        }
      ],
      "codeTitle": "Trace phase-by-phase warm pool boot timing",
      "code": "ID=$(sandboxctl create -w ~/code/app | awk '{print $1}')\nsandboxctl trace \"$ID\"   # scheduler.reserve -> vm.restore -> workspace.sync",
      "sections": [
        {
          "heading": "Pre-Warming Beyond the Critical Path",
          "body": "Cold Linux boots (~1.2 s) happen in the background ahead of user prompts. When an agent invokes sandbox_exec, Kagex simply binds the workspace and policy to an already running standby slot."
        },
        {
          "heading": "Pressure-Aware Eviction",
          "body": "When host memory is tight for other applications, internal/scheduler shrinks idle standby instances automatically so standby pools never steal needed desktop RAM."
        }
      ],
      "faqs": [
        {
          "q": "What falls back cleanly if the warm pool is exhausted?",
          "a": "Kagex restores from the cached golden snapshot (~0.5 s) or cold boots cleanly (~1.2 s) with zero dropped requests."
        },
        {
          "q": "Do warm pool VMs share state between different repos?",
          "a": "Never. Every warm VM boots cleanly from the immutable base Ubuntu 24.04 image before a single repo file enters /workspace."
        },
        {
          "q": "How can I inspect exact millisecond timings on my machine?",
          "a": "Run sandboxctl trace <sbx_id> to inspect the waterfall per phase."
        }
      ],
      "related": [
        "cow-golden-snapshots-pause-resume",
        "parallel-agent-forking-workflows",
        "opentelemetry-prometheus-grafana-microvm-metrics"
      ]
    },
    {
      "slug": "parallel-agent-forking-workflows",
      "title": "Parallel MicroVM Forking: Race Multiple AI Code Fixes Side-by-Side",
      "shortTitle": "Parallel Sandbox Forking",
      "category": "Speed & Workflows",
      "badge": "~0.8 s Fork",
      "readTime": "4 min",
      "calloutFocus": 6,
      "description": "Clone a running sandbox state N times concurrently in ~0.8 s per fork using sandboxctl fork or pkg/client Fork() to evaluate competing AI hypotheses safely.",
      "summary": "Instead of sequentially undoing failed edits, branch an active sandbox into parallel clones, test rival patches simultaneously, and apply only the winner.",
      "keywords": [
        "fork running microVM",
        "parallel AI agent testing",
        "best-of-N coding agent sandbox",
        "sandboxctl fork Go SDK",
        "CoW VM clone concurrency"
      ],
      "highlights": [
        {
          "label": "Fork speed",
          "value": "~0.8 s per parallel clone"
        },
        {
          "label": "CLI command",
          "value": "sandboxctl fork <id> [count]"
        },
        {
          "label": "MCP tool",
          "value": "sandbox_snapshot (action=fork)"
        }
      ],
      "codeTitle": "Fork a sandbox and race competing fixes",
      "code": "sandboxctl checkpoint \"$ID\" --name pre-upgrade\nsandboxctl fork \"$ID\" 2   # Creates two independent CoW child sandboxes",
      "sections": [
        {
          "heading": "Best-of-N Agent Search & Evaluation",
          "body": "Harnesses like docs/examples/go-harness illustrate spinning up N forks after reproducing a failing test, letting distinct model prompts mutate each fork independently and diffs returning strictly from passing runs."
        },
        {
          "heading": "Isolated Storage & Independent Egress",
          "body": "Each forked sandbox preserves separate CoW layers and execution logs while sharing common immutable ancestor blocks."
        }
      ],
      "faqs": [
        {
          "q": "Does modifying files in Fork A affect Fork B or the parent VM?",
          "a": "No. CoW disk isolation guarantees every fork has an independent write layer."
        },
        {
          "q": "Can an Antigravity or Claude agent invoke forks via MCP?",
          "a": "Yes — sandbox_snapshot supports checkpoint, restore, fork, and list actions."
        },
        {
          "q": "How does host apply work after forking?",
          "a": "Run sandboxctl diff <winning_fork_id> and sandboxctl apply <winning_fork_id> cleanly back to the host repo."
        }
      ],
      "related": [
        "custom-go-agent-harness-sdk",
        "cow-golden-snapshots-pause-resume",
        "one-way-workspace-sync-3way-apply-undo"
      ]
    },
    {
      "slug": "cow-golden-snapshots-pause-resume",
      "title": "Golden Snapshots, Pause-to-Disk & Sub-Second Agent Restores",
      "shortTitle": "Snapshots & Pause/Resume",
      "category": "Speed & Workflows",
      "badge": "0.5 s Restore",
      "readTime": "4 min",
      "calloutFocus": 10,
      "description": "Cache dependency builds in golden snapshots (0.5–0.6 s create), pause running sessions cleanly on daemon shutdown, and recover gracefully across restarts.",
      "summary": "Stop paying cold apt/npm/pip install time every session: snapshot your configured environment once and restore it repeatedly in half a second.",
      "keywords": [
        "microVM golden snapshot",
        "pause resume Firecracker VM disk",
        "save node_modules snapshot AI VM",
        "sandboxctl snapshot restore",
        "crash recovery microVM rescue"
      ],
      "highlights": [
        {
          "label": "Golden restore",
          "value": "0.5–0.6 s incl. sync"
        },
        {
          "label": "Pause / resume",
          "value": "0.5–0.7 s to/from disk"
        },
        {
          "label": "Ctrl-C behavior",
          "value": "Safely pauses active sandboxes"
        }
      ],
      "codeTitle": "Pause, checkpoint, and restore sandbox state",
      "code": "sandboxctl pause \"$ID\"\nsandboxctl resume \"$ID\"\nsandboxctl snapshot \"$ID\" --name clean-deps\nsandboxctl restore \"$ID\" clean-deps",
      "sections": [
        {
          "heading": "Pause on Shutdown & Crash Recovery",
          "body": "Stopping sandboxd cleanly with Ctrl-C pauses running microVMs to disk. If the host reboots unexpectedly, internal/service/recover.go restores consistent database and artifact states safely."
        },
        {
          "heading": "Automatic Template Layering",
          "body": "Repo setup commands invoked via --setup build cached project layers automatically so teams reuse warm dependencies across branches."
        }
      ],
      "faqs": [
        {
          "q": "What happens to running microVMs if I press Ctrl-C on sandboxd serve?",
          "a": "Active sandboxes gracefully pause to disk so you can resume without losing in-progress VM work."
        },
        {
          "q": "How fast is restoring a golden snapshot?",
          "a": "0.5–0.6 seconds including workspace delta sync on Apple Silicon NVMe."
        },
        {
          "q": "How do I list available templates and snapshots?",
          "a": "Use sandboxctl templates and sandboxctl snapshot list <id>."
        }
      ],
      "related": [
        "32ms-warm-pool-microvm-boot",
        "parallel-agent-forking-workflows",
        "sandboxctl-cli-complete-reference"
      ]
    },
    {
      "slug": "local-port-forwarding-sandbox-previews",
      "title": "Safely Preview AI-Built Web Apps via Loopback Port Forwarding",
      "shortTitle": "Local Port Forwarding",
      "category": "Speed & Workflows",
      "badge": "Port Forward",
      "readTime": "3 min",
      "calloutFocus": 9,
      "description": "Expose Vite, Next.js, Flask, or API dev servers running inside an isolated Kagex microVM strictly on host 127.0.0.1 using sandboxctl port or MCP sandbox_port.",
      "summary": "Let Playwright or your browser verify agent-built UI changes on 127.0.0.1 while keeping the server containerized inside its isolated Ubuntu microVM.",
      "keywords": [
        "microVM loopback port forwarding",
        "sandboxctl port",
        "preview AI dev server localhost",
        "sandbox_port MCP tool",
        "isolated Next.js preview VM"
      ],
      "highlights": [
        {
          "label": "Bind interface",
          "value": "127.0.0.1 only (never 0.0.0.0)"
        },
        {
          "label": "CLI syntax",
          "value": "sandboxctl port <id> <guest_port>"
        },
        {
          "label": "Background cmd",
          "value": "sandboxctl exec <id> -d -- <cmd>"
        }
      ],
      "codeTitle": "Run and preview a sandboxed web app",
      "code": "sandboxctl exec \"$ID\" -d -- \"npm run dev -- --port 3000\"\nsandboxctl port \"$ID\" 3000\n# -> Prints http://127.0.0.1:NNNNN",
      "sections": [
        {
          "heading": "Loopback-Only Binding Guarantee",
          "body": "Exposed ports bind strictly onto host 127.0.0.1 ephemeral ports rather than LAN interfaces (0.0.0.0), preventing untrusted dev servers inside VMs from accepting external Wi-Fi traffic."
        },
        {
          "heading": "Agent Self-Verification Loops",
          "body": "AI agents can start a backend server via sandbox_exec, map it with sandbox_port, run integration curls cleanly, and tear everything down on sandbox_destroy."
        }
      ],
      "faqs": [
        {
          "q": "Are forwarded ports reachable by other devices on my Wi-Fi?",
          "a": "No. Kagex binds strictly to 127.0.0.1."
        },
        {
          "q": "Can agents run background servers cleanly without hanging exec?",
          "a": "Yes. Pass -d (detached) in CLI or detached mode in exec and follow logs anytime via sandboxctl logs."
        },
        {
          "q": "Does port forwarding work on Windows WSL2 as well?",
          "a": "Yes — forwarded ports appear seamlessly on Windows 127.0.0.1."
        }
      ],
      "related": [
        "mcp-tools-reference-guide",
        "nested-docker-inside-microvm",
        "allowlist-egress-firewall-dns-rebinding"
      ]
    },
    {
      "slug": "multi-language-ubuntu-24-04-sandbox-templates",
      "title": "Ubuntu 24.04 Rootfs, Toolchains & Auto-Template Resolution",
      "shortTitle": "Ubuntu 24.04 Base Templates",
      "category": "Speed & Workflows",
      "badge": "Templates",
      "readTime": "4 min",
      "calloutFocus": 5,
      "description": "Inside Kagex's Ubuntu 24.04 ext4 rootfs builder (infra/image/Dockerfile & build-rootfs.sh), automatic language detection (template=auto), and sha256-pinned kernels.",
      "summary": "Every sandbox launches a clean, deterministic Ubuntu 24.04 image built reproducibly with pinned Kata Linux kernels verified via sha256.",
      "keywords": [
        "Ubuntu 24.04 Firecracker rootfs",
        "sha256 pinned Linux kernel microVM",
        "build-rootfs.sh Kagex",
        "template=auto AI sandbox",
        "reproducible ext4 microVM image"
      ],
      "highlights": [
        {
          "label": "Guest OS",
          "value": "Ubuntu 24.04 LTS ext4 rootfs"
        },
        {
          "label": "Kernel source",
          "value": "fetch-kernel.sh (sha256 verified)"
        },
        {
          "label": "Artifacts dir",
          "value": "_out/images/ (git-ignored)"
        }
      ],
      "codeTitle": "Build and register base images cleanly",
      "code": "make kernel   # Fetches vmlinux-<arch> + verifies checksum\nmake rootfs   # Builds base-rootfs-<arch>.ext4\n./_out/bin/sandboxd install --artifacts _out\n./_out/bin/sandboxctl templates",
      "sections": [
        {
          "heading": "Determinism Across macOS, Linux, and Windows",
          "body": "All three host operating systems share the exact Ubuntu 24.04 guest environment and PID 1 agent binary, ensuring tests behave identically whether launched on an M4 MacBook or Windows WSL2."
        },
        {
          "heading": "Auto-Detection & Custom Toolchain Snapshots",
          "body": "Setting template='auto' automatically selects or warms matching snapshots for Node, Go, Python, or system toolchains cleanly."
        }
      ],
      "faqs": [
        {
          "q": "Where do image files live after make images?",
          "a": "Everything lands in _out/images/ (ignored cleanly in .gitignore) and installs into daemon storage when running sandboxd install --artifacts _out."
        },
        {
          "q": "Can Linux and WSL2 build rootfs without Docker?",
          "a": "Yes. infra/scripts/build-rootfs.sh automatically uses native debootstrap if Docker is absent."
        },
        {
          "q": "How are kernels verified before booting?",
          "a": "fetch-kernel.sh checks sha256 checksums before placing vmlinux-<arch> into _out/images/."
        }
      ],
      "related": [
        "macos-apple-silicon-virtualization-framework",
        "linux-firecracker-kvm-microvms",
        "cow-golden-snapshots-pause-resume"
      ]
    },
    {
      "slug": "opentelemetry-prometheus-grafana-microvm-metrics",
      "title": "Observe AI MicroVMs with OpenTelemetry, Prometheus & Grafana",
      "shortTitle": "OTel, Prometheus & Grafana",
      "category": "Observability & API",
      "badge": "Telemetry",
      "readTime": "4 min",
      "calloutFocus": 2,
      "description": "Inspect per-phase microVM latency waterfalls via sandboxctl trace, export OTLP spans to Jaeger/Tempo, and monitor fleet metrics with Kagex's ready-to-run Grafana dashboard.",
      "summary": "Treat local AI sandbox fleets like production infrastructure: inspect every scheduler reservation, vsock exec, firewall deny, and CoW sync millisecond by millisecond.",
      "keywords": [
        "OpenTelemetry microVM tracing",
        "Prometheus sandboxd metrics",
        "Grafana dashboard AI sandboxes",
        "sandboxctl trace waterfall",
        "monitor autonomous AI agent latency"
      ],
      "highlights": [
        {
          "label": "CLI trace",
          "value": "sandboxctl trace <sbx_id|exe_id>"
        },
        {
          "label": "OTLP flag",
          "value": "--otlp-endpoint http://127.0.0.1:4318"
        },
        {
          "label": "Grafana stack",
          "value": "infra/observability/docker-compose.yml"
        }
      ],
      "codeTitle": "Enable OTLP tracing and launch Prometheus + Grafana",
      "code": "sandboxd serve --otlp-endpoint http://127.0.0.1:4318\ndocker compose -f infra/observability/docker-compose.yml up -d\nsandboxctl trace \"$ID\"\nsandboxctl events",
      "sections": [
        {
          "heading": "Per-Phase Latency Waterfalls",
          "body": "sandboxctl trace prints structured spans covering scheduler.reserve, vm.restore, guest.configure, workspace.sync, and exec duration so bottlenecks never hide in black-box scripts."
        },
        {
          "heading": "Pre-Built Prometheus & Grafana Stack",
          "body": "Scrape /metrics natively from sandboxd or spin up infra/observability/docker-compose.yml with grafana-dashboard.json preloaded."
        }
      ],
      "faqs": [
        {
          "q": "Does observability require Docker running?",
          "a": "No! sandboxctl trace and sandboxctl events work natively in any terminal without Docker. Docker Compose is optional for Grafana/Prometheus charts."
        },
        {
          "q": "Can OTLP export to Jaeger or Grafana Tempo?",
          "a": "Yes — any standard OTLP/HTTP collector listening on port 4318 works with --otlp-endpoint."
        },
        {
          "q": "Where are execution logs persisted?",
          "a": "Kagex uses SQLite in WAL mode (internal/store) plus structured log files queryable via sandboxctl logs and sandboxctl grep."
        }
      ],
      "related": [
        "sandboxctl-cli-complete-reference",
        "sandboxd-http-rest-sse-openapi-guide",
        "32ms-warm-pool-microvm-boot"
      ]
    },
    {
      "slug": "sandboxctl-cli-complete-reference",
      "title": "sandboxctl & sandboxd Complete CLI Reference for Developers",
      "shortTitle": "CLI Command Reference",
      "category": "Observability & API",
      "badge": "CLI Docs",
      "readTime": "5 min",
      "calloutFocus": 1,
      "description": "Master every sandboxctl and sandboxd command: create, exec, shell, cp, diff, apply, pull, undo, snapshot, fork, net, secret, events, trace, gc, doctor, and mcp install.",
      "summary": "Fast lookup reference covering every host daemon and sandbox lifecycle command across macOS, Linux, and Windows.",
      "keywords": [
        "sandboxctl cheat sheet",
        "sandboxd CLI reference",
        "sandboxctl doctor events trace",
        "sandboxctl create exec diff apply",
        "Kagex terminal CLI commands"
      ],
      "highlights": [
        {
          "label": "Control CLI",
          "value": "sandboxctl (28+ subcommands)"
        },
        {
          "label": "Host daemon",
          "value": "sandboxd (serve, install, doctor, token, setup-wsl)"
        },
        {
          "label": "Dry-run GC",
          "value": "sandboxctl gc --dry-run"
        }
      ],
      "codeTitle": "Daily developer commands cheat sheet",
      "code": "sandboxd doctor && sandboxctl doctor\nsandboxctl ps                                   # List running/paused VMs\nsandboxctl shell \"$ID\"                          # Interactive guest bash session\nsandboxctl exec \"$ID\" -- go test ./...          # One-off command execution\nsandboxctl logs \"$ID\" && sandboxctl grep \"$ID\" FAIL\nsandboxctl artifacts && sandboxctl undo art_...",
      "sections": [
        {
          "heading": "Safe Lifecycle & Backup Recovery Commands",
          "body": "From creating sandboxes to rolling back applied patches, every destructive action requires confirmation or creates logged recovery trails. sandboxd uninstall preserves data unless --purge is explicitly confirmed."
        },
        {
          "heading": "Cross-OS Parity",
          "body": "All subcommands work consistently across macOS Terminal, Linux bash, and Windows PowerShell (sandboxctl.exe / sandboxd.exe)."
        }
      ],
      "faqs": [
        {
          "q": "How do I open an interactive terminal inside a microVM?",
          "a": "Run sandboxctl shell <sbx_id> — supported across macOS, Linux, and Windows."
        },
        {
          "q": "How do I print the daemon TCP authentication token?",
          "a": "Run sandboxd token."
        },
        {
          "q": "Does sandboxd uninstall delete my snapshots?",
          "a": "No, it removes only the startup service entry unless you pass --purge."
        }
      ],
      "related": [
        "sandboxd-http-rest-sse-openapi-guide",
        "opentelemetry-prometheus-grafana-microvm-metrics",
        "antigravity-mcp-sandbox"
      ]
    },
    {
      "slug": "sandboxd-http-rest-sse-openapi-guide",
      "title": "sandboxd HTTP/JSON + SSE REST API & OpenAPI 3 Contract Guide",
      "shortTitle": "HTTP REST & OpenAPI API",
      "category": "Observability & API",
      "badge": "OpenAPI 3",
      "readTime": "4 min",
      "calloutFocus": 3,
      "description": "Automate Kagex from TypeScript, Rust, Ruby, or curl using the documented REST & Server-Sent Events contract in docs/openapi.yaml (GET /v1/openapi.yaml).",
      "summary": "Zero proprietary binary framing between host clients and sandboxd: clean HTTP/1.1 + JSON + SSE over Unix sockets or authenticated loopback TCP.",
      "keywords": [
        "sandboxd REST API",
        "Kagex openapi.yaml",
        "/v1/sandboxes exec stream SSE",
        "Unix socket curl HTTP sandbox",
        "AI sandbox HTTP API"
      ],
      "highlights": [
        {
          "label": "Contract",
          "value": "docs/openapi.yaml (GET /v1/openapi.yaml)"
        },
        {
          "label": "Unix auth",
          "value": "OS peer credentials (SO_PEERCRED)"
        },
        {
          "label": "TCP auth",
          "value": "Authorization: Bearer $(sandboxd token)"
        }
      ],
      "codeTitle": "Control sandboxes directly via curl",
      "code": "SOCK=\"$HOME/Library/Application Support/sandboxd/sandboxd.sock\"\ncurl -s --unix-socket \"$SOCK\" http://localhost/v1/openapi.yaml | head -n 20\ncurl -s --unix-socket \"$SOCK\" -X POST http://localhost/v1/sandboxes \\\n  -d '{\"workspace\":{\"host_path\":\"'\"$PWD\"'\"},\"template\":\"auto\"}'",
      "sections": [
        {
          "heading": "Unix Socket First, Optional Bearer TCP",
          "body": "On macOS and Linux, sandboxd serves directly over an OS-authenticated Unix socket. On Windows (or containers with tcp_listen configured), clients present a Bearer token from sandboxd token."
        },
        {
          "heading": "Streaming Execution Logs Over SSE",
          "body": "Async executions return an exec_id immediately and stream real-time stdout/stderr/exit JSON payloads on GET /v1/executions/{exec_id}/stream."
        }
      ],
      "faqs": [
        {
          "q": "Where can I download the full OpenAPI schema from a running daemon?",
          "a": "Fetch GET /v1/openapi.yaml directly from sandboxd or read docs/openapi.yaml in the repository."
        },
        {
          "q": "Are there rate limits or paywalls on local API requests?",
          "a": "Zero paywalls — only local resource budgets configured by you in config.yaml."
        },
        {
          "q": "Which database stores sandbox metadata?",
          "a": "internal/store uses SQLite in WAL mode (1 writer, 8 readers) with embedded migrations and sqlc queries."
        }
      ],
      "related": [
        "python-sse-agent-sandbox",
        "custom-go-agent-harness-sdk",
        "mcp-tools-reference-guide"
      ]
    },
    {
      "slug": "3d-mk4-hypervisor-cutaway-architecture",
      "title": "Inside the Kagex MK-IV 3D Hypervisor Architecture & Interactive Simulator",
      "shortTitle": "MK-IV 3D Hypervisor Architecture",
      "category": "Observability & API",
      "badge": "3D Cutaway",
      "readTime": "4 min",
      "calloutFocus": 7,
      "description": "Explore Kagex's 10 hardware & control-plane subsystems visually in 3D (/cutaway): Agent MCP Mux, sandboxd Rotor, virtio-vsock Coil, nested dockerd, CoW Blade Tray, Ghost Key Enclave, Firewall Shutter, and Diff/Undo Stack.",
      "summary": "Inspect every packet, CoW overlay blade, firewall deflection, and ghost secret swap live inside our custom Three.js Inkworks drafting blueprint.",
      "keywords": [
        "Kagex 3D hypervisor cutaway",
        "Inkworks 3D architecture diagram",
        "interactive microVM simulator",
        "Three.js technical cutaway microVM",
        "kagex.vercel.app cutaway"
      ],
      "highlights": [
        {
          "label": "Route",
          "value": "/cutaway (Full drafting sheet + Figure mode)"
        },
        {
          "label": "Callouts",
          "value": "#1–#10 clickable 3D inspection probes"
        },
        {
          "label": "Interactive CLI",
          "value": "Built-in stateful sandboxctl REPL"
        }
      ],
      "codeTitle": "Try these interactive commands in the live 3D CLI bar",
      "code": "sandboxctl ls\nsandboxctl curl pypi.org             # Watch firewall shutter deflect (403)\nsandboxctl allow add pypi.org        # Whitelist domain & probe (200)\nsandboxctl exec -- npm test          # Generate CoW workspace diff\nsandboxctl apply                     # Commit cleanly or rollback with undo",
      "sections": [
        {
          "heading": "4-Phase Sandbox Lifecycle Cycle (0° – 360°)",
          "body": "Step frame-by-frame across 01 Connect (MCP Ingress), 02 Isolate (CoW Warm Pool), 03 Guard (Execute & Egress Proxy), and 04 Sync (Diff, Apply & Undo) with live X-Y pressure plots."
        },
        {
          "heading": "Unified Simulation State Across Landing Page & Blueprint",
          "body": "Both the Runtime Matrix on / and the full-screen /cutaway sheet share kagex-sim telemetry so policy edits, secret probes, and workspace diffs synchronize with 3D motion."
        }
      ],
      "faqs": [
        {
          "q": "Can I click individual 3D parts to inspect what they map to in Go code?",
          "a": "Yes — click any #1 through #10 callout badge on the 3D scene to auto-focus the camera and read exact subsystem guarantees."
        },
        {
          "q": "Does the Policy & Diff drawer work on mobile?",
          "a": "Yes. Both the live CLI bar and Policy/Diff drawers adapt cleanly on 390px viewports and desktop widescreens."
        },
        {
          "q": "Where does the 3D engine live in the repository?",
          "a": "Check web/src/components/inkworks/ and web/src/lib/kagex-sim.ts."
        }
      ],
      "related": [
        "antigravity-mcp-sandbox",
        "ghost-secrets-vault-mitm-proxy",
        "one-way-workspace-sync-3way-apply-undo"
      ]
    }
  ]
}