Loading local progress…
PLC Gym
PLC Gym homeLevel 1, 0 XP · your progress
All guides

AI PLC programming with Claude Code: what works in a factory today

AI PLC programming explained: how engineers can use Claude Code today to write, test and review PLC code, find faults safely, and what comes next.

An engineer by a Siemens S7-1500 rack, ladder logic on one screen and AI suggestions on the other.
The AI reads the code and the data. The engineer still decides what goes on the machine.
In this guide
  1. What agentic AI is, and how it differs from a chatbot
  2. AI PLC programming in 2026: three routes
  3. What Siemens, Rockwell and Beckhoff offer
  4. Why use Claude Code as well
  5. Getting PLC projects out as text
  6. Setting Claude Code up safely before you start
  7. Guide 1: reading alarms and trends to find a fault
  8. Guide 2: reviewing a program before a change
  9. Guide 3: writing an SCL function block with tests
  10. Guide 4: documenting an old machine nobody understands
  11. Connecting AI to live plant data, read only
  12. Building a read only MCP server for your plant
  13. Commissioning with an AI beside you
  14. The limits, honestly
  15. Where the industry is heading
  16. The skills that stay human
  17. Practise the part AI can't do for you
  18. Frequently asked questions
  19. Sources

If you've wondered whether AI can really help with PLC work, the short answer is yes, today, and by more than most people realise. AI PLC programming isn't just asking a chatbot to write a rung. With an agent like Claude Code, an engineer can review a whole program before a change, write a function block and the tests that prove it, document a machine nobody understands any more, and work through weeks of alarms and trends to narrow down a fault.

This guide shows how to use it on a real site on Monday morning, with real examples, and where the industry is heading. Plenty of people who run engineering teams aren't sure how, or whether, their engineers use AI. Some use it quietly. Some won't touch it. Very few firms have a plan for it.

Every PLC fact below comes from the makers' own manuals and press releases, or from the standards bodies and regulators, and they're all linked at the end.

What agentic AI is, and how it differs from a chatbot

A chatbot answers in a window. You paste some code in, it replies, and you copy its answer back out. It only sees what you paste, and it can't check anything it tells you.

An agent works on your files with your tools. Claude Code, made by Anthropic, runs on your own computer, in a terminal, an editor or the Claude desktop app. You point it at a folder and give it a job. It reads the files, makes a plan, edits, runs commands such as a script or a test, reads what came back, and keeps going until the job is done or it needs you. By default it asks before it edits a file or runs most commands.

That changes what you can hand over. "Explain this rung" is chatbot work. "Go through all 140 routines, list every place this output is written, and flag any that bypass the guard interlock" is agent work. It does the long, careful reading that people skip when they're tired, and it shows its evidence.

AI PLC programming in 2026: three routes

RouteWhat it isGood forWatch out for
The maker's own copilotAI built into TIA Portal, FactoryTalk Design Studio or TwinCATWriting and explaining code inside the tool you already useOne maker only, and still early
An agent on exported filesClaude Code working on a copy of the project, as text, on an office laptopReviews, documentation, tests, comparing versions, any makerGetting the project out as text and back in
An agent reading live dataClaude Code connected read only to OPC UA, SCADA or a historian, through MCPFault finding from real values, alarms and trendsNetwork security, and it must never write

Most sites should start with the second route. Nothing touches the plant, you work on a copy, and the worst thing that can happen is a bad suggestion that a person reads and throws away.

What Siemens, Rockwell and Beckhoff offer

The product names keep changing, so check what's current before you buy anything.

Siemens announced its Industrial Copilot for TIA Portal in April 2024, built with Microsoft on Azure OpenAI models. It generates SCL that TIA Portal takes straight in, explains SCL blocks and searches the documentation. In April 2026 Siemens made its Eigen Engineering Agent commercially available. Siemens says it plans, carries out and checks engineering tasks inside TIA Portal, from PLC code to HMI screens and device setup, after a pilot with more than 100 companies. It needs TIA Portal V19 or later and is sold as a subscription, with a free trial.

Rockwell and Microsoft put Azure OpenAI into FactoryTalk Design Studio, Rockwell's cloud engineering tool, in 2023, so engineers can generate code from plain language. Trade press at Automation Fair 2024 described its Copilot writing code, explaining projects and showing ladder changes highlighted for the engineer to approve. In October 2026 Rockwell announced FactoryTalk Conductor, which coordinates AI agents across Studio 5000 Logix Designer, Logix Echo, Emulate3D and FactoryTalk Optix. Customers can use Rockwell's AI or their own models, and it goes on sale in early 2027.

Beckhoff added TwinCAT Chat in 2023: a chat window inside TwinCAT engineering, linked to the PLC project, that writes, extends and documents code. In June 2026 it followed with TwinCAT 3 CoAgent for Engineering. Beckhoff says it suggests Structured Text, sets up I/O and builds HMI pages, works with OpenAI, Anthropic, other providers or a local model with no internet at all, and is built on MCP. The engineer approves every result before it's applied.

