---
title: "How to Manually Verify AI-Generated G-Code: Six Passes"
description: "AI G-code fails in plausible ways, so verification needs structure: six passes from dialect check to single-block first run, each catching what the last cannot."
url: https://gcodepractice.com/journal/how-to-manually-verify-ai-generated-g-code/
canonical: https://gcodepractice.com/journal/how-to-manually-verify-ai-generated-g-code/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-06-07
updated: 2026-06-07
category: "Guides"
tags: ["ai", "verification", "g-code", "safety"]
lang: en
---

# How to Manually Verify AI-Generated G-Code: Six Passes

> **TL;DR** Verify AI-generated G-code in six ordered passes, each catching a failure class the previous one cannot: a dialect pass (every word exists on your control), a state pass (units, distance mode, offsets, and safety line all declared), a geometry pass (plot the path and compare against intent), a physics pass (feeds, speeds, and depths against the formulas), a clearance pass (every rapid, retract, and G28 traced for what is actually in the way), and a machine pass (dry run, then single block with conservative overrides). Skipping a pass because the code looks professional is the trap; looking professional is what the model is for.

The right frame for AI-drafted G-code is an unknown programmer's first submission: it looks competent, nothing about it is proven, and it gets reviewed in a fixed order rather than by vibes. Fixed order matters because AI failures are plausible by construction, [hallucinated](https://en.wikipedia.org/wiki/Hallucination_(artificial_intelligence)) code reads smoothly, and a structured review catches what smooth reading slides past. Six passes, cheapest first, each catching a class the previous one cannot.

## Why ad-hoc review fails on AI code

Reading a file top to bottom and nodding is review theater, and AI output defeats it for a structural reason: a human programmer's mistakes cluster where the human was uncertain, so experienced reviewers know where to look. A model is never uncertain. Its errors distribute evenly across confident, fluent code, a wrong cycle parameter sitting in a perfectly formatted block, a dialect-foreign word wearing the house style. The fix is to stop reviewing by suspicion and start reviewing by category: six passes, each interrogating the file for one failure class, in an order that puts the cheap checks before the expensive ones.

## The six passes

| Pass | The question | The tool |
| --- | --- | --- |
| 1. Dialect | Does every word exist on my control? | Your control's manual; a reference like LinuxCNC's |
| 2. State | Are units, distance mode, offset, and safety line declared? | Your eyes, on the header |
| 3. Geometry | Does the path match the intent? | A plotter or simulator |
| 4. Physics | Are feeds, speeds, and depths plausible? | The two formulas and the tool data |
| 5. Clearance | What is actually in the way of every rapid and retract? | The setup, pictured honestly |
| 6. Machine | Does it behave, slowly, with nothing at stake? | Dry run, then single block |

## Pass 1: dialect

Models train on every dialect at once and mix them freely: a Fanuc-format cycle here, a LinuxCNC-only word there, an M code your machine never wired. Read every G and M word against your control's documentation, with a strict public reference like the [LinuxCNC G-code list](https://linuxcnc.org/docs/html/gcode/g-code.html) as the comparison baseline. Anything your control does not document is wrong by definition, however standard it looks. Tooling helps at this layer, the [syntax-checker stack](/journal/g-code-syntax-checker-for-chatgpt-output/) industrializes it, and canned cycles deserve double attention either way: the deepest dialect divergence and the model's favorite place to improvise, with the lathe version dissected in [ChatGPT's G71 errors](/journal/chatgpt-cnc-lathe-g71-canned-cycle-errors/).

## Pass 2: state

AI code chronically under-declares: no units word, no distance mode, no offset selection, no safety line, because training examples omit them too. The header should establish units, G90 or G91, the work offset, plane, and comp-off state explicitly. Whatever is undeclared, the machine inherits from its previous program, which is a coin flip you do not control.

## Pass 3: geometry

Plot the file. A backplot or a free simulator like [CAMotics](https://camotics.org/) turns the code into a shape, and your eyes do the comparison against intent: right profile, right depth layering, arcs bowing the right way. This is the pass where reversed G02/G03 and wrong arc centers surface. A simulator is excellent here and only here; it models the program's world, not your shop, which is why this pass is one of six rather than the review, the boundary [simulating without a machine](/journal/how-to-simulate-g-code-without-a-machine/) draws precisely.

## Pass 4: physics

Models guess numbers with total confidence: feeds that parse and snap cutters, spindle speeds from a different material's table, full-diameter depths for a finishing tool. Check S against the speed formula, F against chip load, depths against the tool maker's data. Thirty seconds with the [feed-rate arithmetic](/journal/how-to-calculate-feed-rate-for-g01/) is the whole pass, and it regularly catches the error that would have been loudest.

## Pass 5: clearance

Trace every rapid, retract, and reference move while picturing the actual setup: vise jaws, clamps, the chuck. AI does not know your workholding exists. G28 deserves special suspicion, it moves through an intermediate point in a way [models reproduce wrongly across dialects](/journal/why-did-chatgpt-g-code-crash-my-cnc/), and a Z-positive retract written for a machine zeroed differently is a plunge on yours. The general skill of this pass, scanning a file specifically for its dangerous lines, is [error-hunting](/journal/how-to-read-g-code-to-find-errors/), and it transfers to every file you will ever review, AI-born or not.

## Pass 6: machine

Dry run above the work or in air, then first real run in single block with feed and rapid overrides pulled down, distance-to-go on the screen, hand near hold. Nothing new here; this is what a careful shop gives any unproven program. The point of passes one through five is that by the time the AI's code earns the machine, it has stopped being the AI's code: every line has been read, checked, and owned by you.

## Make the review fast enough to survive

A six-pass review that takes an hour gets abbreviated by Friday; one that takes minutes becomes habit. Speed comes from recognition, knowing the core codes and your dialect's edges at recall rather than lookup, and that trains in minutes a day: the free 60-second rounds on the [G-code practice page](/g-code-practice/) repeat your misses until the vocabulary answers instantly. Whether you need the fluency despite using AI has a short answer, [yes, more than before](/journal/do-i-need-to-know-g-code-if-i-use-ai/), and the six passes are where that fluency pays its rent.

## Sources

- [Wikipedia: Hallucination (artificial intelligence)](https://en.wikipedia.org/wiki/Hallucination_(artificial_intelligence))
- [LinuxCNC: G-code reference](https://linuxcnc.org/docs/html/gcode/g-code.html)
- [CAMotics: open-source CNC simulation](https://camotics.org/)

## Frequently asked questions

### How do you manually verify AI-generated G-code?

In six ordered passes: dialect (every word exists on your control), state (units, distance mode, offset, safety line declared), geometry (plot it), physics (feeds, speeds, depths against the formulas), clearance (trace every rapid and retract for obstacles), and machine (dry run, then single block with low overrides).

### Which pass catches the most AI G-code problems?

The dialect pass catches the most, because models mix controls freely. The clearance pass catches the worst: plausible code that rapids through a vise or returns through G28's waypoint.

### Can I just run AI G-code in a simulator instead of checking manually?

A simulator covers the geometry pass well and parts of dialect, and that is all. It will not flag a feed four times too high, a missing G43, or a retract through your actual workholding. Use one inside the six passes, not instead of them.

### What knowledge do the six passes assume I have?

Instant recognition of the core codes plus your control's dialect edges. The free G-Code Sprint app builds that recognition in 60-second daily rounds, the difference between a review taking minutes and getting skipped.

---

Source: https://gcodepractice.com/journal/how-to-manually-verify-ai-generated-g-code/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
