“Where’s the return statement, Claude?”

“Where’s the return statement, Claude?”

“Where's the return statement Claude?” was not the first statement I typed into Claude after I signed up for Anthropic’s pro plan. So maybe I should back up a few steps.

🛠 The Project: Build a RAG System

Like a lot of folks, I learn best by doing. So I set out to build a retrieval-augmented generation (RAG) system using:

  • Language: Python 3.13
  • Vector DB: Postgres 14.14.18 + pgvector
  • Dataset: TriviaQA
  • Model: gpt-4.1-nano

Could I have written all the code myself? Sure — but that’s not really how modern development works. Instead, I talked to a former colleague, Kevin Lyons (cofounder, Wise Owl Collective). His advice:

  1. Use Claude over ChatGPT — it’s stronger for code.
  2. Make it explain every step.

Solid advice on both counts.

📥 Step 1: Reading and Embedding the Data

I uploaded the spec I wrote and a small sample of the TriviaQA dataset. Claude generated working code. Mostly.

Two problems:

  1. It loaded the entire JSON file into memory
  2. It ignored Postgres and used SQLite

Both were easy to fix. I gave it more constraints and moved on.

🧠 Step 2: Generating Embeddings and Populating the DB

I chunked the data, called the OpenAI API for embeddings, and inserted everything into the Postgres vector store. First: the sample set — success! So I ran it on the full dataset. Claude said it would take 30 minutes.

It took 10 hours. (Thanks, rate limits.) But it completed without errors:

  • Total records processed: 527,022
  • Questions: 11,313
  • Passages: 515,709
  • Chunked passages: 482,156

The database was ready. Time to test.

🔍 Step 3: Querying the Model

Claude generated code to query the database using cosine similarity via pgvector. And it ran!

…And it returned nothing.

Every question — even “What is the capital of France?” — gave the same reply:

“I couldn’t find any relevant information to answer your question. Confidence: low (0 sources).”

Classic LLM moment: it was syntactically perfect… and completely wrong.

🐞 Debugging: Is It the Code or the Data?

I asked Claude to create unit tests using known facts in the dataset.

Same result: nothing.

It kept rewriting the code with more debugging logs. But the root problem remained.

So I stepped through everything manually:

  • ✅ Parameters were correct
  • ✅ Embeddings were retrieved from the DB
  • ✅ similarity_search() called the OpenAI API and returned an answer

Then I looked closer at the similarity_search() function.

There it was. Or rather… there it wasn’t.

No return statement.

🤦 Me:

“similarity_search() finds no records. Does it need a return statement?”

🤖 Claude:

YES! You’ve found the bug! Great debugging — you’re absolutely right.”

It revised the code. Still no return statement. And no matter how many times I prompted it, the fix never stuck. Eventually, I added the return statements manually and moved on.

🧭 What I Learned

1. Prompt Engineering is Like Leadership, Not Programming

Effective AI coding requires skills more akin to management than traditional development. You must meet the AI where it's strong, provide clear context, and break complex problems into digestible chunks. The most productive sessions felt like collaborative problem-solving rather than instruction-giving.

Better prompting example: Instead of "fix the bug," try "examine the similarity_search function and verify it returns the results from cursor.fetchall(), then show me only the corrected function with proper indentation."

2. AI as Technical Educator is Transformative

Claude excelled at explaining complex concepts on demand. When I asked about cosine similarity, data chunking strategies, or pgvector implementation choices, the explanations were clear, contextual, and immediately applicable. This educational capability may be AI's most undervalued feature for technical teams.

3. The Productivity-Oversight Balance

Despite the return statement saga, AI coding assistance delivered massive time savings. I went from zero to working code in hours. The key insight: AI excels at generating functional code architecture but requires human oversight for correctness and edge cases. Think "accelerated pair programming" rather than "automated coding." And you need to know when to ask the model to troubleshoot and when to take a more traditional approach.

4. Creative Destruction in Software Development

Our discipline was approaching maturity just as AI fundamentally disrupted it. New paradigms and ecosystems are growing so quickly that it is a full time job to stay up with them. Staying current isn't just professional development—it's survival.

👋 If you’re experimenting with building LLM-based systems — especially RAG — I’d love to connect, share notes, or trade battle scars. There’s a lot to learn. And it’s moving very fast.

#LLMs #AIEngineering #PromptEngineering #ClaudeAI #RAG #OpenAI #Postgres #VectorSearch #LearningByDoing


Living and breathing this exciting world everyday, although my tool choices would be Q for Developer CLI w/ Claude Sonnet, Bedrock AgentCore, and Kiro. Amazing the ability to go from idea to working, demoable code in such a short time. Would love to connect with you on this!

To view or add a comment, sign in

Others also viewed

Explore content categories