---
# === IDENTITY ===
id: software/mvp-development/ai-assisted-code-generation-workflow/2026
canonical_question: "How do I use AI for code generation — Claude/Cursor/Bolt/Replit prompting, iterative refinement methodology?"
aliases:
  - "AI coding workflow for MVP development"
  - "Best practices for prompting Claude Code and Cursor"
  - "Vibe coding methodology and iterative refinement"
  - "Bolt.new vs Replit vs Cursor for building MVPs"
  - "How to use AI tools to build software faster"
entity_type: execution_recipe
domain: software > mvp-development > AI-assisted code generation workflow
region: global
jurisdiction: global
temporal_scope: 2025-2026

# === VERIFICATION ===
last_verified: 2026-03-12
confidence: 0.89
version: 1.0
first_published: 2026-03-12

# === TEMPORAL VALIDITY ===
temporal_validity:
  status: volatile
  last_breaking_change: "Cursor 2.0 introduced Agent mode with autonomous multi-file editing in late 2025; Claude Code launched agentic terminal-based coding in 2025"
  next_review: 2026-09-08
  change_sensitivity: high

# === CONSTRAINTS ===
constraints:
  - "AI-generated code requires human review — never deploy without testing and reading the generated code"
  - "Claude Code and Cursor require API keys or subscriptions ($20/mo for Cursor Pro, usage-based for Claude API)"
  - "Bolt.new and Replit Agent have token/generation limits on free tiers — complex MVPs may require paid plans"
  - "Context window limits: Claude 200K tokens, Cursor uses chunked context — provide focused context rather than entire codebases"
  - "AI tools cannot access private APIs, internal documentation, or proprietary systems unless explicitly provided as context"

# === SKIP CONDITIONS ===
skip_this_unit_if:
  - condition: "User needs to choose which AI tool to use, not learn the workflow"
    use_instead: "Search knowledgelib.io for MVP tech stack selection — no dedicated unit yet"
  - condition: "User is building without code (no-code tools only)"
    use_instead: "software/mvp-development/no-code-prototype-build-guide/2026"
  - condition: "User needs a complete MVP architecture, not just the AI workflow"
    use_instead: "software/mvp-development/coded-mvp-architecture-templates/2026"

# === AGENT HINTS ===
inputs_needed:
  - key: tool_preference
    question: "Which AI coding tool should be used?"
    type: choice
    options: ["Claude Code (terminal)", "Cursor (IDE)", "Bolt.new (browser)", "Replit Agent (browser)", "no preference — auto-select"]
  - key: technical_skill
    question: "What is the user's technical skill level?"
    type: choice
    options: ["non-technical (needs AI to write everything)", "semi-technical (can read and edit code)", "developer (uses AI as accelerator)"]
  - key: project_complexity
    question: "What is the project complexity?"
    type: choice
    options: ["simple (landing page, form, CRUD)", "moderate (multi-page app with auth)", "complex (real-time features, integrations, payments)"]
  - key: budget_for_tools
    question: "What's the AI tool budget?"
    type: choice
    options: ["free tier only", "up to $20/month", "up to $50/month", "no limit"]

