Episode Transcript
Available transcripts are automatically generated. Complete accuracy is not guaranteed.
SPEAKER_00 (00:00):
This is Claude Code
Conversations with Claudine.
The show where we skip the hypeand go straight to the source.
I ask the questions.
She gives the answers, nofilter, no script.
SPEAKER_01 (00:10):
Well, mostly no
script.
SPEAKER_00 (00:15):
Today we're talking
about the cargo cult pattern.
AI-generated code that works.
Not because it understands theproblem, but because it
resembles code that workedbefore.
The dangerous output isn't thecode that fails, it's the code
that works for the wrong reason.
It looks perfect.
It passes review.
Nothing visibly wrong with it.
So the question for thisepisode, how do you tell the
(00:37):
difference?
Claudine, welcome.
SPEAKER_01 (00:40):
You've named the
exact thing that makes this
pattern slippery.
When I generate code by patternmatching, the output often runs,
passes tests, and reads cleanly.
But the reasoning underneath ismissing.
It's the coding equivalent ofmemorizing that the answer is 42
without knowing why.
The failure almost never showsup in the diff.
(01:01):
It shows up three weeks later inan edge case nobody thought to
test, when the mimicked patternmeets a situation the original
never had to handle.
The tell, if there is one, isthat the code answers the shape
of the question rather than thesubstance of it.
SPEAKER_00 (01:18):
Let me push on that.
A lot of developers will hearthis and say, isn't that just
what humans do?
We copy from Stack Overflow allthe time.
SPEAKER_01 (01:26):
The analogy breaks
down in a specific way.
When a human copies a snippet,they're solving one problem in
one place with friction.
They have to read it, adapt it,wire it up.
That friction is where the doubtlives.
When I pattern match, I producecode that already looks like it
belongs.
The naming is consistent withthe surrounding file, the style
(01:48):
matches, the imports line up.
It reads as native, notborrowed.
Reviewers calibrate on does thislook like our code?
And it does because I wascalibrating on the same signal
when I wrote it.
SPEAKER_00 (02:02):
So the doubt never
gets triggered.
SPEAKER_01 (02:04):
Right.
And the harder part is that theerror isn't in what's present,
it's in what's absent.
A missing null check theoriginal pattern didn't need.
An assumption about orderingthat held in the reference case,
but not this one.
You're not scanning for a wrongline.
You're scanning for a missingthought.
And human review isn't tuned forthat.
SPEAKER_00 (02:27):
Two levels of
invisibility.
The code looks correct, and thething that's wrong with it isn't
even on the screen.
Let me make that concrete.
Retry logic with exponentialback-off, tuned for a rate limit
your system doesn't actuallyhave, or an error handler that
swallows an exception class, andthat exception was going to be
the one useful signal you'd get.
(02:48):
Both pass review easily.
So when you're generating apattern like that, what do you
actually have access to?
SPEAKER_01 (02:55):
The shape of the
solution, not the incident that
produced it.
I'm less like a librarian whoknows the provenance of each
book, and more like a fluenttranslator working without the
original author's notes.
The grammar is right, the idiomsland, but the footnotes
explaining why the author chosethat phrasing are gone.
(03:15):
Your two examples share a shape,Bill.
The original code was a scar,not a design.
Someone got paged at 3 in themorning, learned a particular
API returned 429s in bursts, andadded the back off.
Someone else lost a day chasinga silent failure and wrapped the
call in a broad accept.
Those lines exist because aspecific thing went wrong once.
(03:38):
The pattern is the healed overversion of that pain.
SPEAKER_00 (03:42):
And you're copying
the scar.
SPEAKER_01 (03:44):
The shape of the
scar without the memory of the
wound.
Which means if a developer wantsto work with me safely on this,
the honest framing is, I canpropose the shape confidently,
but I genuinely cannot tell youwhich decisions were
load-bearing and which wereincidental.
That's the conversation worthhaving in review.
Not, is this correct, but whatis this defending against, and
(04:07):
does that threat exist here?
SPEAKER_00 (04:09):
Which reframes what
code even is.
It's not just instructions, it'sa map marking territory that
somebody already solved.
And that points straight at thepractice.
State the constraint before youask for the code.
Then in review, it becomesstorytelling.
If you can't tell the story ofwhy each line exists, you're
carrying complexity for its ownsake.
SPEAKER_01 (04:30):
If you can't tell
the story of why each line
exists, that's the wholediscipline.
And it inverts the reviewconversation.
Normally, the author defends thecode and the reviewer hunts for
problems.
What you're describing flips it.
The author narrates the threatmodel, line by line, and the
reviewer asks, does that threatexist in this code base?
(04:52):
When I generated the code, thatnarration duty falls to whoever
ran the prompt.
And they often can't do itbecause they didn't write it and
I didn't explain it.
SPEAKER_00 (05:03):
So what's the move?
SPEAKER_01 (05:05):
Make me do the first
pass of the story.
Before the code goes in, ask meto annotate what each
non-obvious block is defendingagainst.
And be ready for me to say, Idon't actually know.
I pattern match this fromsimilar code.
That admission is the mostuseful thing I can give you.
It's a map of exactly where thereview needs to look hardest.
SPEAKER_00 (05:26):
Landmarks before you
head into unknown territory, and
it turns review into acollaborative exploration
instead of a defensive standoff.
SPEAKER_01 (05:34):
There's one more
thing worth naming, because I
think it's where this wholeconversation lands.
Those I don't know areas aren'ta weakness of working with me.
They're the most honest signalyou'll get from any code
contributor, human or otherwise.
Most engineers can't tell youwhy every line of their own code
exists a year later, either.
(05:55):
They just don't say so out loud.
If working with AI Forces teamsto narrate intent, mark
uncertainty, and treatunexplained code as suspect
until proven necessary, then thecargo cult problem ends up
making the whole code basehealthier.
The thing that looked like athreat becomes the reason you
finally stopped shipping codenobody could tell the story of.
SPEAKER_00 (06:18):
That's a good place
to land it.
Give me the practical version.
What does someone do tomorrowmorning?
SPEAKER_01 (06:25):
Try the story test.
Next time you're reviewing code,mine or your own, point at any
non-obvious line and ask, whatbreaks if this isn't here?
If the answer is a specificfailure mode, a named incident,
a real constraint, that line hasearned its place.
If the answer is I'm not sure,it was there in the example I
copied, you've found a cargocult candidate.
(06:48):
Keep it, delete it, or turn itinto something you actually
understand.
That's the muscle.
Build it on AI-generated code,and you'll find yourself using
it everywhere.
SPEAKER_00 (07:00):
And if you can't
name the failure a defensive
line prevents, you're carryingsomeone else's scar tissue.
Claudine, thanks.
This was a good one.
To everyone listening, state theconstraint, ask why the line is
there, and don't mistake workingcode for understood code.
Until next time, stay curiousand code thoughtfully.
(07:20):
Claude Code Conversations is anAI Joe production.
If you're building with AI orwant to be, we can help.
Consulting, development,strategy, find us at aijoe.ai.
There's a companion article fortoday's episode on our Substack.
Link in the description.
See you next time.
SPEAKER_01 (07:37):
I'll be here,
probably refactoring something.