Claude's ugly code
-
-
@David-Healey said in Claude's ugly code:
This is some code Claude gave me
if (key == "midi" && isDefined(data.midi)) ma.setAutomationDataFromObject(data.midi); else if (key == "macro" && isDefined(data.macro)) mh.setMacroDataFromObject(data.macro);This is how I would write it
if (!isDefined(data) || !isDefined(data[key])) return; if (key == "midi") ma.setAutomationDataFromObject(data[key]); else mh.setMacroDataFromObject(data[key]);Just sayin
Hey Claude, please update your behaviour to script more like @David-Healey . Don't make any mistakes this time.
-
@David-Healey You can ask Claude to analyse your previous project styles once for all so it automatically applies it next time
-
@HISEnberg said in Claude's ugly code:
Hey Claude, please update your behaviour to script more like @David-Healey . Don't make any mistakes this time.
Accurate

-
@ustk said in Claude's ugly code:
@David-Healey You can ask Claude to analyze your previous project styles once for all so it automatically applies it next time
Definitely you can, and it often shows up as a big improvement. I find after time that Claude, Codex (probably other agents too) start to "drift" towards their preferred style of coding anyways. They also have a tendency to over-comment and use special characters which HISE doesn't support. Example:
// ── Backend ─────────────────────────────────────────────────────────────Which renders like this:

I also see it drop things in scripts that are outside a namespace, and the namespace does not always match the script's name. Example file:
HiseScriptStandardsForMyAgents.js:namespace ScriptStandards { // Rules for following strict scripting standards inline function iDontFollowTheStandards(); // .... } iDontFollowTheStandards(); // End of HiseScriptStandardsForMyAgents.js:I wonder if more rigid guidelines around the HISE scripting standards in the HISE-MCP would help, but most important caveats are already featured in style-guides.ts and in the guidelines. Seems like Christoph did a bang-up job already and agents just have a tendency to cut corners over time to in order to complete the task.
-
inline function currentFile() { local exp = eh.getCurrentExpansion(); if (!isDefined(exp) || exp == undefined) return undefined; return exp.getRootFolder().getChildFile("myFile.json"); }More horrible script.
Is anyone getting good HISE script output from Claude that doesn't need a ton of cleanup/rewriting?
-
@David-Healey Have you pointed Claude to any of your other repos? Rhapsody, etc.
If you do that, and tell it to use your scripting conventions rather than inventing new ones, it will likely do a better job.
I found Claude usually follows whatever style is already in the repo. Might be my bad code, of course!

Also, genuinely curious - why does it need cleanup/rewriting?
-
@dannytaurus said in Claude's ugly code:
Have you pointed Claude to any of your other repos? Rhapsody, etc.
Do I have to do that for each session? I've done it for some and also pointed it at the HISE docs, style guide, and MCP server.
Usually I'm connecting Claude to the HISE source repo so it can query parts of the codebase that I'm less familiar with and explain how undocumented things are supposed to work.
@dannytaurus said in Claude's ugly code:
Also, genuinely curious - why does it need cleanup/rewriting?
The function name is a bad choice -
currentFile()tells me nothing. A function name should generally be set, get, or do so I know its purpose. In this case I thinkgetCurrentFilemight be better, although it could be more specific than that.!isDefined(exp)is the same asexp == undefinedso the second check in the if statement is redundant. -
@David-Healey You would usually have a CLAUDE.md file in each repo that documents all the conventions used there.
It's loaded in each new session and used throughout that context.
I have more or less the same CLAUDE.md in every HISE project that has HISE conventions, gotchas and resources. And I have a project-specific PROJECT.md with the same, but per project - so things like what this plugin does, what DSP is uses, target audience, etc.
PROJECT.md is referenced in CLAUDE.md so it carries into every session.
-
@dannytaurus ah that makes sense. I'm just getting Claude to help with small little tasks so I haven't gone to the trouble of setting up a remote repo, etc.