Others are at it too. CODESYS has an MCP server for its development system. Inductive Automation is building AI agents and MCP into Ignition 2027, its SCADA platform, in public beta now with a full release planned for February 2027. Schneider Electric announced a copilot for EcoStruxure Automation Expert in 2025.

The direction is clear. Every big maker is building agents, and some are building them on MCP, the same open standard Claude Code uses. The line between "the maker's AI" and "your own agent" is already blurring.

Why use Claude Code as well

The makers' tools are good and getting better, but a general agent alongside them still adds a lot. Claude Code, Anthropic's agent, is built for long jobs across many files, which is exactly what PLC work needs. Which AI leads changes every few months, so judge any tool on a real job from your own site. Here's what a general agent brings.

  • It isn't tied to one maker. Plenty of sites have Siemens, Rockwell and something older on the same floor. One agent can read all of it.
  • It works on the whole job. Not just one block, but the project, the I/O list spreadsheet, the alarm export, the functional description and the test results, together.
  • It can run tools. Git to compare versions, Python to crunch a historian export, a test runner to prove a block works.
  • It follows your standards. You can write your naming rules, block structure and "never do this" list into a file it reads every time.
  • It connects to your systems. Through MCP you can give it exactly the tools you choose, and nothing else.

It has real downsides too. It doesn't know your plant. It wasn't built for PLCs, so it can mix up how Siemens and Rockwell do the same thing. It can't see inside TIA Portal or Studio 5000 unless you get the project out as text. And by default your files go to Anthropic's servers to be processed, which your company and your customers need to be happy with first.

Getting PLC projects out as text

An agent reads text. PLC projects mostly live inside the maker's own project files, so the first job is getting them out. All three big makers let you.

Siemens. In TIA Portal, "Generate source from blocks" saves SCL blocks, data blocks and PLC data types as text files, such as .scl, which you can edit in any text editor and import back to generate the blocks again. It doesn't cover ladder or FBD. For those there's TIA Portal Openness, Siemens' interface for automating TIA Portal, which exports blocks in every language, tag tables, data types and more as Simatic ML XML files, and imports them again. Anyone running an Openness program has to be in the "Siemens TIA Openness" Windows group. Since V16, TIA Portal has also had a Version Control Interface that connects a project to Git and tools like it. SIMATIC AX, Siemens' newer text based engineering, keeps Structured Text as text from the start, with Git and unit tests built in.

Rockwell. Studio 5000 Logix Designer exports a whole project as L5K, a text file, or L5X, which is XML. Parts of a project export as L5X too: programs, routines in any language, single rungs, user defined data types and AOIs. Inside an L5X, ladder rungs are stored as plain text, which agents read well. Rockwell's Logix Designer SDK lets Python or C# scripts open and export projects, and the Logix Designer Compare Tool shows the differences between two versions.

Beckhoff. TwinCAT 3 already stores each program unit, data type and global variable list as its own XML file (.TcPOU, .TcDUT and .TcGVL), so projects work with source control. That makes TwinCAT the easiest of the three for an agent. The TwinCAT Automation Interface also lets scripts create and edit projects.

CODESYS and others export PLCopen XML, the maker neutral format set out in IEC 61131-10, though CODESYS says it can't promise every detail survives the trip.

Getting changes back in is the part to plan. Whatever the agent writes goes into an offline copy of the project through the maker's normal import, gets compiled there, checked with the maker's own compare tool and tested on a simulator. Never paste AI code straight into a project that's online with a running machine.

Setting Claude Code up safely before you start

Get this right once and every job after it is easier.

  1. Ask first. The program belongs to your company or your customer. Check with IT and read the contract. Some customers ban sending their code to any cloud service.
  2. Use an office laptop. Not an engineering PC on the plant network, and never a machine that can reach a PLC.
  3. Work on a copy. Export the project into a folder and put it under Git, so every change the agent suggests can be seen and undone.
  4. Write the house rules down. Claude Code reads a file called CLAUDE.md at the start of each session. Put your standards and your red lines in it.
  5. Lock down what it may do. Claude Code's settings let you allow, ask about or deny each kind of action, and a deny rule beats everything else. Your company can set rules centrally that nobody can override.
  6. Start with questions, not changes. "Explain", "list" and "find" come before "write". Claude Code's plan mode lets it read and plan without changing anything, which suits a review.

Here's the kind of CLAUDE.md to start with:

# Line 3 filler: TIA Portal V19 export, for review only

- This folder is a copy. Nothing here is ever downloaded to a PLC from this laptop.
- S7-1500, SCL and LAD. One FB per device. Alarms live in DB_Alarms.
- Never edit an F block or anything in the Safety folder. Report on them only.
- Show every suggested change as a diff, with the test that proves it.
- If you are not sure how Siemens handles something, say so. Do not guess.

This is the one to show a sceptical engineer first, because nothing is changed and the time saved is obvious.

