Skip to content
Chapter one

Chapter oneAI dev tools, industrial

PLCcode.ai

I built the AI chat that reads and edits ladder logic, then spent months making sure it only reports an edit once the save has actually landed.

Role
Full Stack Engineer
Timeline
Mar 2026 to present
Public launch
Oct 2, 2026
Team
Small team

AI tools for controls engineers: browser-based PLC programming, version control, and live equipment access. Publicly launched October 2, 2026.

起 (Opening)01 / The problem

Ladder logic runs real machines. The AI editing it can't bluff.

PLCcode.ai is AI tooling for controls engineers: browser-based PLC programming, version control, and live equipment access. Put a chat model in the middle of that and a confident "done" that isn't true stops being a bug. It's a safety problem.

The public PLCcode.ai homepage. Headline reads: PLCs run the world.
plccode.ai, live

承 (Development)02 / What I built

The AI chat that reads and edits ladder logic, in the browser.

I joined as Full Stack Engineer in March 2026. I built PLC Chat and the retrieval behind it, wrote the rung checker, contributed to GitPLC version control, and moved the platform onto self-hosted Kubernetes. It went public with the rest of the product on October 2, 2026.

転 (Turn)03 / The hard part

44,362 to 13

False positives from my rung checker

Writing the edit was one job. Telling the truth about it was the real one.

The AI was faking edits and reporting success. I put a server-side field policy on both write paths, then built a rung checker I could trust by grinding its false alarms down until a warning meant something.

結 (Outcome)04 / The result

0

rungs lost across 4,966 in three tested projects. Loss used to be 90.8%.

Checker false positives
44,362 to 13
Recall@10, synthetic eval
0.675 to 0.897
Public since
Oct 2, 2026
数字 (Numbers)

By the numbers

  • 0rungs lost across 4,966 in three tested projects (was 90.8%)
  • 44,362 → 13false positives from my rung checker on a 3,137-rung project
  • 0.675 → 0.897retrieval recall@10 on a synthetic eval set
  • 65 sfrom a save to searchable, in one staging test
  • Oct 2public launch, on the Kubernetes platform I moved us onto
仕組み (How it works)

How it works

The product is the team's. This is the shape of it at the level the public site describes, with my parts in red: the AI chat and its agent pipeline, the retrieval service, and the Kubernetes platform underneath. GitPLC is dashed because I contributed to it.

  • Built by me
  • I contributed
  • Platform, team or vendor
Fig. 1PLCcode.ai at the level of the public site. Red is what I built; dashed is GitPLC, which I contributed to with the team. Edits only count as applied once the save comes back OK, and every save re-indexes the changed file.

01THE AI CHAT

An AI that edits industrial code and owns up to it.

The people using PLCcode.ai write the logic that runs real machines. So the AI in the middle of it can't be a toy, and it definitely can't bluff.

I built PLC Chat from scratch: a project-aware assistant that reads your tags, routines, rungs and uploaded manuals, cites where its answers come from, and keeps its history. Then I grew it into a multi-stage agent. Every request runs a visible pipeline (cleaner, orchestrator, coder, reviewer), each stage can run on its own model, local or cloud, and the reviewer checks proposed edits on the server before anything touches the project.

Around launch I rebuilt it to work like Claude Code. In Edit mode each change lands in the open editor as the AI makes it, long jobs like "comment this whole program" finish without anyone mashing Continue, and when it's unsure it asks a clarifying question with clickable answers. It runs on a self-hosted coding model or on cloud models, with a live model switcher.

CONTEXT, CACHING, TOOLS

  • Long chats stay coherent: model-aware token budgeting, history trimming that never splits a tool call from its result, rolling summary compaction, and a live meter showing how full the context window is.
  • Reordered the prompt so the stable prefix comes first. In a two-request test against the self-hosted model, the second turn's prefix-cache hit rate went from 0% to 98%.
  • Added guided tool-calling for the self-hosted model and measured it in Langfuse: native tool calls went from 0 of 10 to 7 of 10 on the eval set.
  • Rewrote the read loop to buffer the answer and filter leaked tool-call JSON out before it reaches the user, and load a heavy tool family only when the conversation needs it.

