← Blog
2026-07-19
Generating SCL code with AI
An LLM writes you an SCL block in seconds. The real question is not whether AI can write code, but how that code gets into the project safely. The answer is a workflow with guardrails.
The workflow
- Specify precisely: interface, behavior, edge cases, naming convention. The more concrete the spec, the less rework. Describe the problem, not the syntax.
- Generate: with the model of your choice. A reasoning model for tricky logic, a fast model for boilerplate, a local model for confidential projects.
- Import: not via copy-paste but over the Openness API, reproducible and traceable.
- Compile: the compile against the real project catches hallucinated calls and type errors before anyone has to debug them.
- Test: SCL unit tests pin down the behavior. Green first, then review, then merge.
What AI is good at
Boilerplate, interfaces, state machines, comments, converting LAD logic to SCL, refactoring existing blocks. Anything with a pattern goes fast.
Where you need to be careful
- Invented system blocks: LLMs occasionally hallucinate calls that do not exist. The compile gate catches that.
- Timing and hardware: assumptions about cycle time, peripherals or alarm behavior are yours to check, not the model's to guess.
- Safety logic: fail-safe logic has no place in LLM output. Generate, yes, but for standard logic only.
Conclusion
AI-generated SCL code is not a risk if the path into the project runs through gates: import over Openness, compile, unit test. That is exactly how the flow in AnyAutomation Studio is built, with a free choice of model including a local option.