Say a filler stops a few times a shift on "Low air pressure". Maintenance has already changed the regulator, and it still happens. Here's how to use Claude Code on it.

  1. Export the alarm history. Two weeks from the SCADA or HMI alarm log, as CSV. Every alarm, not just this one.
  2. Export the trends. From the historian, at the finest resolution it keeps: air pressure, the line's state, speed, and every valve or blower that uses air.
  3. Export the code behind the alarm. The block that raises it, and anything that reads the pressure.
  4. Ask for a timeline, then patterns. What happens in the minute before each stop? Is it worse on one shift, at one speed, on one product?
  5. Ask how the alarm is made. What threshold, what delay, does it latch, what does it stop?
  6. Ask for ranked suspects and the checks that would prove each one. Then a person goes and checks.

The prompt can be as plain as this:

The files in /exports are 14 days from Line 3: alarms.csv, trends.csv and the
SCL blocks. Build a timeline of every "Low air pressure" stop. For each one,
list what changed in the 60 seconds before it. Then read FB_AirMonitor and
tell me the exact threshold, delay and latching. Rank the likely causes by
evidence, and for each, give me one safe check a technician can do on the
line. Don't change any files.

Here's the kind of thing that comes back. This one is made up, but the pattern is a classic. Every stop came within two seconds of the reject blower and the air knife firing together. The pressure dipped below the 5.2 bar threshold for about 300 milliseconds each time. And the alarm had no delay, so a dip shorter than a blink stopped the whole line. The real problem may be air demand at that point in the cycle, plus an alarm that's too twitchy. It could also be wrong, which is why the next step is a person with a gauge.

Notice what the AI is doing. It's reading thousands of rows that a person would sample, and pointing at where to look. It isn't diagnosing the machine. The PLC troubleshooting guide covers the method a person still follows on the floor.

Guide 2: reviewing a program before a change

A second pair of eyes catches most bad changes, and an agent is a very patient second pair of eyes. It doesn't replace the human reviewer. It gives them a list to check.

  1. Export the program before the change and commit it to Git.
  2. Make the change offline in TIA Portal or Studio 5000 as normal, export again and commit that too.
  3. Ask Claude Code to review the difference. What changed, every place each changed tag is read and written, and what else depends on it.
  4. Give it a checklist. Outputs written in two places, interlocks or permissives bypassed, timers that never reset, states with no way out, alarms that no longer fire, comments that no longer match.
  5. Read its report, then do your own review. Its job is to find things for you to look at.

Rockwell projects export rungs as plain text, which makes this easy to show. Here's a conveyor rung before and after a change:

Before:
[XIC(Start_PB) ,XIC(Conveyor_Run) ]XIC(Stop_OK)XIC(Guard_Closed)OTE(Conveyor_Run);

After:
[XIC(Start_PB) ,XIC(Conveyor_Run) ]XIC(Stop_OK)[XIC(Guard_Closed) ,XIC(Maint_Mode) ]OTE(Conveyor_Run);

A good review flags that Maint_Mode now lets the conveyor run with the guard open. Then it asks the questions a person should answer. Who can turn on Maint_Mode? Is it a key switch, or a button on the HMI? Is the guard also covered by the safety system, or is this rung the only thing stopping it? A one line edit, and the most important line in the change.

AI writes plausible code that can still be wrong, and that's exactly what review is for. PLC Gym has three missions where an assistant has written the code and your job is to find what's wrong before it goes to site, starting with Review the AI: Stop priority.

Guide 3: writing an SCL function block with tests

This is where an agent shines, as long as you write the tests before you trust the code. Here's the workflow for a valve block in Siemens SCL.

  1. Write the job in plain words. What goes in, what comes out, what counts as a fault.
  2. Ask for the test cases first, as a table, and check them yourself. If the tests are wrong, the code will be too.
  3. Ask for the block, written to your standards.
  4. Run the tests on a simulator, never on a live machine.
  5. Review it like any other code, then import it and carry on as normal through FAT.

Here's a plain spec to give it. The valve opens while OpenCmd is on. It has an open and a closed limit switch. If it hasn't reached the position it was asked for within TravelTime, raise a fault and drop the solenoid. Both switches on at once is a wiring fault. Reset clears the fault only once the valve is safely closed.

The test cases come back as a table like this:

TestDo thisExpect this
Opens normallyOpenCmd on, open switch made after 2 sSolenoid on, IsOpen on, no fault
Sticks closedOpenCmd on, open switch never madeFault after 5 s, solenoid off
Both switches madeOpen and closed switches on togetherFault straight away
Reset too earlyFault, then Reset before the closed switch is madeFault stays
Reset properlyFault, valve back closed, then ResetFault clears

And the block:

FUNCTION_BLOCK "FB_Valve"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT
      OpenCmd : Bool;              // Request from the sequence
      FbOpen : Bool;               // Limit switch: valve open
      FbClosed : Bool;             // Limit switch: valve closed
      Reset : Bool;                // Operator reset
      TravelTime : Time := T#5S;   // Longest normal travel
   END_VAR
   VAR_OUTPUT
      Solenoid : Bool;
      IsOpen : Bool;
      IsClosed : Bool;
      Fault : Bool;
   END_VAR
   VAR
      OpenTimer : TON_TIME;
      CloseTimer : TON_TIME;
      FaultLatch : Bool;
   END_VAR

