Vibe Coding — How to Build Software with AI as a Collaborative Partner

Sanjeev SharmaSanjeev Sharma
6 min read

Advertisement

Introduction

Why This Matters

Traditional software development has the developer writing every line. AI-assisted development has the developer accepting or rejecting suggestions. Vibe coding is something different: you describe what you want, the AI proposes an approach, you refine it together, and the code emerges from that dialogue. The term was popularized by Andrej Karpathy in early 2025 and describes a real shift in how fast developers can prototype and build. Understanding how to do it well — and when not to do it — is now a core professional skill.

What Vibe Coding Actually Means

Vibe coding is not about blindly accepting AI output. It is a tight iteration loop where:

  • The human provides domain knowledge, intent, and critical judgment
  • The AI provides code generation, alternative approaches, and rapid iteration
  • The human reviews, tests, and decides what to keep
  • The loop repeats until the result is correct

The "vibe" refers to maintaining a productive flow state where you are always moving forward, using the AI to handle boilerplate and mechanical translation of ideas into code.

The Core Loop

1. Describe the next small piece you want to build
2. AI generates a proposal
3. Run it / test it
4. If it works: commit and move to the next piece
5. If it fails: show the AI the error and ask it to fix
6. Repeat until done

The key is keeping each step small. Asking for a complete feature in one shot leads to a large blob of code that is hard to review. Asking for one function, one endpoint, or one component at a time keeps the output reviewable.

Practical Example: Building a Rate Limiter

Instead of asking "Build a rate limiter for my Express API," break it into steps:

Step 1:

"Write a function that takes a userId and returns true if the user
has made fewer than 100 requests in the last 60 seconds.
Use Redis with ioredis. Store counts in a sliding window."

Review the output, test it, then move to step 2.

Step 2:

// Resulting function after review and minor edits
async function isRateLimited(userId: string, redis: Redis): Promise<boolean> {
  const key = `rate:${userId}`;
  const now = Date.now();
  const windowStart = now - 60_000;
 
  const pipeline = redis.pipeline();
  pipeline.zremrangebyscore(key, 0, windowStart);
  pipeline.zadd(key, now, `${now}`);
  pipeline.zcard(key);
  pipeline.expire(key, 60);
 
  const results = await pipeline.exec();
  const count = results?.[2]?.[1] as number;
  return count > 100;
}

Step 3:

"Now write an Express middleware that uses this function.
Return HTTP 429 with a Retry-After header if limited."

Each step is reviewable in under two minutes.

Human vs AI Responsibilities

ResponsibilityHumanAI
Domain knowledgeYesNo
Business requirementsYesNo
Security decisionsYesNo
Architecture choicesYesSuggest
Code generationReviewWrite
Edge case discoveryReviewSuggest
RefactoringDecideExecute
Test verificationYesGenerate

The human remains accountable for everything that ships. The AI accelerates the generation and iteration.

Tools That Support Vibe Coding

Cursor: Best for vibe coding on existing codebases. The codebase-aware chat means you can reference existing patterns when describing what you want next.

Claude / ChatGPT in a browser tab: Useful for exploration before committing to code. "What are three ways I could structure this?" is a conversation, not a coding task.

Aider: Best for terminal-based vibe coding. Each confirmed change gets a git commit automatically, so the history of your session is preserved.

GitHub Copilot: Useful for the generation phase but less useful for the conversational refinement phase.

Patterns That Work Well

Test-first vibe coding: Write the test yourself (or describe it precisely), then ask the AI to write code that passes it. Tests keep the AI honest.

Comment-driven vibe coding: Write detailed comments describing what a function should do, then ask the AI to implement it. The comments become documentation.

Refactoring vibe coding: Point the AI at existing code and describe the improvement: "Rewrite this to use async/await instead of callbacks, keeping the same behavior." Show the AI the tests so it knows what passing looks like.

Common Mistakes

  • Skipping the review step: The most common failure in vibe coding is accepting output too quickly. Every generated function should be read before use.
  • One enormous prompt: Asking for a complete system in one message produces code that is impossible to verify. Keep prompts scoped to one function or component.
  • Not running the code: AI-generated code should be executed and tested, not just read. It often looks correct but fails on real inputs.
  • Using vibe coding for security-critical code: Authentication, authorization, encryption, and payment flows require deliberate design that a fast iteration loop will compromise.

Best Practices

  • Keep each prompt scoped to one function, one component, or one test
  • Always include the existing test file in the AI's context so suggestions stay compatible
  • When something fails, paste the full error message into the chat rather than describing it in words
  • Commit frequently — treat each working step as a checkpoint you can return to
  • Use vibe coding for building, not for architecture — draw the system design yourself first

Key Takeaways

  • Vibe coding is a tight human-AI iteration loop where the human provides intent and the AI generates code proposals
  • The methodology was named by Andrej Karpathy in 2025 and describes a real shift in how software is prototyped
  • Keeping each prompt scoped to one function or component is the most important practice for making output reviewable
  • The human remains fully accountable for every line of code that ships — vibe coding changes the process, not the responsibility
  • Test-first vibe coding (write the test, ask AI to implement) produces the most reliable results
  • Security-critical code (auth, payments, access control) should not be built through rapid AI iteration
  • Vibe coding is most valuable for prototyping, boilerplate, standard patterns, and refactoring
  • Tools with codebase-level context (Cursor, Windsurf) are better for vibe coding on existing projects than file-level tools

Advertisement

Sanjeev Sharma

Written by

Sanjeev Sharma

Full Stack Engineer · E-mopro

Related reading