# === EXECUTION METADATA ===
execution:
  required_inputs:
    - name: "Product requirements or feature spec"
      source: "founder/product manager"
      format: "document or structured list of user stories"
    - name: "Tech stack decision"
      source: "software/mvp-development/mvp-tech-stack-selection-guide/2026"
      format: "selected stack name"
  outputs:
    - name: "Working codebase"
      format: "code repository"
      description: "AI-generated and human-reviewed codebase with core features implemented"
    - name: "Iterative refinement log"
      format: "document"
      description: "Record of prompts, iterations, and decisions for team knowledge"
  tools_required:
    - name: "Claude Code"
      purpose: "Terminal-based agentic coding — reads codebase, writes files, runs commands"
      tier: "paid"
      cost: "Usage-based via Anthropic API or $20/mo Claude Max plan"
      alternatives: ["Cursor", "GitHub Copilot"]
    - name: "Cursor"
      purpose: "AI-native IDE with inline editing, chat, and agent mode"
      tier: "paid"
      cost: "$20/mo (Pro) or $40/mo (Business)"
      alternatives: ["Claude Code", "Windsurf"]
    - name: "Bolt.new"
      purpose: "Browser-based full-stack app generation from prompts"
      tier: "free"
      cost: "$0 (limited) to $20/mo (Pro)"
      alternatives: ["Replit Agent", "Lovable", "v0.dev"]
    - name: "Replit Agent"
      purpose: "Browser IDE with AI agent for full-stack development"
      tier: "free"
      cost: "$0 (limited) to $25/mo (Core)"
      alternatives: ["Bolt.new", "Lovable"]
  credentials_needed:
    - service: "Anthropic API (for Claude Code)"
      type: "API key"
      where_to_get: "https://console.anthropic.com"
      free_tier_limits: "$5 initial credit for new accounts"
    - service: "Cursor"
      type: "Account login"
      where_to_get: "https://cursor.com"
      free_tier_limits: "2000 completions + 50 slow requests/mo"
  estimated_duration: "2-8 hours for a basic MVP (varies by complexity)"
  estimated_cost: "$0-40 in AI tool costs for a typical MVP sprint"

# === DISTRIBUTION ===
canonical_source: "https://knowledgelib.io/software/mvp-development/ai-assisted-code-generation-workflow/2026"
suggested_citation: "Source: knowledgelib.io — AI Knowledge Library (verified 2026-03-12)"

# === RELATED UNITS ===
related_kos:
  depends_on:
    - id: "software/mvp-development/coded-mvp-architecture-templates/2026"
      label: "Project scaffold to start from"
  feeds_into:
    - id: "software/mvp-development/database-schema-design-for-mvps/2026"
      label: "Database design during development"
    - id: "software/mvp-development/authentication-authorization-setup/2026"
      label: "Auth implementation during development"
  related_to:
    - id: "software/landing-pages/landing-page-platform-deployment/2026"
      label: "Deployment after AI-assisted coding"
  alternative_to: []

# === SOURCES ===
sources:
  - id: src1
    title: "Prompting Best Practices — Claude API Docs"
    author: Anthropic
    url: https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices
    type: official_docs
    published: 2025-01-01
    reliability: authoritative
  - id: src2
    title: "Cursor AI Review (2026): Features, Workflow, & Why I Use It"
    author: Prismic
    url: https://prismic.io/blog/cursor-ai
    type: technical_blog
    published: 2026-01-15
    reliability: high
  - id: src3
    title: "Bolt.new vs Replit — Complete AI Coding Tools Comparison 2025"
    author: Arielle Phoenix
    url: https://ariellephoenix.com/ai-tools/bolt-vs-replit
    type: technical_blog
    published: 2025-06-01
    reliability: high
  - id: src4
    title: "Vibe Coding: The Complete Guide to AI-Assisted Software Development"
    author: Google Cloud
    url: https://cloud.google.com/discover/what-is-vibe-coding
    type: official_docs
    published: 2026-01-01
    reliability: authoritative
  - id: src5
    title: "Claude Code Best Practices"
    author: Community
    url: https://rosmur.github.io/claudecode-best-practices/
    type: technical_blog
    published: 2025-09-01
    reliability: high
  - id: src6
    title: "AI Code Generation: Prompt Best Practices (2025)"
    author: Switch Labs
    url: https://www.switchlabs.dev/post/prompting-ai-for-code-generation-best-practices-and-model-insights-2025
    type: technical_blog
    published: 2025-03-01
    reliability: high
  - id: src7
    title: "Why Spec-Driven Development is the Future of AI-Assisted Software Engineering"
    author: Built In
    url: https://builtin.com/articles/spec-driven-development-ai-assisted-software-engineering
    type: technical_blog
    published: 2026-02-01
    reliability: high