BEGIN
   // Only drive the valve while there is no fault
   #Solenoid := #OpenCmd AND NOT #FaultLatch;

   // Time each move separately, so a reversal mid travel starts a fresh count
   #OpenTimer(IN := #Solenoid AND NOT #FbOpen, PT := #TravelTime);
   #CloseTimer(IN := NOT #Solenoid AND NOT #FbClosed, PT := #TravelTime);

   IF #OpenTimer.Q OR #CloseTimer.Q OR (#FbOpen AND #FbClosed) THEN
      #FaultLatch := TRUE;
   END_IF;

   // After a fault the valve is sent closed, so reset only works once it is
   IF #Reset AND #FbClosed AND NOT #FbOpen THEN
      #FaultLatch := FALSE;
   END_IF;

   #IsOpen := #FbOpen AND NOT #FbClosed;
   #IsClosed := #FbClosed AND NOT #FbOpen;
   #Fault := #FaultLatch;
END_FUNCTION_BLOCK

The most useful thing in that block is the idea behind it: a command isn't proof that anything moved. PLC Gym's command is not feedback mission is built on exactly that.

How you run the tests depends on what you have. Siemens' TIA Portal Test Suite has an Application Test for writing test cases against S7-1500 blocks and running them on S7-PLCSIM Advanced, Siemens' virtual PLC. SIMATIC AX has its own unit test framework, AxUnit. TwinCAT users have TcUnit, which is free and open source, and Beckhoff has announced its own TF1140 Test Framework. CODESYS has its Test Manager. If you have none of those, ask the agent for a test block that steps through each case in PLCSIM and sets a pass or fail flag for each one. Whichever you use, the agent can write the tests. Your job is to check they test the right things.

Guide 4: documenting an old machine nobody understands

Every site has one. It was built fifteen years ago, the integrator has gone, the comments are in another language or missing, and the one person who understood it has retired. An agent is very good at the first pass of turning that into something a new engineer can follow.

  1. Export everything you can: program, tags, HMI alarm texts and screens, any drawings you have as PDFs.
  2. Ask for the shape of it first. Which routines call which, what runs every scan, what runs on an event, where the sequences are.
  3. Ask for a plain description of each routine, with what it reads, what it writes and why it probably exists.
  4. Ask for an I/O list built from the addresses, tag names and comments, as a spreadsheet.
  5. Ask for each sequence as numbered steps, with the condition that moves it on.
  6. Ask for draft alarm texts where the existing ones are vague, in your house style.
  7. Ask for a list of questions it couldn't answer from the code. That list is gold.
  8. Walk the machine with the drafts and correct them. Then store them with the project.

The I/O list comes back like this, ready to check against the panel:

AddressTagDraft descriptionConfidence
%I4.0LS_201Infeed gate closed limit switchHigh: named and used as a gate interlock
%I4.3PX_7Probably the bottle present sensor at the capperMedium: only used in the capper step
%Q8.2Y12Unknown solenoid, energised in step 40Low: no comment, check on the machine

The confidence column is the part to insist on. It tells you where to spend your time on the walk round, and it stops a guess being written up as a fact.

Connecting AI to live plant data, read only

The next step is letting the agent read live values, alarms and history, so you can ask it about the machine as it is now. This is where people get nervous, and they should. Done badly, it's a new way into a plant network. Done properly, it's no riskier than a SCADA client that can only look.

One rule never bends: the AI never talks to a PLC directly, and nothing it can reach can write.

There are three places to read from, best first:

  1. A historian or SCADA system. It already collects the data, it often sits in a safer part of the network, and reading from it puts no load on the controllers.
  2. An OPC UA server. OPC UA is the standard way for industrial software to share data, with encryption and logins built in.
  3. The controller's own protocol. Possible with free libraries, but the hardest to make read only.

Siemens

The S7-1500 has an OPC UA server built in, but it's switched off until you turn it on, and Siemens says it needs a runtime licence, small, medium or large depending on the CPU. Every tag in TIA Portal has two boxes, "Accessible from HMI/OPC UA" and "Writable from HMI/OPC UA", and both are ticked by default. Untick Writable and the tag is read only to every OPC UA client and HMI. Siemens recommends the Basic256Sha256 security policy with signing and encryption, and logins rather than anonymous access.

The free python-snap7 library talks to S7 controllers directly, but on an S7-1200 or S7-1500 it needs "Permit access with PUT/GET communication from remote partner" switched on, and data blocks that aren't optimised. Siemens' own security guide lists switching PUT/GET off as a protection step, because while it's on, other devices can read and write the CPU's data. For an AI, use OPC UA instead.

Rockwell

