Refactoring with AI
Once you have a script dump on disk, you can use an AI assistant to analyze, compare, and refactor your WinCC Unified scripts at scale.
Why this works
In a typical WinCC Unified project, faceplate scripts are written over time by different people. They end up with inconsistent patterns. Refactoring this manually inside TIA Portal is slow because you can only see one script at a time.
With a script dump, you have every script as a plain file on disk. An AI assistant can read all of them at once, compare patterns across faceplates, and produce consistent refactored versions.
Never write refactored scripts into the Dynamics/ or Events/ directories. These are volatile — the proxy clears them on every startup and target change. Any files you save there will be deleted. Always write refactored output to a separate directory.
The workflow
Dump scripts to disk
Start the proxy with --dump and navigate to the screens that contain the faceplates you want to refactor.
./wincc-unified-debug-proxy.exe run --dump scripts -t 192.168.1.100This gives you a complete snapshot of every script running on those screens, organized by faceplate.
Identify a reference module
Pick a faceplate that already follows your desired pattern — this becomes the template for all others.
Let AI compare and refactor
Point the AI at both the reference module and a legacy module. It will identify every difference and produce a refactored version that follows the reference pattern.
Verify and audit across files
After refactoring, ask the AI to search the entire dump for remaining legacy patterns. It can scan all files at once and flag inconsistencies — something that would take much longer to do manually inside TIA Portal.
Copy back to TIA Portal
The refactored scripts need to be manually copied back into TIA Portal — paste them into the correct Events and Dynamics editors for each faceplate.
Limitations
The script dump only contains the JavaScript code. Tag interface bindings and trigger configurations are not part of the dump — you'll need to verify and update those manually in TIA Portal.
Where to put refactored scripts
The dump directories (Dynamics/, Events/) are read-only from your perspective — the proxy owns them and will delete their contents. Save refactored scripts elsewhere:
scripts/
├── Dynamics/ ← proxy writes here (volatile, do not edit)
├── Events/ ← proxy writes here (volatile, do not edit)
├── .eslintrc.json
├── ua_rt_device_V19.d.ts
│
└── refactored/ ← your output goes here
├── FaceplateA/
│ ├── Events.js
│ └── Triggers.js
└── FaceplateB/
├── Events.js
└── Triggers.jsThe ESLint config and type definitions in the parent directory still apply, so you get linting and IntelliSense in the refactored folder too.
Auditing with AI
The real power of having scripts on disk is auditing. Inside TIA Portal, you can only look at one script at a time. With a dump, an AI assistant can search all files at once — finding hardcoded values, inconsistent patterns, unused code, or anything else you ask it to look for.
Point the AI at the entire dump directory and ask questions like:
- "Which faceplates still use hardcoded colors instead of tag references?"
- "Are there any faceplates missing an OnLoaded handler?"
- "Compare these two faceplates and list every difference"
This turns hours of manual review in TIA Portal into a conversation.