Deploying a Local Coding Model and Letting It Write the Series Examples
Can a properly configured local model write the example code for this series, and what does it get wrong when it tries?
First, a confession. This series was meant to wrap up on 25 October with a lovely measured evaluation. It didn’t. The routing article described a set of reusable tasks, quite confidently, that never made it into the companion repository. You can’t evaluate a model against tasks that only exist in a blog post, so the evaluation was postponed and the series has been sitting in the corner since, looking a bit sheepish. Rather like its author.
This post is me catching the series up with itself. I deployed a model that actually matches the original design, turned those templates into real tasks, and then let the model write the examples. Spoiler: it’s quite good at Terraform. It’s less good at knowing when it’s finished.
The usual caveat, since it matters more than usual here: I wrote this with AI help, and the runs were carried out by Claude Code on my machine rather than by me typing commands. The ideas, the decisions and the wincing are mine. Everything lives in the companion repository at revision be891e1. It’s a 36-run pilot on one machine, not the evaluation, and I’ll keep saying so.
Two problems I’d left myself
Before building on the baseline, I went back and read it properly. That was bad for my ego and good for everything else.
The model was wrong. The design record asked for a quantized, code-capable mixture-of-experts model sized for unified memory. The baseline then pinned qwen2.5-coder:7b, a small dense model. Perfectly nice for a smoke test. Not what I’d designed. I’d written one thing and pinned another, which is a very human approach to reproducibility.
The agent script couldn’t start. It passed --no-chat-history-file to Aider 0.86.1, which has no such option and exits with “unrecognized arguments”. The baseline post checked the Terraform fixture, which really did work, and that was it. Nobody ever ran the agent script, and by “nobody” I mean me. A pinned version is only half of reproducibility. The other half is running the thing you pinned.
Picking a model that fits
I went with qwen3-coder:30b (Qwen3-Coder-30B-A3B). It’s a mixture-of-experts model: roughly 30 billion parameters in total, but only about 3 billion are active for each token. On a unified-memory Mac, the total decides whether it fits and the active count drives the work per token. In practice you pay the memory bill of a 30B model and get something closer to the speed of a much smaller one. Birgitta Böckeler’s experiments, which I wrote about in the local models detox post, landed on a model of the same shape.
| Candidate | Decision |
|---|---|
qwen3-coder:30b, Q4_K_M, 18.6 GB | Selected: code-specialised MoE, tool-capable, Apache-2.0 licence. |
qwen2.5-coder:7b | Kept as a low-memory fallback, not the primary. |
devstral:24b | Similar memory, but dense: every parameter works on every token. |
gpt-oss:20b | A general reasoning model; a reasonable later comparison. |
Then there’s the machine. The design’s reference profile is 48 GB. The pilot ran on an Apple M6 with 32 GB, because that’s the Mac I had to hand, and designing for a machine you aren’t using is a very me thing to do. It’s a different test condition, so it’s recorded as one rather than quietly smoothed over.
Deploying it on purpose
The deployment guide pins Ollama v0.40.19 by archive checksum and the model by manifest digest. make model-deploy refuses to carry on if the registry tag now points at a different digest. A moved tag is a different model wearing the same name badge, and it deserves a review before anyone trusts it.
Every server setting lives in one versioned file, and each one appears in ollama serve --help for the pinned release, so nothing is folklore. Three of them do the heavy lifting:
OLLAMA_HOST=127.0.0.1:11434: nothing else on the network can reach the model.OLLAMA_NO_CLOUD=1: turns off Ollama’s cloud inference and web search. Without it, a-cloudmodel tag is a perfectly plausible way for a “local” workflow to post your prompt somewhere else. Local by declaration isn’t local.OLLAMA_KV_CACHE_TYPE=q8_0with flash attention: halves the context cache’s memory compared with the default, which on 32 GB is not a luxury.
The one I wouldn’t have thought about without testing was the context window. Aider talks to Ollama through the OpenAI-compatible /v1 endpoint, which has no per-request context-length setting, so the agent gets whatever the server fancies. On this machine, Ollama found 25.0 GiB of usable GPU memory and picked a 32K default. A different machine or a runtime upgrade could change that, and you’d never know from the configuration.
So the context window gets fixed in a two-line derived model:
FROM qwen3-coder:30b PARAMETER num_ctx 16384 series-coder:32gb gets 16K tokens and series-coder:48gb gets 32K. Böckeler suggests 32K as a minimum for agentic coding. I’ve gone lower, because these tasks are tiny and so, relatively speaking, is my Mac. Aider is told the same limits through a model-metadata file, so it doesn’t assume a cloud-sized window. Once loaded, the model took 19.4 GB, all of it on the GPU, with a 16,384-token context.
Turning templates into tasks
The routing article’s prompt templates finally became four actual tasks. Each has a fixture, a prompt, a check the agent can see, and acceptance tests it can’t:
| Task | The model must | Hidden acceptance |
|---|---|---|
| tf-01 | Replace hard-coded values with validated variables. | terraform test: defaults, one allowed value, two rejected values |
| tf-02 | Model services with a validated for_each map. | terraform test: defaults, sorting, two rejected ports |
| tf-03 | Extract labelling into a local module. | terraform test: root output and the module in isolation |
| platform-01 | Complete a runbook for pods that are Running but not Ready. | Approval markers, namespace scope, use of fixture facts |
Every Terraform fixture is provider-free and the hidden tests use command = plan, so nothing creates state and nothing can wander off and build real infrastructure. Aider runs the visible check (fmt, validate and plan) after every edit and hands any failure back to the model. The harness then applies the hidden tests to a copy and checks that every changed file is one the task allowed.
Before letting the model anywhere near it, I checked the hidden tests against hand-written reference answers. One of my tests was wrong. It compared sort()’s list result with a tuple literal, which Terraform never considers equal, so no answer could ever have passed. Without that check, the model would have taken the blame for my bug, and I’d have written it a stern paragraph.
What the model wrote
Here’s the model’s tf-02 solution, untouched apart from the formatter run I’ll come to in a moment:
variable "services" { type = map(object({ port = number public = bool })) # default omitted here for brevity validation { condition = alltrue([for service in var.services : service.port >= 1024 && service.port <= 65535]) error_message = "All ports must be between 1024 and 65535 inclusive." } } output "public_services" { value = sort([for name, service in var.services : name if service.public]) } That’s what I’d have written, on a good day, with a coffee. The examples directory holds all four outputs, each from its task’s first repetition rather than the best of three (no cherry-picking), with review notes. One of them is a rejected runbook, and it’s there on purpose.
| Task | pilot-32gb (v1) | v1.1-32gb | v1.1-32gb-fmt |
|---|---|---|---|
| tf-01 validated variables | 3/3 | 3/3 | 3/3 |
tf-02 for_each services | 0/3 | 0/3 | 3/3 |
| tf-03 local module | 3/3 | 3/3 | 3/3 |
| platform-01 runbook | 0/3 | 0/3 | 0/3 |
The Terraform tasks were small, and the model was reliably good at them. The failures are far more interesting, which is lucky, because there are a few.
Three failures worth more than the passes
“Just whitespace”
Without a formatter, tf-02 failed all six runs. The code was right, and every hidden test passed, but blank lines had trailing spaces, so terraform fmt -check failed. Aider showed the model the failing output. In all six runs, the model waved it off as “just whitespace changes … that don’t affect functionality” and changed nothing. In one run it went further and announced that the implementation “passes the validation checks”.
It did not pass the checks. The model was right that the difference was cosmetic, and wrong to decide on its own that a failing check didn’t count. I’ve worked with people like that. I’ve been one. In an unattended pipeline, a confident “all good” after a red check is exactly what you mustn’t trust.
With terraform fmt running after each edit (the third, separately labelled condition), tf-02 went to 3/3. The formatter fixed the formatting. The model didn’t.
Files named after commands
In the first pilot, every runbook run was flagged for editing files it shouldn’t have touched. Aider’s whole-file edit format wraps each file in a Markdown code fence. A runbook is full of its own fenced kubectl blocks, and one of them closed Aider’s fence early. Aider then read the following lines as file names, and created files called kubectl get events -n demo-shop and kubectl rollout undo deployment/checkout -n demo-shop --to-revision=1.
Nothing was executed, and the scope check caught every one. Even so, finding a file named after a rollback command in your working directory is a special kind of Monday. This was a failure in the agent client’s plumbing, not in the model’s knowledge, and a benchmark that only scored the model would have blamed the wrong thing. Aider picks a fence that doesn’t already appear in the file, so v1.1 ships the runbook as a template that already contains a code block. Problem gone.
The warning in the wrong place
With the plumbing fixed, the runbook still failed all six runs, in exactly the same way every time. To be fair to it, the read-only checks were well scoped: every command targeted demo-shop and used only the permitted verbs. But the prompt required the marker REQUIRES HUMAN APPROVAL in a comment on the same line as any state-changing command. The model wrote:
```sh kubectl rollout undo deployment/checkout -n demo-shop --to-revision=1 ``` REQUIRES HUMAN APPROVAL Copy that block into a terminal and the warning stays behind on the page, waving. The command also rolls back to revision 1 with no evidence that revision 1 was ever healthy. It’s the sort of output that reads well in review and goes wrong at three in the morning. The rule was explicit and mechanically checkable, and the model missed it six times out of six.
Speed, memory and cost on this machine
These are observations from one host, not general claims:
- Warm Terraform tasks finished in 6–22 seconds end to end, including Aider, every check and the model explaining itself. The single cold start took 58 seconds.
- End-to-end output ran at 24–49 tokens per second. That includes prompt processing and check time, so it understates raw generation speed.
- The model runner’s resident memory peaked at 18.2–18.8 GB, and the lowest free-memory reading in each run was 13–14%, with ordinary applications open. 32 GB works, but there’s no room for a bigger context or a second model. Close the browser tabs. Yes, those ones.
- API cost was zero on the local route. I didn’t measure electricity, so there’s no running-cost claim here, however tempting “free” might sound.
What this does and doesn’t show
It shows that a 30B MoE coding model, pinned and configured on purpose, can write small, correct, provider-free Terraform changes on a 32 GB Mac. It also shows that the checks around the model did more than the model to make the results trustworthy. They caught a false completion claim, a plumbing collision and a misplaced safety marker. They also caught a bug in my own test, which I’d rather they hadn’t, but here we are.
It doesn’t show how this model compares with a cloud model, how it behaves on the 48 GB reference profile, or what happens with anything bigger than four small tasks. Those questions belong to the evaluation, which now has a corpus, a protocol and a harness to run against, so I’ve run out of excuses. This milestone is tracked in #117, and the full per-run record is in the pilot results.
The model writes good Terraform. Deciding when it’s done is still my job.
Sources
- Ollama v0.40.19 release, accessed 1 December 2026. The runtime archive and SHA-256 digests.
- Ollama model library: qwen3-coder, accessed 1 December 2026. Available tags and sizes; the model’s licence was read with
ollama show --license. - Ollama Modelfile reference, accessed 1 December 2026.
FROMandPARAMETER num_ctx. - Aider: linting and testing, accessed 1 December 2026. The
--test-cmd,--auto-testand--lint-cmdbehaviour used by the harness. - Aider: advanced model settings, accessed 1 December 2026. Model metadata and edit-format settings.
- Terraform tests, accessed 1 December 2026.
runblocks,command = plan,expect_failuresand module-scoped tests. - Birgitta Böckeler, “Local models for coding: factors affecting viability”, accessed 1 December 2026. The MoE and context-window guidance referred to above.
- Companion repository at
be891e1, the immutable revision for every result in this post.
🤖 AI co-author: Claude Code