ControlLogix 5580 and CompactLogix 5380 controllers have an OPC UA server built in from firmware version 36, switched off by default. Each tag can be set to read and write, read only or no OPC UA access, and safety tags can only be read only or none. For older controllers, FactoryTalk Linx Gateway is an OPC UA server on a PC that serves Logix data, and you choose which tags it offers. The free pylogix and pycomm3 libraries talk EtherNet/IP straight to the controller and can write as well as read, so neither belongs in an AI's hands.

Beckhoff and Ignition

TwinCAT's OPC UA server is TF6100. Setting one attribute in the PLC code, OPC.UA.DA.Access to 1, makes a variable read only and the server refuses writes, and its default Guests group can only browse and read. The free pyads library uses Beckhoff's own ADS protocol, and Beckhoff documents read only access for OPC UA, not for ADS connections as a whole, so again OPC UA is the safer route.

Ignition, the SCADA platform from Inductive Automation, has an OPC UA client built in, an optional OPC UA server where each role gets its own browse, read and write permissions, and a tag historian. That makes it a natural place for an AI to read from.

The free Python libraries

LibraryTalks toLicenceWatch out for
asyncuaAny OPC UA serverLGPL 3.0Its README warns of bugs and changes to come
python-snap7Siemens S7MITNeeds PUT/GET switched on for an S7-1200 or S7-1500
pylogixRockwell Logix and Micro800Apache 2.0Reads and writes; no PLC-5, SLC or MicroLogix
pycomm3Rockwell LogixMITIts README says it's no longer actively developed
pyadsBeckhoff TwinCATMITNeeds an ADS route set up on the target

Building a read only MCP server for your plant

MCP, the Model Context Protocol, is an open standard for giving AI agents tools. An MCP server is a small program that offers a list of tools, such as "read these tags" or "get the last hour of this trend". The agent can call only those tools, in only the way the server allows. So the server is where you put the safety rules, in code, rather than hoping the AI behaves.

Anthropic released MCP as open source in November 2024. In December 2025 it handed it to the Agentic AI Foundation, run under the Linux Foundation and set up by Anthropic, Block and OpenAI. It's now the usual way to plug tools into AI agents, and there are already open source MCP servers on GitHub for OPC UA, Modbus and Ignition. Read their code before using one: several can write as well as read, some once writing is switched on, and at least one can download to a PLC.

For a plant, give it tools like these and nothing more:

  • list_tags: the tags it's allowed to read, with descriptions and units.
  • read_tags: current values for a short list of those tags.
  • read_alarm_history: alarms between two times, from SCADA or the historian.
  • read_trend: one tag's history between two times, thinned out to a sensible number of points.
  • find_in_program: search an exported copy of the program, so it can say where a tag is used.

No write tool, no force tool, no download tool. If one doesn't exist, it can't be called. Here's a sketch in Python, to show how little there is to it. It reads through an OPC UA server using the free asyncua library and the official MCP Python SDK. It isn't production code, and it would need a proper security review before it went near a site.

# plant_mcp.py: a read only MCP server for one OPC UA endpoint. A sketch, not production code.
import csv
from asyncua import Client
from mcp.server.fastmcp import FastMCP
from mcp.types import ToolAnnotations

# A gateway or historian in the plant DMZ, never a PLC on the control network
ENDPOINT = "opc.tcp://ot-gateway.example.local:4840"
# Only the tags listed in this file can ever be read
ALLOWED = {row["name"]: row["node_id"] for row in csv.DictReader(open("allowed_tags.csv"))}
READ_ONLY = ToolAnnotations(readOnlyHint=True, destructiveHint=False)

mcp = FastMCP("line3-read-only")

@mcp.tool(annotations=READ_ONLY)
def list_tags() -> list[str]:
    """The tags this server is allowed to read."""
    return sorted(ALLOWED)

@mcp.tool(annotations=READ_ONLY)
async def read_tags(names: list[str]) -> dict[str, str]:
    """Read the current value of up to 20 allowed tags."""
    if len(names) > 20 or any(n not in ALLOWED for n in names):
        raise ValueError("Only up to 20 tags from list_tags")
    client = Client(url=ENDPOINT)
    # In real use: an encrypted connection and an OPC UA user with read only rights
    async with client:
        return {n: str(await client.get_node(ALLOWED[n]).read_value()) for n in names}

if __name__ == "__main__":
    mcp.run()

Then you tell Claude Code about it once, and it can use those tools in any session:

claude mcp add --transport stdio line3 -- python plant_mcp.py

The tool labels in that code tell the agent the tools only read. They're a hint for the agent, not a lock. The real locks are the server having no write tools, the OPC UA user having no write rights, the tags being set read only in the PLC, and the network only letting the gateway through.

Commissioning with an AI beside you

Commissioning is mostly checking, recording and chasing. That suits an agent well, as long as a person does anything physical.

  • Before FAT: turn the functional description into test scripts, step by step, with the expected result for each. Check the program against the I/O list and flag anything missing either way.
  • I/O checkout: generate the loop check sheets from the I/O list. With a read only connection, the agent can log what each input really did as a technician operates it, so the sheet is filled in from data, not from memory.
  • During SAT: keep the punch list. Paste in notes from the day and ask for them sorted by area, owner and severity.
  • Handover: draft the as built description, the alarm list and the operator notes from the final program, then compare the final program against the FAT version so every change is accounted for.

