How to better organize complex scripts so they don't get crazy messy?

One thing not mentioned so far that helped me a lot, is to create “file-referenced” clusters (alternatively use hops, but I find it less easy to work with).
Those .ghclusters files can be edited once only and you can then easily propagate your fixes/changes for a certain functionality.
That’s useful when some clusters are often re-used, and are not all at the same “nesting” level.
For example your block would be once at root level, and once inside another block.

For example, let’s say you have a block of components that you need that more than once, I would suggest doing the following :

  1. Clusterize those components. Before doing so you can create small wire relays at your input / output locations. By doing so you can easily give names to your IOs.
  2. Selecting all components from your block, but not the wire relays, mouse middle click → cluster
  3. Enter your cluster just created, name your cluster inputs and outputs properly (you’ll thank yourself later).
  4. Save the cluster and go back to parent
  5. Right click on the cluster, fill-in properties (again, you’ll thank yourself later)
  6. Finally, right click again, and save & reference file.

If you have nested clusters, and blocks being re-used at different nesting levels, that’s super practical.

Because the files are referenced on your file system, it allows you to manage the clusters separately and propagate your changes quite easily. If you have such a case, I can recommend this post that provides a one-click solution to update your clusters automatically and recursively.

Hope this helps, don’t hesitate if you have questions.

All the best