Vibe Coding (Part 2): Thinking, Testing, Debugging — Co-Building with AI

Vibe Coding Illustration

In Part 1, I shared how I paired with ChatGPT and Windsurf to build faster — treating the AI not as a code generator, but as a coding partner.

This chapter zooms out.

It's not about writing code. It's about how you think before writing code.

How you design with prompts, debug with logs, test with intent, and build incrementally — co-building with AI like you would with a smart junior dev or senior peer.

In this post, I'll walk through how I:

  • Brainstorm architecture through back-and-forth prompting
  • Feed logs instead of feelings for faster bug resolution
  • Use integration tests as a safety net for AI-led development
  • Build features one scoped phase at a time
  • And refactor first to align AI and human understanding

If Part 1 was about vibing while coding, Part 2 is about vibing before coding.

Let's dive in.

🧠 ChatGPT for Brainstorming

Using ChatGPT not just as a coder, but as a thought partner

There was a time when architecture decisions began with a Google search. Now? Karan starts every major thought process by vibing with ChatGPT.

This isn't about getting code snippets. It's about co-designing systems — like a senior dev pair programming in plain English.

1. Replace Google with Prompt-Driven Thinking

Instead of searching "best way to debounce in React" or "FastAPI background tasks," Karan prompts ChatGPT:

"I'm building a FastAPI service that streams data. Should I use BackgroundTasks, threading, or async generators?"

The result?

An interactive, layered breakdown. With tradeoffs, edge cases, and real-world suggestions.

2. Discuss Pros and Cons Like a Dev Would

ChatGPT's not just a lookup tool. It's a sounding board.

"Which image diffing library should I use in Python for perceptual similarity?" "Can you compare opencv, PIL, and ImageHash with use cases?"

Karan treats these discussions like team huddles. Pros, cons, performance, maintainability — it's all on the table.

3. Finalize the Flow, Then Summarize

Once the architecture, flow, and stack are locked in, he asks:

"Now summarize this design in Markdown for me."

That summary goes directly into Windsurf as input — giving the agent a crystal-clear spec to build from.

No misalignment. No assumptions. Just shared understanding.

🪲 Logs, Not Prompts, for Bugs

Don't describe the bug — show the evidence.

When debugging, your AI agent isn't a mind reader — it's a pattern matcher. And nothing gives it a better pattern than actual logs.

1. Feed It Real Logs, Not Feelings

Instead of vague statements like:

"The app's crashing again…"

Say:

"Here's the error log from module-agent:\n\n\nTraceback (most recent call last): ...\n"

These logs give the agent exact clues: filenames, line numbers, stack traces. That's what it needs — not your interpretations.

2. Let the Agent Do the Detective Work

When given real logs, the agent can:

  • Trace where the error occurred
  • Infer why it happened
  • Suggest a fix in the right place

That's far better than prompting:

"Can you fix the bug?"

— because without logs, the agent doesn't know what or where to fix, and you waste time feeding it the full story.

3. Real-Time Debugging with Live Logs

Paste tailing logs from Docker or your terminal:

docker logs -f module-agent

And ask:

"Spot anything failing in this stream?"

It becomes like pairing with a senior dev who watches your logs while you code.

Why It Works

Logs give context the agent can parse, trace, and solve.

They anchor the problem in reality — where it happened, why it happened, and how to fix it.

Without them, the agent is flying blind.

✅ Tests Are the Real Vibe Check

In vibe coding, tests aren't optional — they're stability anchors.

When working with an AI agent, you're not just writing features — you're building atop a layered system where a small mistake, like a missing import or misnamed variable, can bring down your backend entirely.

High-level integration tests protect against these failures by validating critical flows end-to-end.

1. Write Integration Tests, Not Unit Specs

Forget micro-tests like test_addition() or isolated utils. Instead, start with:

"Write an integration test to verify the /start-conversation API calls module-session-mgmt and module-agent."