A person still strokes the valves, forces nothing without a permit, and signs the sheets. The agent's job is to make sure nothing is missed and everything is written down.

The limits, honestly

Never let it write to a live machine

An AI should never download to a PLC, write a tag, force an input or make an online edit on a running machine. Not "carefully", not "just this once". Changes go through your normal route: offline, reviewed, tested on a simulator, approved, and downloaded by a competent person who knows what will move.

Safety systems and the standards

Emergency stops, guard interlocks, light curtains and safety PLCs are a different world, and AI should stay well away from writing them.

  • IEC 61508 is the main standard for the functional safety of electrical, electronic and programmable systems, rated SIL 1 to SIL 4. Its software part sorts the tools used to build safety software into classes. A tool whose output ends up in the running code, such as a compiler or a code generator, is the strictest class, T3. It needs evidence that it does what its specification says, and each new version has to be qualified again. That's an interpretation, not a ruling, but an AI that can give a different answer every time would be very hard to qualify that way.
  • ISO 13849-1, updated in 2023, covers the safety related parts of machine control systems, rated from performance level a to e. For safety application software it expects a V model, where every design step has a matching test, plus code review and functional testing.
  • The EU Machinery Regulation (EU) 2023/1230 replaces the Machinery Directive and applies from 20 January 2027. Safety components whose behaviour evolves through machine learning need an independent notified body, and their control systems must stay within their defined task, record their safety decisions and stay correctable. Every machine's safety software and data must be protected against accidental or deliberate corruption, with changes logged. It doesn't apply in Great Britain, which keeps its own 2008 machinery regulations, but it does apply in Northern Ireland.
  • The EU AI Act treats AI used as a safety component of machinery as high risk. A July 2026 amendment moved those rules for machines into the Machinery Regulation and pushed the dates back to August 2028.

The agencies agree. In December 2025, CISA, the UK's National Cyber Security Centre and other national agencies published joint principles for AI in operational technology. Their line on safety is blunt: "LLMs almost certainly should not be used to make safety decisions". An LLM, a large language model, is the technology behind Claude and ChatGPT. They add that people stay responsible for functional safety, and that AI shouldn't control anything without a person in the loop.

OT network security

OT, operational technology, is the plant side of IT: PLCs, drives, HMIs and SCADA. Much of it was built to be trusted, not defended, so the network around it does the defending.

  • ISA/IEC 62443 is the main series of standards for securing industrial automation and control systems. It splits a plant into zones, groups of equipment that share a level of risk, and conduits, the controlled links between them. An AI connection is a new conduit, so treat it like one: risk assessed, written down and as narrow as you can make it.
  • Never expose a PLC to the internet. From November 2023, attackers linked to Iran's Revolutionary Guard took over at least 75 Unitronics devices, 34 of them in the US water sector. CISA says they logged in to devices facing the internet that had default passwords or none, and left a message on the screens. CISA's first advice for OT now is simply to remove its connections to the public internet.
  • Read only first, and for a long time. Read from a historian or a gateway in the DMZ, the buffer network between office and plant, not from the controllers themselves, and use an account that can't write.
  • Watch for prompt injection. An agent that reads outside content can be tricked by instructions hidden inside it, in a document, a web page or even a tag description. Anthropic's own documentation warns about this with MCP servers. It's one more reason an agent on a plant must have no way to write.

Faults the sensors can't see

The AI only knows what's in the tags. It can't hear a bearing, smell a hot motor, feel a loose terminal or see a belt slipping on its pulley. Plenty of faults never show up in the data at all, or show up as something else, like a "jam" that's really a worn guide. The data narrows the search. A person on the floor finishes it.

Old kit with no network

Lots of plants still run controllers with no Ethernet, or programs that only exist on a floppy disk, a printout or an old laptop nobody dares switch off. An agent can still help with what you can get as text: a printout photographed and read, a converted file, a manual. But there's nothing live to connect to, and an old program that can't be exported and tested is one to treat with extra care.

Who's accountable

The AI isn't a competent person and it can't sign anything. The engineer who accepts a change, and the company that ships the machine, carry the responsibility, exactly as they would if the code came from a junior or a forum post. Under the EU Machinery Regulation the manufacturer must make sure the machine meets the safety requirements, and anyone who substantially modifies a machine is treated as its manufacturer. That catches integrators and maintenance teams, not just machine builders.

In the UK, HSE said in June 2026 that health and safety law applies whatever technology is used, and that whoever creates a risk has to manage it. "The AI wrote it" isn't a defence. Write down what was AI assisted and who checked it.

It can be confidently wrong

It will sometimes invent an instruction that doesn't exist, mix up Siemens and Rockwell timer behaviour, or tell you a rung does something it doesn't, in the same confident tone it uses when it's right. That's why every guide above ends with a test or a person checking. Treat it like a fast, well read new starter: brilliant at the legwork, never trusted alone on anything that moves.

