At $0.20 per million input tokens, $1.50 per million output, and roughly 190 tokens per second, xAI's grok-code-fast-1 sits in a different price-performance bracket than the frontier models most of us learned to prompt against. That gap isn't a footnote. When a model is that cheap and that fast, the habits you built around expensive, slow ones start working against you. xAI's own prompt-engineering guide reads less like a list of tricks and more like an argument that the economics should change how you write instructions. I think that argument is right, and it's worth spelling out.
Stop polishing the prompt; polish the loop
The expensive-model reflex is to front-load. You spend twenty minutes on a single prompt because each round-trip costs real money and real seconds, so you try to nail it in one shot. With a model priced at a tenth of the competition and running several times faster, that trade inverts. The cheapest way to find out what a prompt produces is to run it.
Instead of spending twenty minutes crafting the "perfect" prompt, fire off a quick attempt and refine from the result.
This isn't laziness dressed up as method. A first attempt gives you a real artifact — a diff, a failing test, a wrong assumption made visible — that no amount of armchair prompt-writing surfaces. Two fast iterations that each correct a concrete mistake beat one slow prompt built on guesses about what the model will misunderstand. Budget your attention for reading outputs and steering, not for divining the ideal opening move.
Give it the necessary context, not the whole repository
The instinct that a bigger context window means you should paste more is the most expensive mistake here. grok-code-fast-1 carries a 256K-token window, which is enough to swallow a mid-sized service whole — and doing that reliably makes the output worse. The guide is blunt about it: dumping an entire codebase invites "unnecessary tangents and decreased performance."
Necessary context is specific. Point at the files that matter, the function that's broken, the interface the change has to satisfy. If the task touches three files, name those three files. The model can't tell which of the forty modules you pasted is load-bearing, so it treats a random helper as though it were a requirement. You know which parts matter; spend a sentence saying so instead of a thousand tokens hoping it infers it.
Long, unstructured context flattens priority — the model reads a stray paragraph with the same weight as a hard constraint. Both Markdown headings and XML tags fix this by labeling what each block is. Tags such as <requirements>, <current_code>, and <examples> act like folder labels: they tell the model what to do with the text underneath, and they let you refer back to a section on the next iteration without restating it.
## Goal
Add idempotency keys to POST /orders.
<current_code>
// paste only OrdersController.CreateAsync + the request DTO
</current_code>
<requirements>
- Reject a replayed key within 24h with the original response
- Store keys in the existing Redis connection, no new dependency
</requirements>
## Deliverable
A minimal patch plus one integration test. Explain any assumption in two lines.
Goal, context, constraints, deliverable — the sections do the disambiguation that a wall of prose can't.
grok-code-fast-1 was trained for native tool calling, and the guide is explicit that you should use it rather than inventing an XML-in-text protocol where the model prints something that looks like a function call for you to parse. Define the tool as a real schema and let the model emit a structured call:
{
"name": "run_tests",
"description": "Run the test suite and return failures",
"parameters": {
"type": "object",
"properties": {
"path": { "type": "string", "description": "Test file or directory" }
},
"required": ["path"]
}
}
The hand-rolled alternative — "when you want to run tests, output <tool>run_tests: path</tool> and I'll reply with the result" — burns output tokens on formatting the model already knows, and it's brittle the moment the model's phrasing drifts. Native calls are what it was optimized to produce; asking for the workaround fights the training.
Keep the prefix stable so the cache stays warm
Here's the detail that ties the speed back to the prompting. A large share of grok-code-fast-1's throughput comes from prompt cache hits, and cached input is billed at $0.02 per million tokens — a tenth of the already-low uncached rate. In an agentic loop, most of the prompt prefix is identical from one tool call to the next, so the model retrieves it from cache instead of reprocessing it.
That only holds if you don't disturb the front of the prompt. Editing earlier turns, reordering the system message, or splicing new instructions into the middle of the history invalidates the cache from the edit point forward — slower responses and a higher bill, for no visible reason. Treat the prompt prefix as append-only: keep the system message and early context fixed, and add new information at the end. Stable prefix, warm cache, fast loop.
Point it at agentic work
The model is built for multi-step tasks that plan, call tools, and navigate a problem — not one-line question-and-answer. Prompts that match that shape get the most out of it: ask for a short plan before edits, constrain which files it may touch, and request a structured result at the end. "Plan first, then execute, and only modify the files I listed" is a better frame for this model than a single imperative sentence, because it turns the task into the sequence the model was trained to run.
The takeaway
Rewire the loop, not just the wording. Curate the few files that matter instead of pasting the repo; label sections with headings and tags so priority survives; define tools as real schemas and let the model call them; keep the prompt prefix append-only to stay in cache; and reach for a second fast iteration rather than a perfect first prompt. A cheap, fast model doesn't reward the careful single shot — it rewards the tight loop, and the prompting that keeps that loop cheap and warm.
Sources: xAI — Grok Code Prompt Engineering guide, PromptLayer — xAI's Prompt Engineering Guide for grok-code-fast-1, xAI — Grok Code Fast 1 announcement