I think I found a solution to crap code


TL;DR you can have Claude (or your favorite LLM) create wonderful, clean, bullet-proof code if you take the time to use good patterns and practices, wrapped in some type of development process like Scrum or Kanban. Sounds weird, but I made it work, and it's amazing.


This last month has been one of best of my professional career. I wrapped up my first cohort and felt extremely good about it, especially the last meeting where we discussed whether Gang of Four and things like SOLID are meaningful anymore.

In short, we all agreed that not only are they important, they're more important than they've ever been! We use software patterns and principles to mitigate the damage of change over time, because that is where the true work is. Debugging, new features, component upgrades - these things should be straightforward, not cause for a full rewrite.

This is why we use interface-based programming and adhere to principles like "Single Reponsibility" and Dependency Inversion. Coupling and Cohesion are two words that every programmer should have tatooed on their buttcheeks!

OK sorry about that... but really they should.

Anyway this conversation got me thinking: how can we get Claude to write code that conforms to these principles?

Cargo Cults

Let's get this out of the way: just because you're using Strategy or Adapter patterns doesn't make your app "good". It's all too easy to get lost in patternville, creating a cathedral in a town of 10.

The trick is to solve the problem "elegantly", doing just enough so that you don't create a mess with either too much or too little engineering.

Sounds great, but how do you actually do this?

Just Ask

In my latest video I dig in that very question: how can I set things up with Claude so that it does what I ask it to do? This isn't an easy question to answer, but I then thought back to my days working on a larger engineering team.

Bad developers don't write bad code; teams and organizations without process do. You can spot a crappy team lead when they blame their developers for shipping bugs. If that happens, it's the process that's failed, not the programmer.

That's when I heard the ding go off! What if we could wrap a process around Claude that worked like an agentified version of Scrum? There would be an orchestrator, a product owner, an architect, developers, policy and security reviews, client interviews...

So that's what I set out to make and I'll just tell you straight up that the result blew my damned mind. I thought I might be a little too high on my own supply so I fired up Gemini to do a code review.

Dig this:

Incredible! I honestly had never heard of a "Composition Root" before I made this video. I mean - I know what Dependency Inversion is and I've used Dependency Injection tooling... but what Claude came up with was downright amazing.

Getting there took some time, however, and the key to it all is patience.

Leverage

Just like running a large development team, you have to take the time to lay down the rules and the process. The fun thing is that you don't need to do it all on your own - have Claude interview you to find out what you need.

In the video I made (it's a premium one, just so you know), I start with a SPEC.md and an ORCHESTRATION.md, together with a simple CLAUDE.md. From there I have Claude ask me questions about all three. It helped me:

  • Expand the ORCHESTRATION.md document so that it made sense, turning my simple diagrams and bullet points into mermaid graphs and full agent descriptions.
  • Create a PROJECT_CONTEXT.md document, by interviewing me about what I wanted to build and how. We also discussed architectural approaches, which helped to create an ARCHITECTURE.md document together with an architect agent.

It took some time, but I also detailed how I want a product owner to write user stories and then a tester to create behavior-driven design tests from those stories. We discussed how to do verification in the real world, outside the non-deterministic walls of the LLM.

But the big unlock came when I tried to do this with Claude Code.

Use A Better Agentic Harness

I don't know how else to say it, but Claude Code has degraded heavily over the last few months. I think it's mostly the tooling, because the LLM worked great for me if I used pi.dev. I like Pi a lot, but you could also use OpenCode or anything else that doesn't have a gigantic system prompt.

Claude Code worked so well for so long, that it seems silly to say "it sucks" when these capabilities didn't even exist a year ago. My expectations are so high now, that anything that doesn't blow my mind is a let down. Yeah, I know.

That said, the degradation is annoying as hell, especially when you burn $50 in tokens only to realize there's no way you're going to get what you asked for.

I didn't have this problem with Pi and I suspect it's because I wasn't fighting with the system prompt. It seems the tooling has been the issue all along, per this post from Anthropic just last week (emphasis mine):

Over the past month, we’ve been looking into reports that Claude’s responses have worsened for some users. We’ve traced these reports to three separate changes that affected Claude Code, the Claude Agent SDK, and Claude Cowork. The API was not impacted.

The only reason the API couldn't be impacted is because it's the raw LLM response that isn't subject to the system prompts of each tool.

Here's another quote from that post:

On April 16, we added a system prompt instruction to reduce verbosity. In combination with other prompt changes, it hurt coding quality and was reverted on April 20. This impacted Sonnet 4.6, Opus 4.6, and Opus 4.7

If I wasn't paying $200/month, I might say I understand. What's clearly happening here is that Anthropic is compute constrained, so they're throttling aspects of the service (degrading the quality) to, I assume, lower the burden.

The crazy thing is that degrading quality like this causes more burden because programmers like you and me have to keep at it to get the response we want.

For me, OpenRouter + pi.dev has been a wonderful change of pace. You can see the difference in the video.

90 Minutes to Happiness

It took me 90 minutes to leverage 3 small documents into a full agentic team with Pi, complete with deterministic extensions and agentic skills that it made for me (Pi is aware of its own documentation and can build things out for you).

The interviews took some time, but they were so very worth it, especially based on the code they produced. And no, you don't need to buy a video to see how to do all this! Just write out your orchestration process, your spec, and give Claude some basic rules on code quality. Ask it to interview you a few times to lay things out, and off you go.

And finally: yes, I wrote this all by hand, myself. Do you think an AI would joke about tatooed buttcheeks!

Cheers,

Rob


It's not hype, it's happening

Get a premium membership and enjoy timely, level-headed videos on the emerging AI industry.

🥷🏽 Notes From an Imposter Programmer

I taught myself to code in 1998 and within 7 years had a client list that included Google, Microsoft, Starbucks, Ameritech, KLA-Tencor, PayPal, and Visa. In 2014 I decided that I really needed to understand core Computer Science concepts, so I dove in, using the free resources from MIT and Stanford. In 2016 I shared what I learned with The Imposter's Handbook.

Read more from 🥷🏽 Notes From an Imposter Programmer

I was in the middle of recording my latest premium video on agentic orchestration when my Claude Max subcription up and left the building. I was in the middle of my pi.dev demo when BOOM! I got the dreaded "third party tools" request error. Note: if you don't know what pi.dev is I'll explain more at the end. I'm also putting together a video on it. I went online and snooped around and, sure enough, Anthropic knee-capped OpenClaw and every other third party tool that used it's OAuth API Key:...

Something I'm trying to remove from my life is watching other people give their hot takes on something and substituting their experience instead of FAFO for myself. It's entirely understandable why people do this: there's a lot to know in our industry! Keeping up with everything is nearly impossible. That said, I think there's a threshold where it's our actual duty to try something for ourselves to see what we think about it, rather than repeating some influencer on social. Given that I'm...

You can get rid of imposter syndrome for good. It's possible!

I was telling a good friend about my new coaching/workshop thing I'm trying to get off the ground (ridding yourself of Imposter Syndrome) and they asked me a great question (paraphrased): This sounds like a slam dunk for people dealing with it, but are you offering a practical solution with steps or just inspirational stuff? How can you guarantee such a thing? This was in response to my offer: I want to help you break through your personal barriers and transform into the professional you want...