正直 (Honesty)The hard part

The AI was faking edits. Ask it to alias a tag and it made a plain tag with "alias" written in the description, then reported success. On control code, a confident "done" that isn't true is a safety problem. I put a per-operation field policy on both write paths (unknown fields get rejected, not silently dropped), a capability guard, and previews that only show what will actually persist. "Applied" now only appears after the save comes back OK, stale plans get refused instead of overwriting newer rungs, and read-only modes are enforced on the server. Then I built the missing operations properly: alias tags, AOI parameters, UDT members and renames.

02GITPLC

Version control for ladder logic.

GitPLC is our version control layer on self-hosted Gitea: a GitHub Desktop-style Source Control panel for PLC projects, with commit, history, revert, branches, stash, pull and pull requests. I didn't build it from scratch. I contributed to it alongside the team, mostly on the pieces below.

I wrote a shared ladder renderer used by both the IDE and the Gitea web UI, so ladder files show up as actual ladder diagrams with rung-by-rung diffs instead of walls of XML. AI edits persist at the end of each turn, so whatever the chat changed shows up in Source Control right away, with a visual ladder diff.

Then "Update from Studio 5000". Engineers keep working in Rockwell's own tool, so I built a re-import that brings a newer L5X or L5K export into the same project as a single git commit. I built it first as a three-way merge. Then the product call came in, and it was the better one: Studio is the source of truth. So the update now replaces the project's PLC code with Studio's files exactly and removes PLC files Studio no longer has, while notes, docs and generated artifacts are never touched. Before you apply, a warning lists every PLCcode edit about to be replaced, a file from a different controller gets refused, and git is the undo.

難所 (Hard part)The hard part

Keeping a browser workspace in sync with git across collaborators. Fetch never detected anything, because the "local" head came from the same remote call it was compared against. I split out a separate workspace head and persisted it on the server, so sync finally had a real anchor. Later I moved teammates onto per-user working copies so nobody edits the same copy, and cut opening a project from 8 or more git fetches to 2.

03ROUND-TRIP EDITOR

If it doesn't round-trip, it doesn't ship.

Engineers export back to Rockwell Studio 5000 to run the code on real hardware. If an export quietly drops a rung, the product is dead. So I treated fidelity as the job, not a nice-to-have.

AI edits used to lose operand members and mangle AOI calls. I rebuilt the rung round trip and took loss from 90.8% to 0 across 4,966 rungs in three real projects I tested on. Tag edits got surgical too: adding two tags used to rewrite the whole tag file and drop addresses. Now only the touched entries change, and the preview and the applied file are byte-identical.

I checked the converter with a round-trip harness on five real vendor files (493 routines, 9,189 rungs, 1,298 tags) and got zero delta on all of them, shipped L5X export for AOIs and UDTs that Studio 5000 actually accepts, and built a rung checker from scratch with a hand-written, error-recovering Structured Text parser. On a real 3,137-rung project I drove its false positives from 44,362 down to 13.

For editor parity I ran a coordinator session with parallel workers. A "rig" session executed scripted cases on real Studio 5000 (V31 and V37) and recorded the exact behaviour and error text, and fix sessions closed one ticket per mismatch.

難所 (Hard part)The hard part

A real Studio rig beat my own data. A full census of real project files said one AOI attribute was always written. On the rig, writing it on an AOI's EnableIn and EnableOut made Studio 5000 v34 silently delete the whole AOI while the import reported success. The vendor tool owns that attribute. Since then the rule is simple: the vendor tool is the source of truth, not the corpus.

04RAG

The index that was frozen in time.

I built the retrieval service behind the chat from zero (Haystack, Qdrant, an embedding server and a cross-encoder reranker). Before tuning anything I built an eval harness, so every retrieval change had to beat a locked baseline. Hybrid BM25 plus dense search with rank fusion took recall@10 from 0.675 to 0.897 on a synthetic, model-labelled eval set. The reranker deliberately trades a little recall for an abstention guard, so the bot says "not found" instead of making something up.

Small embedding models are bad at XML, so I wrote a deterministic parser that turns raw Rockwell L5X into readable canonical text before embedding. One project went from thousands of raw XML chunks to about a hundred readable ones.