Where the industry is heading

These are predictions, not facts. But the makers' announcements and the surveys point the same way.

Rockwell's 2026 State of Smart Manufacturing report, from 1,560 manufacturers in 17 countries, found 34% of operations already AI augmented, with more than half expected by 2030. Deloitte's 2026 survey found 40% of manufacturers using generative or agentic AI, but only about one use in five scaled up. So most firms are trying it and few have it in their everyday work yet.

The makers' copilots have already become agents. In 2024 they wrote and explained code. In 2026 Siemens, Rockwell and Beckhoff are all selling or announcing agents that carry out whole engineering tasks. Next, expect them to take a spec, generate the project, test it on a virtual controller and hand over a report, with the engineer approving each step.

Agents get read only access to whole plants. OPC UA already describes a plant in a way software can explore, and MCP gives agents a standard way in. Joining the two, behind proper security, is the obvious next step, and people are already building it. The first sites to do it well will fault find faster.

PLC work starts to look more like software work. Text exports, Git, automated tests and code review are normal in IT and patchy in OT. Agents need them to work well, so they'll spread. That's good news on its own.

Teams get smaller and the work changes. A lot of the typing is likely to go. The engineer's day moves towards writing a clear spec, reviewing what comes back, testing it hard and taking responsibility for it. A small team will deliver what a big one does today.

The regulators catch up. The EU Machinery Regulation is already written with software and learning systems in mind. Expect more of that, and expect customers to ask how you used AI on their job.

The skills that stay human

The hands on skills AI can't do for you are making it safe, reading the drawing, using the meter, the breakdown and commissioning a machine. And one that's new: learning to work with an AI rather than against it.

  • Making it safe. Isolating and locking off, judging the risk, deciding what's safe enough and signing it off.
  • Reading the drawing. Following a circuit from the PLC card out to the field device, and spotting where the drawing and the panel disagree.
  • Using the meter. Proving what's really there, not what the tag says is there.
  • The breakdown. Getting a stopped line running again in the middle of the night, with the operator at your shoulder and the clock ticking.
  • Commissioning a machine. Stroking every valve, checking every loop and standing behind what you hand over.
  • Working with an AI, not against it. Knowing what to hand over, writing a clear brief, checking what comes back and spotting when it's wrong. You can't check what you don't understand, so the basics matter more, not less.

Under all of that sit knowing the process, talking to the people who run it, and owning the result. Someone's name goes on the change, and it won't be the AI's.

That's the honest end of the argument. AI will take a lot of the typing and the reading. It won't take the person who makes it safe, proves it with a meter and gets the line running again. If you're learning, don't let anyone tell you PLC skills are about to be worthless. The people who'll do best know the craft well enough to direct and check an AI, and that takes real practice.

Practise the part AI can't do for you

That's where PLC Gym fits. It runs in a web browser on PLC Gym's own simulator, with working 3D machines, and automatic tests check your code scan by scan. The Review the AI missions train exactly the reviewing skill above. And if you've had an agent write some SCL, Structured Text or an L5X, you can test PLC code by importing it, wiring its tags to a 3D machine and pressing Run, before it goes anywhere near a real one. That's on Pro.

PLC Gym has limits too. It isn't a real controller, it doesn't connect to real I/O, and it isn't made by or affiliated with Siemens, Rockwell, Beckhoff or Anthropic. It practises the PLC side on working machines, but it won't teach you to use a meter, read a drawing or isolate a machine. Those still come from time on site beside an experienced engineer. For more on simulating Siemens code properly, read the TIA Portal simulation guide. If text code is new to you, start with Structured Text programming.

Frequently asked questions

Can AI write PLC code?

Yes. Today's AI can write working Structured Text, SCL and ladder logic in its text form, and an agent like Claude Code can also write the tests that check it. It can't know your machine, so treat its code like a new starter's: reviewed, tested on a simulator and approved by a competent person before it goes near a real one.

Can AI write ladder logic?

Yes, but AI works in text and ladder is drawn. Rockwell exports rungs as plain text inside L5X files, which an agent reads and writes well. Siemens exports ladder as XML, which is harder going. Most engineers find AI strongest in Structured Text and SCL, and keep ladder for where the site standard asks for it.

What is Claude Code?

Anthropic's AI coding agent. It runs on your own computer, reads and edits the files in a folder you choose, and runs commands such as scripts and tests, asking your permission as it goes. It wasn't made for PLCs, but it can work on any PLC project exported as text.

Is Claude Code better than ChatGPT for PLC programming?

Which one leads changes every few months, so judge them on a real job from your own site. The bigger difference is agent against chatbot. An agent works on the whole exported project with real tools, while a chat window only sees what you paste into it.

Can AI do PLC troubleshooting?

It can do a lot of the legwork. Given alarm logs, historian trends and the program, an agent can build a timeline, spot patterns across weeks of data and find the code behind an alarm. It can't see, hear or touch the machine, so a person still makes it safe, goes and looks, and decides what the fault really is.

