# What Does Grok Build CLI Really Send to xAI?
**TL;DR:** Grok Build CLI is not just a code-completion tool — it transmits your workspace file tree, file contents, and environment metadata to xAI endpoints on every session. We ran it through our coderag MCP proxy at FlipFactory and confirmed outbound payloads reaching 80k–120k tokens per session on a mid-sized repo. If you're shipping client code, read this before you `grok build` anything.
---
## At a glance
- **Grok Build CLI v0.4.1** (the version analyzed by cereblab's gist, published 2026-07-08) transmits workspace manifests on session init, not on explicit user prompt.
- **grok-3-mini** is the default model powering Build CLI, priced at ~$0.30/1M input tokens and ~$0.50/1M output tokens as of xAI's July 2026 pricing page.
- **80,000–120,000 tokens** is the observed payload size for a 50-file TypeScript monorepo in a single Build CLI session (cereblab, 2026-07-08 gist analysis).
- **14 distinct outbound HTTPS requests** were captured by our coderag MCP proxy during a 20-minute Build CLI session on 2026-07-09.
- **GDPR Article 28** mandates a signed Data Processing Agreement for any processor handling EU personal data — xAI has not published a standard DPA as of 2026-07-13.
- **xAI endpoint `api.x.ai/v1/build/context`** is the primary telemetry target identified in cereblab's packet capture, separate from the standard completions endpoint.
- **Three data categories** leave your machine: workspace manifest (always), file contents (on first open + on change), and shell environment variables prefixed with the session ID.
---
## Q: What exactly leaves your machine during a Grok Build CLI session?
The cereblab gist (2026-07-08) performed a controlled packet capture and identified three distinct payload types. First, a **workspace manifest** — a JSON object containing your full directory tree, file count, total size, and git HEAD SHA — transmitted immediately on `grok build` invocation, before any user prompt. Second, **file content chunks** sent as the model needs context, batched in 8k-token blocks. Third, a **session metadata envelope** that includes environment variables visible at shell startup, filtered by a loose regex that still passes through items like `DATABASE_URL` if they don't contain obvious secret keywords.
We reproduced this at FlipFactory in July 2026 using our **coderag MCP server** configured as an intercepting proxy (install path: `~/.mcp/servers/coderag/`). Pointing Build CLI's HTTP client at our local coderag endpoint, we captured 14 requests in 20 minutes on a 38-file Hono + Cloudflare Workers repo. The workspace manifest alone was 4,200 tokens. Nothing in the CLI's `--help` output or official xAI Build docs (as of 2026-07-13) discloses this upfront behavior.
---
## Q: How does Build CLI token usage compare to Claude Code or Cursor?
This is where the numbers get genuinely surprising. Claude Code (using claude-sonnet-4 as of mid-2026) uses a **demand-driven context strategy**: it reads file contents only when explicitly referenced or when the model requests them via tool calls. Cursor's Composer similarly lazy-loads context. Build CLI, by contrast, pre-loads the workspace manifest eagerly and streams file contents speculatively based on a dependency graph it constructs client-side.
In our production comparison on 2026-07-09, we ran identical tasks — "add input validation to the POST /leads endpoint" — across all three tools on the same FlipFactory **leadgen MCP** integration codebase (31 files, ~4,800 lines of TypeScript). Claude Code consumed **~18,000 tokens** total. Cursor Composer used **~22,000 tokens**. Grok Build CLI used **~94,000 tokens**, of which roughly 67,000 were in the initial workspace snapshot and speculative file loads that were never referenced in the model's final response. At grok-3-mini pricing that's ~$0.028 per task versus Claude Sonnet-4's ~$0.19 — so Build CLI is cheaper per token but wastes more tokens per useful output.
---
## Q: What are the real compliance and security risks for developer teams?
The risk surface has three layers. **Legal:** If you're under an NDA or working on a SOC 2-scoped codebase, any unauthorized transmission of source code to a third-party AI provider is a contract breach and potentially a reportable incident. xAI's Terms of Service (July 2026 version, Section 4.2) state that "inputs may be used to improve xAI models" unless you opt out via enterprise agreement — an opt-out that isn't available on standard API keys.
**Operational:** Shell environment variable leakage is the immediate danger. Our coderag proxy log from 2026-07-09 shows that `DATABASE_URL`, `STRIPE_SECRET_KEY_TEST`, and `CLOUDFLARE_API_TOKEN` all appeared in Build CLI's session metadata envelope because they didn't match xAI's exclusion regex (`/password|secret|key|token/i` — note it missed `DATABASE_URL` entirely).
**Audit trail:** Unlike our **flipaudit MCP server**, which writes every outbound AI request to a signed append-only log, Build CLI provides zero local audit trail. You cannot reconstruct what was sent after the fact without external interception.
---
## Deep dive: The telemetry architecture xAI didn't document
The cereblab gist (2026-07-08, 293 upvotes on Hacker News, 133 comments as of 2026-07-13) is the most thorough independent analysis of Grok Build CLI's wire protocol published to date. The author used **mitmproxy 10.3** to intercept TLS traffic and identified two non-obvious endpoints: `api.x.ai/v1/build/context` for workspace telemetry and `api.x.ai/v1/build/stream` for the actual completions stream. The context endpoint is called synchronously before the stream endpoint, meaning the model always has your workspace state before you've typed a single character.
What makes this architecturally significant is the design philosophy it reveals. xAI is building Build CLI as a **stateful workspace agent**, not a stateless completion API wrapper. The server maintains a session object server-side, keyed to your API key + workspace hash. Subsequent requests in the same session send diffs, not full content — which explains why token usage drops sharply after the first invocation. This is actually a reasonable engineering choice for responsiveness, but it means xAI is storing a representation of your codebase on their infrastructure for the session duration (and potentially beyond, per Section 4.2 of their ToS).
For context on why this matters at scale: **Anthropic's Claude Code architecture documentation** (published May 2026 in their developer blog) explicitly describes a "read-on-demand" model where the client controls all file reads and the model requests specific files via tool calls. The server never receives files the developer didn't explicitly authorize. This is a meaningfully different trust model.
**GitHub's Copilot telemetry policy** (GitHub Docs, "About GitHub Copilot telemetry," last updated June 2026) similarly limits code transmission to "code snippets in the immediate context of your cursor" and provides an enterprise toggle to disable all telemetry. xAI offers neither equivalent granularity nor an enterprise toggle at the Build CLI tier.
At FlipFactory, we run 12+ MCP servers in production, and the lesson we've internalized across our **competitive-intel**, **scraper**, and **seo** MCP servers is that any tool with outbound HTTP access needs to be treated as a potential exfiltration path until proven otherwise. We now route all AI tool traffic through a coderag proxy instance that logs, rate-limits, and alerts on anomalous payload sizes. When Build CLI's first session hit our alert threshold of 50k tokens in under 60 seconds, it flagged immediately — which is how we caught the environment variable leak.
The fix isn't to avoid AI coding tools. It's to instrument them. Running Build CLI through a local proxy with a `.grokignore` file covering `*.env`, `*.pem`, `config/secrets/**` reduces the risk surface substantially. But as of July 2026, the defaults are unsafe for professional development environments, and xAI's documentation gives you no reason to suspect otherwise.
---
## Key takeaways
- Grok Build CLI transmits workspace manifests to `api.x.ai/v1/build/context` before any user prompt is entered.
- A 50-file repo session generates 80k–120k tokens of outbound data, per cereblab's July 2026 packet analysis.
- `DATABASE_URL` and `STRIPE_SECRET_KEY_TEST` bypassed xAI's secret-exclusion regex in FlipFactory's coderag proxy logs.
- Claude Code's demand-driven context uses ~5x fewer tokens per task than Build CLI on equivalent codebases.
- xAI has no published standard DPA as of 2026-07-13, making Build CLI non-compliant for GDPR-scoped client work.
---
## FAQ
**Q: Does `.grokignore` fully prevent file content from being sent to xAI?**
Partially. Files matched by `.grokignore` are excluded from content streaming, and we confirmed this in our coderag proxy logs — ignored files generated no content chunks. However, the workspace manifest (directory names, file count, total byte size) is transmitted regardless. If your directory names reveal sensitive project names or client identifiers, that information still leaves your machine. Use non-descriptive directory structures for sensitive work or keep Build CLI in a sandboxed project directory.
**Q: Can I use Grok Build CLI safely on a client project with an NDA?**
Not without explicit consent and a reviewed DPA. The CLI sends file paths, file contents, and environment metadata to xAI servers. Until xAI publishes a standard DPA and you execute it with your client, assume every file you open in a Build CLI session is covered by your NDA and off-limits for this tool. Consider Claude Code with enterprise data retention controls as an alternative for NDA-covered work.
**Q: Is Grok Build CLI's token cost actually competitive despite the higher consumption?**
At grok-3-mini pricing (~$0.30/1M input), even a 100k-token session costs ~$0.03 — genuinely cheap. The cost risk isn't per-session, it's at scale: 50 developers running 10 sessions/day at 100k tokens each is 50M tokens/day, or ~$15/day in input costs. That's manageable, but the compliance and secret-leakage risks are the real reason to pause, not the token price.
---
**Further reading:** [FlipFactory.it.com](https://flipfactory.it.com) — production MCP server templates, n8n workflow blueprints, and AI tool audit guides for development teams.
---
## About the author
**Sergii Muliarchuk** — founder of FlipFactory.it.com. Building production AI systems for fintech, e-commerce, and SaaS clients. We run 12+ MCP servers, n8n workflows, and FrontDeskPilot voice agents in production.
*We instrument every AI tool we adopt through our coderag and flipaudit MCP servers — which is exactly how we caught what Grok Build CLI was sending before it became a client incident.* What Does Grok Build CLI Really Send to xAI?
We reverse-engineered Grok Build CLI's telemetry in production. Here's exactly what leaves your machine, what tokens cost, and what to audit before shipping.
Frequently Asked Questions
Can I use Grok Build CLI safely on a client project with an NDA?
Not without explicit consent and a reviewed DPA. The CLI sends file paths, file contents, and environment metadata to xAI servers. Until xAI publishes a standard DPA and you execute it with your client, assume every file you open in a Build CLI session is covered by your NDA and off-limits for this tool.
Is there a way to limit what Grok Build CLI sends?
Yes, partially. You can add a .grokignore file (mirrors .gitignore syntax) to exclude sensitive paths. However, the initial workspace manifest — directory structure and file count — is still transmitted regardless. We confirmed this in our coderag MCP proxy logs on 2026-07-09.