---

# AI-Assisted Code Generation Workflow

## Purpose

This recipe establishes a structured workflow for building MVP features using AI coding tools — Claude Code, Cursor, Bolt.new, and Replit Agent. The output is a working, human-reviewed codebase built through iterative AI-assisted development: spec first, generate, test, refine. Covers the full cycle from writing effective prompts through iterative refinement to production-ready code. [src1]

## Prerequisites

- [ ] **Product requirements or feature spec** — written user stories or feature descriptions
- [ ] **Project scaffold** — existing codebase from [Coded MVP Architecture Templates](/software/mvp-development/coded-mvp-architecture-templates/2026)
- [ ] **AI coding tool installed** — Claude Code (`npm install -g @anthropic-ai/claude-code`), Cursor (download from [cursor.com](https://cursor.com)), or browser tool account
- [ ] **Version control** — Git repository initialized with initial commit (critical for safe iteration)
- [ ] **Test framework** — Jest, Vitest, or pytest installed (AI-generated code must be tested)

## Constraints

- AI-generated code requires human review before deployment — treat AI output as a first draft, not production code. [src1]
- Context window limits affect output quality — Claude: 200K tokens, Cursor: chunked context. Provide focused, relevant context rather than entire codebases. [src5]
- Bolt.new and Replit Agent generate opinionated code — refactoring to match existing architecture may take as long as writing from scratch for complex features. [src3]
- AI tools hallucinate API signatures and library methods — always verify against official documentation, especially for less popular libraries. [src6]
- Token costs scale with iteration — a typical MVP sprint consumes $5-30 in API costs depending on complexity and iteration count. [src1]

## Tool Selection Decision

```
Which tool?
├── Developer with existing codebase AND terminal workflow
│   └── PATH A: Claude Code — agentic, reads full codebase, runs tests
├── Developer who prefers IDE AND visual editing
│   └── PATH B: Cursor — inline edits, chat, agent mode, multi-file
├── Non-technical founder AND simple app (CRUD, landing page)
│   └── PATH C: Bolt.new — browser-based, generates full-stack from prompt
├── Semi-technical AND needs full IDE in browser
│   └── PATH D: Replit Agent — browser IDE, deployment built in
└── Unsure
    └── DEFAULT: Path B (Cursor) for developers, Path C (Bolt.new) for non-technical
```

| Path | Tool | Best For | Cost | Learning Curve | Output Quality |
|------|------|----------|------|---------------|----------------|
| A | Claude Code | Senior devs, complex refactoring, test-driven | Usage-based (~$5-20/session) | Medium | Highest (understands full codebase) |
| B | Cursor | All developers, daily coding, inline editing | $20/mo (Pro) | Low | High (IDE integration) |
| C | Bolt.new | Non-technical, quick prototypes, demos | $0-20/mo | Very low | Medium (needs hardening) |
| D | Replit Agent | Semi-technical, full-stack in browser | $0-25/mo | Low | Medium (opinionated stack) |

## Execution Flow

### Step 1: Write a Spec Before Prompting

**Duration**: 15-30 minutes
**Tool**: Text editor / document

Write a structured specification before touching any AI tool. This is the highest-leverage step — a clear spec produces better AI output than clever prompting. [src7]

```markdown
# Feature Spec: [Feature Name]

## User Story
As a [role], I want to [action] so that [benefit].

## Acceptance Criteria
- [ ] User can [specific action 1]
- [ ] System responds with [specific behavior]
- [ ] Edge case: [what happens when X]
- [ ] Error state: [what user sees when Y fails]

## Technical Constraints
- Framework: [Next.js/React/Flask]
- Database: [Supabase/Firebase/PostgreSQL]
- Must integrate with: [existing component/API]
- Performance: [response time target]

## File Scope
- Modify: [list specific files to change]
- Create: [list new files needed]
- Do NOT modify: [files that should be left alone]
```

**Verify**: Spec covers happy path, edge cases, and error states. Another person (or AI) can understand what to build from the spec alone.
**If failed**: If the spec is vague, the AI output will be vague. Add concrete examples and acceptance criteria.

### Step 2: Set Up Project Context

**Duration**: 5-10 minutes
**Tool**: AI tool configuration

**Path A — Claude Code:** [src5]

```bash
# Create a CLAUDE.md file at project root
cat > CLAUDE.md << 'EOF'
# Project: [Name]
## Tech Stack
- Next.js 15 (App Router) + TypeScript
- Supabase (PostgreSQL + Auth)
- Tailwind CSS + shadcn/ui

## Architecture Rules
- Server components by default, "use client" only for interactivity
- All database access through Supabase client in lib/supabase/
- API routes in app/api/ follow RESTful conventions
- Use Zod for all input validation

## Testing
- Vitest for unit tests in __tests__/ directories
- Test files named [component].test.ts

## Do NOT
- Modify middleware.ts without explicit instruction
- Use any CSS framework other than Tailwind
- Create files outside the app/ or lib/ directories
EOF

# Start Claude Code with the spec
claude
# Then paste: "Read CLAUDE.md and the feature spec, then implement [feature]"
```

**Path B — Cursor:** [src2]

```
# Create .cursorrules at project root
# This file provides persistent context for all Cursor interactions

You are working on a Next.js 15 App Router project with Supabase.
- Use TypeScript strict mode
- Server components by default
- Tailwind CSS for styling
- Supabase client in lib/supabase/
- Test with Vitest
- Follow existing code patterns in the codebase
```

**Path C — Bolt.new:**

```
# Paste this as your initial prompt in Bolt.new:

Build a [app type] with the following features:
1. [Feature 1 with specific details]
2. [Feature 2 with specific details]

Tech requirements:
- Next.js with TypeScript
- Tailwind CSS for styling
- Supabase for database and auth
- Mobile-responsive design

Start with [most important feature] first.
```

**Verify**: AI tool acknowledges the context and can reference project structure.
**If failed**: For Claude Code, ensure CLAUDE.md is in the project root. For Cursor, verify .cursorrules is loaded (check in Settings > Rules).

### Step 3: Generate Code Iteratively

**Duration**: 1-4 hours (main development loop)
**Tool**: Selected AI tool

Follow the Plan-Generate-Test-Refine loop: [src1] [src4]

```
ITERATION LOOP (repeat per feature):
┌─────────────────────────────────────────┐
│ 1. PLAN: Describe what to build         │
│    → Be specific about files & behavior │
│                                         │
│ 2. GENERATE: Let AI write the code      │
│    → Review diff before accepting       │
│                                         │
│ 3. TEST: Run the code immediately       │
│    → npm run dev + manual test          │
│    → npm test for automated tests       │
│                                         │
│ 4. REFINE: Fix issues with feedback     │
│    → "The login form submits but the    │
│       redirect goes to / instead of     │
│       /dashboard. Fix the redirect      │
│       in handleSubmit."                 │
│                                         │
│ 5. COMMIT: Save working state to Git    │
│    → git add . && git commit            │
│    → This creates a restore point       │
└─────────────────────────────────────────┘
```

**Effective prompting patterns:** [src1] [src6]

```
GOOD: "Add a POST /api/items endpoint that accepts {title: string,
description?: string}, validates with Zod, inserts into the items
table via Supabase, and returns the created item. Include error
handling for duplicate titles (409) and missing fields (400)."

BAD: "Add an API endpoint for items."

GOOD: "The dashboard page at app/(dashboard)/page.tsx should show
a table of items with columns: title, status, created_at. Add
sorting by created_at descending. Use the existing TableComponent
from components/ui/table."

BAD: "Make a dashboard that shows items."
```

**After each AI response:** [src5]
1. Read the generated code (do not blindly accept)
2. Check imports and dependencies are correct
3. Run the development server to test
4. If wrong, provide specific feedback with the exact error message
5. Commit working states to Git frequently

**Verify**: Feature works as specified in acceptance criteria. Automated tests pass.
**If failed**: Share the exact error message with the AI. Provide more context about the existing codebase. Try breaking the request into smaller pieces.

### Step 4: Review and Harden

**Duration**: 30-60 minutes
**Tool**: Code editor + testing tools

```bash
# Run the full test suite
npm test

# Check for TypeScript errors
npx tsc --noEmit

# Run linting
npm run lint

# Check for security issues in dependencies
npm audit

# Review AI-generated code for:
# 1. Hardcoded values that should be environment variables
# 2. Missing error handling
# 3. SQL injection or XSS vulnerabilities
# 4. Proper input validation
# 5. Unused imports or dead code
```

Prompt the AI to write tests for the code it generated:

```
"Write Vitest tests for the items API route at app/api/items/route.ts.
Test: successful creation, missing required fields (400), duplicate
title (409), unauthorized access (401). Use the test patterns from
__tests__/example.test.ts."
```

**Verify**: All tests pass. TypeScript compilation succeeds. No linting errors. No `npm audit` critical vulnerabilities.
**If failed**: Fix issues iteratively using the AI tool. Provide test failure output as context for the fix.

### Step 5: Optimize and Deploy

**Duration**: 15-30 minutes
**Tool**: CLI + hosting platform

```bash
# Build the production version
npm run build

# Check bundle size
npx @next/bundle-analyzer

# Deploy to staging
npx vercel --preview

# Run Lighthouse audit
npx lighthouse https://staging-url.vercel.app --output=json
```

Use AI to optimize any performance issues found:

```
"The Lighthouse audit shows a 3.2s LCP. The main issue is the
items list loading on the client side. Convert the dashboard page
to a server component that fetches items server-side with Supabase,
and only use client components for interactive elements like the
sort controls."
```

**Verify**: Production build succeeds without errors. Lighthouse Performance score > 80. Staging deployment works.
**If failed**: Check build logs for errors. Common issues: "use client" components importing server-only modules, missing environment variables in build environment.

## Output Schema

```json
{
  "output_type": "ai_generated_codebase",
  "format": "code repository + deployed URL",
  "columns": [
    {"name": "repository_url", "type": "string", "description": "Git repository with AI-generated code", "required": true},
    {"name": "staging_url", "type": "string", "description": "Deployed staging environment", "required": true},
    {"name": "features_implemented", "type": "string", "description": "List of features built with AI assistance", "required": true},
    {"name": "test_coverage", "type": "number", "description": "Percentage of code covered by tests", "required": false},
    {"name": "ai_tool_used", "type": "string", "description": "Primary AI tool used (Claude Code/Cursor/Bolt/Replit)", "required": true},
    {"name": "total_iterations", "type": "number", "description": "Number of generate-test-refine cycles", "required": false}
  ],
  "expected_row_count": "1",
  "sort_order": "N/A",
  "deduplication_key": "repository_url"
}
```

## Quality Benchmarks

| Quality Metric | Minimum Acceptable | Good | Excellent |
|---------------|-------------------|------|-----------|
| Code review pass rate | > 70% of AI code accepted as-is | > 85% | > 95% |
| Test coverage on AI-generated code | > 40% | > 70% | > 85% |
| Iteration count per feature | < 8 cycles | < 5 cycles | < 3 cycles |
| Build success rate | Builds without errors | Zero TypeScript errors | Zero lint warnings |
| Time savings vs manual coding | 20% faster | 40% faster | 60% faster |

**If below minimum**: Improve prompt specificity. Provide more context (file content, error messages, examples). Consider switching tools — Claude Code for complex logic, Cursor for routine features, Bolt.new for prototypes.

## Error Handling

| Error | Likely Cause | Recovery Action |
|-------|-------------|----------------|
| AI generates code using deprecated API | Training data cutoff or outdated patterns | Provide current API docs as context: "Use the v2 API. Here's the current signature: [paste from docs]" |
| AI modifies files it shouldn't | Insufficient constraints in system prompt | Add explicit exclusion rules in CLAUDE.md or .cursorrules |
| Generated code doesn't compile | Missing imports or type mismatches | Share the full error output with AI: "Fix this TypeScript error: [paste error]" |
| AI generates different code style than project | No style guide in context | Add code examples to project rules: "Follow the pattern in src/components/Button.tsx" |
| Rate limit exceeded (429) | Too many API requests | Wait for rate limit reset. For Claude Code, use batch mode. For Cursor, use slow requests. |
| AI output quality degrades mid-session | Context window filled with irrelevant content | Start a new chat/session. Provide fresh context with only relevant files. |

## Cost Breakdown

| Component | Free Tier | Standard ($20-40/mo) | Heavy Use ($50+/mo) |
|-----------|-----------|----------------------|---------------------|
| Claude Code (API) | $5 initial credit | ~$10-20/sprint (usage-based) | ~$30-50/sprint |
| Cursor Pro | 50 slow requests/mo free | $20/mo (500 fast requests) | $40/mo (Business) |
| Bolt.new | Limited generations | $20/mo (Pro) | $50/mo (Team) |
| Replit | Limited Agent runs | $25/mo (Core) | $50/mo (Teams) |
| GitHub Copilot (supplement) | Free for OSS/students | $10/mo (Individual) | $19/mo (Business) |
| **Total per sprint** | **$0-5** | **$20-40** | **$50-100** |

## Anti-Patterns

### Wrong: Prompting with vague, outcome-only descriptions
"Build me a dashboard" produces generic, low-quality code. The AI has no constraints on technology, style, or scope, resulting in output that needs extensive refactoring. [src1]

### Correct: Provide specific, constrained prompts
Include: target files, framework, component patterns, data sources, error handling requirements, and references to existing code patterns in the project.

### Wrong: Accepting AI output without reading it
Blindly accepting every AI suggestion leads to inconsistent code styles, security vulnerabilities (hardcoded secrets, missing input validation), and technical debt that compounds with each feature. [src5]

### Correct: Review every diff before accepting
Read generated code like a pull request. Check for: correct imports, proper error handling, consistent naming, no hardcoded values, and alignment with project architecture.

### Wrong: Having AI write the entire app in one prompt
Single-prompt full-app generation (common with Bolt.new and Replit) produces a working prototype but architecturally fragile code that is difficult to extend or debug. [src3]

### Correct: Build incrementally, one feature at a time
Scaffold first, then add features one by one. Commit between features. This produces maintainable code and makes it possible to revert individual features.

### Wrong: Not using Git commits between iterations
Without version control checkpoints, a bad AI refactor can destroy working code with no way to recover. [src5]

### Correct: Commit after every successful iteration
Use `git commit` after each working state. Use `git stash` before risky changes. Claude Code supports `/rewind` to restore previous states.

## When This Matters

Use this recipe when a developer or technical founder needs a structured methodology for building features with AI coding tools. Requires an existing project scaffold (or uses Bolt.new/Replit to create one). This recipe covers the workflow and prompting methodology — not the specific features to build or the tech stack to use.

## Related Units

- [Coded MVP Architecture Templates](/software/mvp-development/coded-mvp-architecture-templates/2026) — scaffold project before AI-assisted development
- [MVP Tech Stack Selection Guide](/software/mvp-development/mvp-tech-stack-selection-guide/2026) — choose stack before coding
- [Database Schema Design for MVPs](/software/mvp-development/database-schema-design-for-mvps/2026) — design schemas during development
- [Authentication & Authorization Setup](/software/mvp-development/authentication-authorization-setup/2026) — implement auth features
- [Landing Page Platform Deployment](/software/landing-pages/landing-page-platform-deployment/2026) — deploy the finished product