This guides your agent to validate real behavior across services — ensuring that changes don't silently break runtime flows like STT not initializing or a gRPC dependency failing.

2. Use the Test–Fix–Repeat Cycle

Before coding anything, say:

"Write an integration test that checks whether the user login flow returns a session token and hits the correct services."

Then ask the agent to write the implementation.

If something crashes — say, a container refuses to boot or a server throws a ModuleNotFoundError—ask:

"Read the traceback and fix the issue until the integration test passes."

You're turning the test into a self-correcting loop that finds bugs early — before your app even launches.

Why It Works

AI agents are probabilistic. They'll get things 90% right — and sometimes 100% broken.

Integration tests don't just verify correctness. They defend uptime.

They prevent subtle changes from taking the entire backend offline — ensuring that /login, /inference, or /sync still work as intended after each change.

When the tests stay green, your system stays alive.

And your vibe? Rock solid.

🧱 Plan Big, Build Small: One Step at a Time

You wouldn't hand a junior dev your entire codebase and say "build the next big thing." So don't do it with your agent either.

When working with large or complex features, plan wide, implement small.

1. Build Context for the Big Picture

Start by setting up your agent with vision and goals. Prompt:

"We're building a new feature to convert SSML to plain text, validate it, and return speech through gRPC. What would the full architecture look like?"

Let it explore:

  • System architecture
  • Related services
  • Future-facing goals

This ensures the AI sees the why, not just the what.

2. Don't Solve It All at Once

Avoid dumping the whole feature as a single instruction. Instead, prompt:

"Don't write any code yet. Just break this feature into logical phases or components."

Let the AI return a step-by-step plan.

3. Ask It to Divide the Work

Once the AI outlines the scope, prompt again:

"Divide this into clear tasks: input sanitization, gRPC wiring, response handling, logging, etc."

This creates modular checkpoints.

4. Implement Just One Phase

Pick one task. Prompt:

"Let's begin with just the input sanitization. Don't move ahead to other steps."

The AI now works with precision, not assumptions.

5. Move to Next Step Only After Review

Once the first task is done:

  • Check the logic
  • Run integration tests
  • Confirm alignment

Then prompt:

"Now let's implement the gRPC communication layer — do not wire it to the rest yet."

Repeat this loop for each task until the feature is fully built.

🧹 Refactor as a Ritual

Refactoring isn't just cleanup — it's how you and your AI agent sync up before building anything new.

Before starting any feature, take a moment to refactor the code you're about to work on. Here's why that small step leads to smarter outcomes:

Why Refactor First?

Preps the Agent for Context

Refactoring forces both you and the agent to deeply read and understand the current logic. This builds a shared understanding and better context for what's coming next.

Enables Cleaner Feature Development

Once the AI knows what the current code is doing, it can write more aligned, maintainable implementations — especially when you describe new requirements.

Improves Legacy Code Along the Way

While prepping for new logic, you also end up modernizing older code, cleaning up functions, and setting a better foundation for future tasks.

When you start by refactoring the files tied to your next task, you're not just cleaning house — you're teaching your agent the language of the codebase.

Think of it as a warm-up, not a chore. The better the foundation, the better the build.

📌 TL;DR

Quick takeaways from the VIBE coding journey:

🧠 Brainstorm with Prompts, Not Searches
Replace Google with prompt-driven design conversations. Let your AI break down tradeoffs like a teammate would.

🪲 Debug with Logs, Not Feelings
Feed your agent real stack traces, not vague bug reports. Logs = context. Context = better fixes.

Use Tests as Vibe Checks
Start with integration tests. Let them guide implementation and act as guardrails against breakage.

🧱 Build Big by Starting Small
Don't overwhelm your agent. Break work into scoped phases. Align after each. Then move.

🧹 Refactor First
Treat refactoring as a pre-flight ritual. It gives both you and your agent a clean, aligned mental model before the build begins.