This is an educational explanation of why AI-written G-code is risky, not operating advice for your specific machine. Never run code you have not verified, and always follow your machine’s manual and shop safety procedures.
A language model can produce G-code that reads perfectly and still crashes the machine. That is not a contradiction. The model is trained to generate text that looks correct, which is a different goal from producing a safe toolpath for your exact setup.
The model cannot see your machine
Every safe program depends on facts that live at the machine, not in the text. An AI has none of them:
| What it does not know | Why it matters |
|---|---|
| Your control dialect | A Fanuc-only or Haas-only code can throw an improper-code alarm |
Your work offset (G54) | It cannot know where your part actually sits |
| Your tool lengths | It cannot know how far each tool reaches |
| Your stock size | A move it thinks is clear can be buried in material |
| Your fixtures and clamps | It has no idea where a collision waits |
Because it cannot see any of that, even well-formed code is a guess about your machine.
It can invent codes that look right
Language models are known to produce confident, plausible output that is simply wrong, a behavior documented as AI hallucination. In G-code that shows up as invented canned cycles, parameters that do not exist on your control, or a code borrowed from the wrong dialect. The core codes are standard, as the Wikipedia G-code overview and the LinuxCNC reference show, but the moment a program leans on a machine-specific feature, a guess becomes a real alarm or a real crash.
The usual failure modes
| Failure | What happens at the machine |
|---|---|
| Wrong dialect | Improper G-code alarm, like Fanuc alarm 010 |
| Missing safety block | No units or plane set, so the machine runs in the wrong mode |
| Missing or wrong decimal | A move 1000x off, the missing decimal point problem |
| No offset awareness | A rapid drives into the part or a clamp |
| Invented cycle | The block does not do what the comment claims |
Treat AI code as a draft
The safe stance is simple: AI code is an unverified draft, never a finished program. Before it cuts anything, do what you would do for any untrusted program, which is exactly how to safely test a G-code program without crashing: read it line by line, confirm the dialect and the safety block, simulate it, and dry run it above the part with the offsets and tooling verified. The same discipline applies to a conversational program that alarms. In a shared shop or makerspace, it is also why a CNC router safety and code checkout should happen before anyone runs a job alone.
The real defense is your own code literacy. If you can read a CNC program fluently, an invented or wrong code stands out before you ever press cycle start. That fluency is what a practice routine on the G-code practice hub builds.
Bottom line
ChatGPT G-code crashes because the model does not know your control, offsets, tools, stock, or fixtures, and it can invent codes that look right. It writes convincing text, not verified toolpaths. Treat any AI output as a draft: read it, simulate it, and dry run it before cutting, and lean on your own ability to spot a wrong code.
Sources
Frequently asked questions
Why did ChatGPT G-code crash my CNC?
Because the model wrote code for a machine it cannot see. It does not know your control dialect, offsets, tool lengths, stock, or clamp positions, and it can invent codes that look right but are wrong for your setup. Plausible text is not a safe toolpath.
Is AI-generated G-code safe to run?
Not without verification. It can be a useful draft, but it must be read, simulated, and dry run with offsets and tooling confirmed before it touches material.
What does an AI most often get wrong in G-code?
The wrong control dialect, missing safety lines, missing or wrong decimals, invented cycles or parameters, and no awareness of your offsets or fixtures, so a move that looks fine drives into the part or a clamp.
What is the best way to learn to catch bad G-code?
Build the literacy to read code critically. A free app like G-Code Sprint drills the real codes with active recall and repeats whichever ones you miss, so a wrong code looks wrong immediately.
G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.