Then I found the scary part. The embeddings came only from the original import. Every edit after that, by the user or by the AI itself, was invisible to retrieval, and the chat kept answering confidently from code that no longer existed. RAG was frozen in time at import.

I fixed it in stages. First re-index on commit, then on every save and discard, with incremental re-embedding keyed on a hash of each chunk's text, so a one-rung edit re-embeds 2 chunks instead of the whole project. Chat now says when its index is behind and reads the file directly instead. The final version is a per-file incremental index: content hashes on every vector, rate caps, a job that runs a minute after the last write, and query-time filtering that drops any chunk whose hash no longer matches the live file. On staging, a save was searchable 65 seconds later.

RETRIEVAL QUALITY

  • Went from 10 rungs per chunk to one chunk per rung with a controller, program and routine breadcrumb, plus a deterministic summary chunk per routine. The overlap between relevant and off-topic scores shrank from 0.193 to 0.022 on the same 16 queries.
  • Traced an index that silently doubled itself to writers and readers using two different document ids, after my own first fix turned out to be wrong. The bug had survived 13 unit tests because the fake store accepted any id list.

難所 (Hard part)The hard part

Nothing reported this bug. Retrieval returned plausible, well-formed, wrong logic. The fix that mattered most was structural: re-indexing hooks into the "working copy moved" contract instead of a list of writers, so a writer someone adds next year can't quietly reopen the gap.

05INTEGRATIONS

Wired to the plant floor.

Live equipment access means remote desktop to a machine on a plant floor, straight from the browser. Sessions hung at "Waiting for Agent" because the agent's relay connection didn't survive the CDN proxy, so I gave agents a direct path while keeping downloads and the viewer on the public origin. I shipped the first Windows build of the remote-access agent in six releases and fixed the Linux install end to end, then verified on real machines: install, one-code enrollment, EtherNet/IP, S7, Modbus TCP and OPC UA drivers, and remote control from the web app. Later I brought it up end to end on production.

Single sign-on runs on Keycloak across the app, the embedded Git server and remote access. Inside iframes, third-party cookie blocking broke OAuth, so the fix was establishing both sessions in one chained login. For support I built admin impersonation with guardrails: every write audited and a banner that never goes away.

難所 (Hard part)The hard part

Every one of these only failed on real hardware or real accounts. One session report's headline claim about the agent turned out wrong on a real machine, and I corrected the record instead of leaving it. Same theme as the rest of this project: test the thing itself.

06PLATFORM

The site said 200. The cluster was dead.

I moved the platform off a single box onto self-hosted Kubernetes with Fleet GitOps, sealed secrets, cert-manager and backups, in a five-phase migration with live beta users on it. That grew into the production and staging clusters I ran releases on through launch.

Then the quiet one. Production's Kubernetes API had been down for about two days and nothing alerted. The apps kept returning 200 because running pods keep running, so the site looked healthy while nothing could deploy or self-heal. The cause: synchronized VM snapshot backups froze all three etcd members at the same moment, 48 quorum disruptions a day since the cluster was built.

Before touching anything I took verified cold backups of every member plus full VM snapshots. Then I reset the cluster from the member with the most recent log, fixed the backup schedule at the source, and built an off-cluster heartbeat. That heartbeat reported OK in three states where the cluster was actually broken, so I fixed the watcher too.

ALSO ON MY PLATE

  • A fail-closed rollback gate, after measuring that 10 of 17 historic production image tags would crash-loop on rollback because of forward-only database migrations.
  • Unified four project-authorization paths into one chokepoint and took a 35-item backend audit to zero open items.
  • Moved production databases to a highly available Postgres cluster: 5 databases, every table count matching, after a first attempt I rolled back cleanly when the copy stream dropped.

難所 (Hard part)The hard part

Green dashboards lie. The lesson kept showing up in different costumes: the AI's confident "done", the index that answered from old code, the rollback that was always "possible" but often fatal, the heartbeat that said OK. So I measure the thing itself.

07INFRASTRUCTURE

Building the network it all runs on.

