Forum
    • Categories
    • Register
    • Login

    Claude's ugly code

    Scheduled Pinned Locked Moved AI discussion
    14 Posts 5 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • David HealeyD
      David Healey
      last edited by

      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

      Free HISE Bootcamp Full Course for beginners.
      YouTube Channel - HISE tutorials
      My Patreon - More HISE tutorials

      ChazroxC dannytaurusD HISEnbergH ustkU 4 Replies Last reply Reply Quote 3
      • ChazroxC
        Chazrox @David Healey
        last edited by

        @David-Healey said in Claude's ugly code:

        This is how I would write it

        scrape THAT! haha.

        1 Reply Last reply Reply Quote 1
        • dannytaurusD
          dannytaurus @David Healey
          last edited by

          @David-Healey Depends who (or what) is more likely to be reading the code in the future I guess.

          Meat Beats: https://meatbeats.com
          Klippr Video: https://klippr.video

          ChazroxC 1 Reply Last reply Reply Quote 0
          • ChazroxC
            Chazrox @dannytaurus
            last edited by Chazrox

            @dannytaurus the first time I heard the term 'human-readable' gave me the heebee geebeez. lol

            Who else is reading?...😨 lmaoo

            dannytaurusD 1 Reply Last reply Reply Quote 1
            • dannytaurusD
              dannytaurus @Chazrox
              last edited by

              @Chazrox 😂

              Meat Beats: https://meatbeats.com
              Klippr Video: https://klippr.video

              1 Reply Last reply Reply Quote 0
              • HISEnbergH
                HISEnberg @David Healey
                last edited by

                @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.

                Sonic Architect && Software Mercenary

                ChazroxC 1 Reply Last reply Reply Quote 3
                • ustkU
                  ustk @David Healey
                  last edited by

                  @David-Healey You can ask Claude to analyse your previous project styles once for all so it automatically applies it next time

                  Hise made me an F5 dude, any other app just suffers...

                  HISEnbergH 1 Reply Last reply Reply Quote 3
                  • ChazroxC
                    Chazrox @HISEnberg
                    last edited by

                    @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 🤣

                    1 Reply Last reply Reply Quote 1
                    • HISEnbergH
                      HISEnberg @ustk
                      last edited by HISEnberg

                      @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:
                      Screenshot 2026-07-12 at 1.04.27 PM.png

                      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.

                      Sonic Architect && Software Mercenary

                      David HealeyD 1 Reply Last reply Reply Quote 0
                      • David HealeyD
                        David Healey @HISEnberg
                        last edited by

                        	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?

                        Free HISE Bootcamp Full Course for beginners.
                        YouTube Channel - HISE tutorials
                        My Patreon - More HISE tutorials

                        dannytaurusD 1 Reply Last reply Reply Quote 0
                        • dannytaurusD
                          dannytaurus @David Healey
                          last edited by dannytaurus

                          @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?

                          Meat Beats: https://meatbeats.com
                          Klippr Video: https://klippr.video

                          David HealeyD 1 Reply Last reply Reply Quote 1
                          • David HealeyD
                            David Healey @dannytaurus
                            last edited by

                            @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 think getCurrentFile might be better, although it could be more specific than that.

                            !isDefined(exp) is the same as exp == undefined so the second check in the if statement is redundant.

                            Free HISE Bootcamp Full Course for beginners.
                            YouTube Channel - HISE tutorials
                            My Patreon - More HISE tutorials

                            dannytaurusD 1 Reply Last reply Reply Quote 0
                            • dannytaurusD
                              dannytaurus @David Healey
                              last edited by dannytaurus

                              @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.

                              Meat Beats: https://meatbeats.com
                              Klippr Video: https://klippr.video

                              David HealeyD 1 Reply Last reply Reply Quote 1
                              • David HealeyD
                                David Healey @dannytaurus
                                last edited by

                                @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.

                                Free HISE Bootcamp Full Course for beginners.
                                YouTube Channel - HISE tutorials
                                My Patreon - More HISE tutorials

                                1 Reply Last reply Reply Quote 1
                                • First post
                                  Last post

                                12

                                Online

                                2.4k

                                Users

                                13.9k

                                Topics

                                120.7k

                                Posts