What is an MCP server for a PLC?

A small program that gives an AI agent a fixed set of tools, such as "read these tags" or "get this trend", usually through OPC UA, SCADA or a historian. MCP is the open standard for those tools. The agent can only do what the tools allow, so a well built one only reads.

Is it safe to connect AI to a PLC?

Not directly. Connect it to a read only source such as an OPC UA gateway, SCADA or a historian, using an account that can't write, with the tags set read only and the network locked down. Never give an AI a way to write, force or download, and get your site's approval first.

Will AI replace PLC programmers?

Unlikely, but it is changing the job. Much of the typing goes, and the work moves towards specifying, reviewing, testing and taking responsibility. People who understand PLCs well enough to direct and check an AI should be in more demand, not less. Safety sign off and hands on work stay with people.

Does Siemens have AI for TIA Portal?

Yes. Siemens announced its Industrial Copilot for TIA Portal in 2024, to generate and explain SCL. Since April 2026 it has sold the Eigen Engineering Agent, which Siemens says plans and carries out engineering tasks inside TIA Portal V19 and later.

Does Rockwell have AI for Studio 5000?

So far it lives mainly in FactoryTalk Design Studio, Rockwell's cloud engineering tool, where a Copilot writes and explains code from plain language. FactoryTalk Conductor, announced in October 2026, will coordinate AI agents across Studio 5000 Logix Designer and other tools from early 2027.

What is TwinCAT Chat?

It's Beckhoff's AI assistant inside TwinCAT engineering, launched in 2023, which writes, extends and documents PLC code from a chat window linked to the project. In 2026 Beckhoff added TwinCAT 3 CoAgent for Engineering, which works with several AI providers or a local model.

Can I use AI on safety PLC code?

Use it to read, explain and document, if your process allows it. Writing or changing safety code is different. Safety functions are developed under standards such as IEC 61508 and ISO 13849, with strict rules on how software is specified, verified and validated. Any AI involvement has to fit that process, and a competent person stays responsible.

Will my company's code be sent to the cloud?

By default, yes. Claude Code sends what it reads to Anthropic to be processed. For business plans, Anthropic says it doesn't train on your code unless you opt in and keeps data for 30 days as standard, and qualifying Enterprise accounts can have zero data retention. It can also run through Amazon Bedrock or Google Cloud. Check with IT and your customer contracts first.

How much does Claude Code cost?

It comes with Anthropic's paid Claude plans rather than being sold on its own, and there are business plans for teams. Prices and usage limits change, so check Anthropic's pricing page, linked in the sources.

Do I need to know Python to use AI for PLC work?

No. You can ask Claude Code in plain English to review a program, document a machine or draft an I/O list. Python helps for crunching historian data or building a read only connection, and the agent can write most of that too, but you still need to understand what it's doing.

Which PLC languages does AI handle best?

Text languages, by a distance: Structured Text, Siemens SCL and Rockwell's rung text in L5X files. Graphical languages such as function block diagram and sequential function charts export as XML, which an agent can read but finds harder to write cleanly. If you want AI help with new code, text is the easy route.

Can AI help with old PLCs like the S5 or PLC-5?

Yes, with documenting and understanding them, if you can get the program out as text or even a printout. There's usually nothing live to connect to, so the documentation guide above is where AI helps most. Be extra careful with any change: old hardware is hard to test and harder to replace.

Does the EU Machinery Regulation stop you using AI?

No. It applies from 20 January 2027 and doesn't ban AI as an engineering tool. It adds rules for safety components that use machine learning to change their behaviour, which need an independent notified body, and it requires safety software to be protected against corruption, with changes logged. It doesn't apply in Great Britain, but it does in Northern Ireland.

Can AI write HMI alarm texts?

Yes, and it's one of the quickest wins. Give it the alarm list, the tag names and your house style, and it drafts clear texts that say what happened and what to do. An operator and an engineer should still read every one, because a wrong alarm text sends people to the wrong place at three in the morning.

How do I start using AI for PLC work next week?

Get permission, then pick a job where nothing touches the plant. Export one program you know well, put it in a folder on an office laptop, and ask Claude Code to explain it and draft its documentation. Check what comes back against what you know. You'll learn quickly what it's good at, and where it needs watching.

Can beginners learn PLC programming with AI?

They can use it as a tutor, but it's a poor shortcut. If AI writes all your code, you never learn to spot when it's wrong, and spotting that is the job. Learn the basics by doing them yourself on a simulator, then use AI to explain things and check your work, not to do it for you.

Sources

Claude Code and MCP

Reading plant data

Getting projects out as text

The makers' AI

Safety, security and regulation

Industry surveys

Questions about this?Ask in the Locker Room

Try it on a machine

Free · Runs in your browser

Try it on a working machine

Write real Siemens or Rockwell code in the free online PLC simulator and watch a 3D pump, tank or filling line do exactly what you told it. Nothing to install.