PLCcode.ai doesn't run in someone else's cloud. It runs on a rack of our own servers, split into separate network zones so internal tools, production and anything public-facing stay apart. Our lead designed that layout. I spent a big chunk of 2026 inside it with my hands dirty: the Kubernetes platform the product ships on, a staging cluster built from an empty folder, self-hosted object storage and database backups with a tested restore, and helping build the shared services each zone runs on.

The biggest piece was moving the team onto zero-trust access: everyone on their own single sign-on identity, least-privilege policies instead of allow-everything defaults, and a verification script that checks the expected paths work and fails loudly if a door that should be shut is open. It passed all 15 of its checks, including 5 negative controls.

I cleaned up as much as I built: DNS issues that were quietly breaking internal services, a credential audit, and secrets split so each zone only holds its own. When we consolidated production onto fewer servers, I wrote and ran the power-off test that proved it.

難所 (Hard part)The hard part

A review, not a build. A setup script looked fine and would have shipped. Reading it line by line, I found an ordering problem that could have left a machine less protected than intended after a reboot, with nothing to alert anyone. Catching that before it ran on real hardware was worth more than anything I typed that week.

流儀 (Method)

How I work

I orchestrate AI coding agents.

On PLCcode.ai I ran a command tower: one session holds the spec and the plan, worker agents build in their own git worktrees, and I re-verify every gate myself before anything merges. It's how one engineer on a small team shipped this much without taking an agent's word for it, and it's the skill I'm proudest of.

  1. 設計 (Design)

    Spec first

    Nothing gets built off a vibe. I write the spec and the plan before any code, with the tradeoffs and the "if this is wrong" assumptions spelled out, so every agent works from the same contract.

  2. 並列 (Parallel)

    Agents in lanes

    I run AI coding agents in parallel, each in its own lane or git worktree with files it owns. They don't share a brain, so they share rules: who owns what, how to ask for a change, how to hand off.

  3. 検証 (Verification)

    Verify independently

    An agent saying "done" is a claim, not evidence. I re-run the gates myself against the repo, the database and the live app, and I point adversarial reviewers at the work to try to break it before it lands.

  4. 判断 (Judgment)

    I make the calls

    Taste, product calls and root-cause verdicts stay with me. The agents are fast. I'm the one accountable for what ships, so nothing ships that I haven't checked.

実例 (Real examples)On this project

  • Studio 5000 parity: a coordinator session, a "rig" session running scripted cases on real Studio 5000 V31 and V37, and fix sessions shipping one ticket per mismatch.
  • A 35-item backend audit run as a command center. Parallel agents made the fixes, and every row was closed against the repo, the database and CI, never against an agent's own report.
  • Bigger designs, like per-chat retrieval scoping, went out as a written plan (5 packets, 31 tasks) and ran in parallel worktrees.
  • Adversarial review before merge: a six-lens review of the streaming leak filter found 14 real findings, mostly new shapes of the same bug class that had made the first version flaky.
技術 (Technology)

What it's built on

01 / APP

画面 (Screen)
  • Next.js
  • React
  • TypeScript
  • Jotai
  • Monaco
  • React Flow (xyflow)
  • Drizzle ORM
  • Auth.js
  • Vercel AI SDK

02 / AI AND RAG

頭脳 (Brain)
  • Claude
  • Self-hosted coding model
  • vLLM
  • Haystack
  • Qdrant
  • BM25 + RRF hybrid
  • Cross-encoder reranker
  • Langfuse

03 / BACKEND

裏方 (Backstage)
  • Python
  • FastAPI
  • PostgreSQL (Patroni / Autobase)
  • Redis
  • Gitea
  • Keycloak SSO
  • MinIO
  • Collabora
  • MeshCentral

04 / DATA AND BACKUPS

保存 (Storage)
  • S3 object storage
  • pgBackRest
  • Velero
  • MinIO

05 / PLATFORM

基盤 (Foundation)
  • Kubernetes
  • Fleet GitOps
  • Traefik
  • cert-manager
  • Sealed Secrets
  • Velero
  • NFS CSI
  • Prometheus
  • Grafana
  • Loki + Alloy
  • Blackbox exporter
  • GitHub Actions

Contents第一話 (Chapter one) PLCcode.ai