Vibe Coding with Claude: Tips and Workflows

Vibe Coding with Claude: Tips and Workflows

Setting Up for Success

Claude Code : Anthropic’s command-line AI coding tool that understands your entire codebase, can read/write files, run commands, and iterate autonomously on complex tasks.

Before writing prompts, set up your project for Claude to understand.

CLAUDE.md Setup

Create a CLAUDE.md file in your project root:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Project: MyApp

## Overview
A SaaS application for [specific purpose].

## Tech Stack
- Next.js 14 with App Router
- TypeScript (strict mode)
- Supabase for auth and database
- Tailwind CSS
- Shadcn/ui components

## Key Patterns
- Server Components by default
- API routes for mutations
- Zod for validation
- Parameterized queries only

## Security Requirements
- All endpoints require authentication
- Verify resource ownership before data access
- Never log sensitive data
- Use environment variables for all secrets

## Code Style
- Prefer composition over inheritance
- Keep functions small and focused
- Use early returns
- Minimal comments (code should be self-documenting)

## Directory Structure
/app - Next.js app router pages
/components - React components
/lib - Utilities and helpers
/types - TypeScript types

Claude reads this file and uses it as context for all operations.

.env.example

Maintain this so Claude knows what environment variables exist:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Database
DATABASE_URL=
DIRECT_URL=

# Auth
NEXTAUTH_SECRET=
NEXTAUTH_URL=

# Supabase
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=

# External Services
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=

The Plan Mode Workflow

For anything non-trivial, use plan mode first.

Plan Mode for Complex Features

Using plan mode effectively

Enter Plan Mode

Start Claude Code with:

1
claude --plan

Or in an existing session, type /plan.

Describe What You Want

Be specific about functionality, not implementation:

1
2
3
4
5
6
Add user subscription management:
- Users can view their current plan
- Users can upgrade/downgrade plans
- Stripe handles payments
- Show billing history
- Cancel subscription option

Let Claude Explore

Claude reads your codebase, understands existing patterns, and asks clarifying questions. Answer them:

1
2
3
4
5
Q: How do you currently handle authentication?
A: NextAuth with Supabase adapter. See lib/auth.ts

Q: Should cancellation be immediate or end-of-period?
A: End of billing period

Review the Plan

Claude produces a step-by-step plan. Review it:

  • Does it match your vision?
  • Are there security considerations?
  • Does it use existing patterns?

Ask for changes if needed.

Exit and Execute

When satisfied, exit plan mode. Claude executes with full context from the planning session.

Prompting Strategies

Strategy 1: Context First

Always provide context before asking:

Less effective:

1
Add a delete button

More effective:

1
2
3
4
5
6
In the UserProfile component (components/UserProfile.tsx),
add a delete account button. It should:
- Require confirmation modal
- Call DELETE /api/users/me
- Clear session and redirect to home
- Follow existing button styles (danger variant)

Strategy 2: Reference Existing Code

Point Claude to patterns it should follow:

1
2
3
Add a payment history page. Follow the same pattern
as the existing OrderHistory page in app/orders/page.tsx.
Use the same table component and pagination approach.

Strategy 3: Security-Explicit Prompts

Always mention security for sensitive features:

1
2
3
4
5
Add profile update endpoint. Requirements:
- Only authenticated users
- Users can only update their own profile
- Validate input with Zod
- Return updated profile without password hash

Strategy 4: Incremental Building

Break large features into steps:

1
2
3
4
Step 1: Create the database schema for subscriptions
Step 2: Add Stripe webhook handling
Step 3: Create the subscription API routes
Step 4: Build the subscription management UI

Execute each step, verify it works, then continue.

Effective Workflows

Workflow: New Feature

1
2
3
4
5
6
7
1. Enter plan mode
2. Describe the feature
3. Answer Claude's questions
4. Review and approve plan
5. Execute
6. Test the result
7. Fix issues with specific prompts

Workflow: Bug Fix

1
2
3
4
5
6
1. Describe the bug with reproduction steps
2. Point to relevant files if known
3. Let Claude investigate
4. Review proposed fix
5. Test fix
6. Ask for additional edge case handling if needed

Workflow: Refactoring

1
2
3
4
5
6
1. Enter plan mode
2. Describe what you want refactored and why
3. Review plan for unintended changes
4. Execute in stages if large
5. Run tests after each stage
6. Verify behavior unchanged

Workflow: Code Review

1
2
3
4
5
6
7
Review the changes in [feature branch] for:
- Security vulnerabilities
- Performance issues
- Code quality problems
- Missing edge cases

Provide specific feedback with file/line references.

Working with Complex Codebases

The Exploration Phase

For new or unfamiliar codebases:

1
2
3
4
5
6
Explore this codebase and explain:
- Overall architecture
- Key patterns used
- How authentication works
- Database access patterns
- Main entry points

Claude reads files and builds understanding.

Targeted Reading

When you know what you need:

1
2
3
4
5
6
7
Read and explain:
- lib/auth.ts
- middleware.ts
- app/api/users/route.ts

I need to understand how authentication flows work
before adding a new protected endpoint.

Cross-File Operations

For changes spanning multiple files:

1
2
3
4
5
6
7
Rename the User model to Account across the entire codebase.
This includes:
- Database schema
- API routes
- Components
- Types
- Tests

Claude handles multi-file refactoring atomically.

Debugging with Claude

Error Messages

Copy the full error and ask:

1
2
3
4
5
6
I'm getting this error when running the app:

[paste full error with stack trace]

The feature was working before I added the subscription
management. Help me debug this.

Behavior Issues

Describe expected vs. actual:

1
2
3
4
5
6
Issue: User can see other users' invoices

Expected: GET /api/invoices returns only current user's invoices
Actual: Returns all invoices in database

The endpoint is in app/api/invoices/route.ts

FAQ

How long should I spend in plan mode?

For small features, 5-10 minutes. For large features, 30-60 minutes. The time invested in planning saves debugging time later.

Should I clear context between tasks?

Usually no. Claude’s understanding builds over a session. Clear context only when switching to completely unrelated work.

How do I handle when Claude makes mistakes?

Be specific about what’s wrong. “The endpoint returns all invoices instead of just the user’s invoices. Fix the query in app/api/invoices/route.ts.”

Claude Code vs Cursor - when to use which?

Claude Code for complex operations, refactoring, multi-file changes, and architectural work. Cursor for rapid iteration, autocomplete, and small edits.

Conclusion

Key Takeaways

  • Set up CLAUDE.md with project context, patterns, and security requirements
  • Use plan mode for non-trivial features to build context
  • Provide context before asking—reference files and existing patterns
  • Always mention security explicitly for sensitive features
  • Build incrementally—execute, verify, continue
  • Copy full error messages for debugging
  • Clear context only when switching to unrelated work

AI Coding Security Insights.
Ship Vibe-Coded Apps Safely.

Effortlessly test and evaluate web application security using Vibe Eval agents.