AI Code Generation and NodeRed

I have been working with NodeRed for while and found that I could generate flows using ChatGPT. This was useful and sped things up. It got me to wondering, how far could I get with this.

ChatGPT was somewhat suboptimal, Grok, not much better. Experimentation led me to believe that Claude was noticeably better at many things. The big problem was the endless cutting an pasting. That was really slowing things down.

So I used ClaudeChat to bootstrap a system which used Anthropic's API to generate code. It was a miserable failure for various reasons. I gave up on that approach and switched to Claude Code, that worked much better. Basically I gave Claude Code control over node red, and the ability to push out code to remote node red servers via MQTT. This allowed me to control and write code for many different servers/projects. There was a need to develop memory for Claude Code, store style requirements, quirks etc.

So now the development process becomes... I explain the needs to Claude Chat. Claude chat then asks questions, clarifies issues etc. and generates development specifications. Those specifications are fed to Claude Code which creates the flows and pushes them out to the appropriate sever. I can then test, make modifications, debug etc. The volume of code generated this way is orders of magnitude greater than I could create by hand. The quality is reasonable, to be honest the html ui, far better. And using node-red allows me to organize into projects, tabs, subflows etc. I have a good visual picture of how things are laid out and if there is a problem, it's easy to drill down and actually inspect code/messages etc.

On a good day you go bla bla, it makes your working flows. On a bad day it screws up makes nodered unusable and you spend tokens having it fix the problem it created. More good days than bad though.

1 Like

Yep it is pretty amazing how far and how quickly these engines have come.

Whenever they screw up something i always ask will i get my token supply back for that and all you get is some form of bashful apology - never a token bump !

What you have done would be worth a write up for newer people to AI and NR - if you have a time to put together a step by step guide

Craig

1 Like

@nodeautomata ... I've had similar experience using ClaudeChat but have not had the guts to use ClaudeCode and let it push changes to my NR servers :slight_smile:

I'm content in having Claude give me a good start on nodes/flow/functions

1 Like

Eventually it got to the point where the bulk of my time was spent copying and pasting and patching, frequently getting things wrong in the process. It was really slowing things down and probably taking up the bulk of the time.

I can develop on the local test machine and then push the changes out to the production machine when they have been reviewed and found to be working properly. I also built in a checkpoint system so I could reverse changes. Worst thing so far was a bug which ran the load up to 99% and make nodered inaccessible and I don't need AI to do that, I've done it all by myself.

After creating a sizable real world application I have a fair amount of confidence in the system being able to produce a reliable product provided the operator kind of knows what they are doing and pays attention.

Basically the same issues you run into hiring a random person from upwork.

I spent a lot of time having Claude Chat create an installer which basically sets the whole thing up. I used some techniques like having the Claudes embed massive amounts of comments which explain how things work, why they were done etc. The theory was that in a loss of context issue AI could read the code itself and regenerate the context.

Installers tend to be one of those last minute things people throw together at the end. Given massive coding capability I burned a big chunk of the tokens trying to create one that was comprehensive and easy to use. Two shell scripts, one for client, one for server, it sets up all the dependencies, users, passwords etc. Somewhere there is a matching pile of documentation. Unfortunately I have a bunch of other projects going on so this doesn't get the attention it deserves.

I've created an AI chat sidebar for Node-RED that works directly inside the editor and lets you interact with your flows using OpenAI or Anthropic .
link to my post

1 Like