Skip to main content

What You'll Build

A complete database development workflow that uses Continue CLI with Prisma MCP to design schemas, generate migrations, seed data, and manage your PostgreSQL database - all through natural language prompts.

What Youโ€™ll Learn

This cookbook teaches you to:
  • Use Prisma Remote MCP to build database workflows
  • Design database schemas with AI assistance
  • Generate and apply migrations automatically
  • Create realistic seed data for development
  • Launch Prisma Studio for visual database management
  • Set up automated database health checks

Prerequisites

Before starting, ensure you have:
  • Node.js 18+ installed locally
  • Continue CLI with active credits (required for API usage)
  • Basic understanding of SQL and database concepts
  • A project directory where you want to set up your database
1

Install Continue CLI

npm i -g @continuedev/cli
2

Set up Continue CLI Account & API Key

  1. Visit Continue Organizations
  2. Sign up or log in to your Continue account
  3. Navigate to your organization settings
  4. Click โ€œAPI Keysโ€ and then โ€+ New API Keyโ€
  5. Copy the API key immediately (you wonโ€™t see it again!)
  6. Login to the CLI: cn login
3

Add Prisma Secrets to Continue Hub

For the Prisma Remote MCP to work, you need to authenticate with Prisma:
  1. Visit Continue Hub Secrets
  2. Click โ€+ Add Secretโ€
  3. Add your Prisma authentication token:
    • Key: prisma/prisma-remote-mcp/PRISMA_AUTH_TOKEN
    • Value: Your Prisma auth token (get from Prisma Console)
The Prisma Remote MCP runs on Prismaโ€™s hosted infrastructure and requires authentication to access your databases and projects.
Continue CLI with Prisma Remote MCP can generate complete database schemas, write migrations, and even create realistic seed data - you just describe what you need!

Step 1: Set Up Your Database

  • Prisma Postgres Setup
  • Local PostgreSQL
Prisma MCP works with any PostgreSQL database, including Prisma Postgres:
  1. Create a Prisma Account (optional, for hosted databases)
  2. Authenticate via Continue CLI Prompt:
    Log me into the Prisma Console
    
    The AI will use the Prisma-Login tool to authenticate.
  3. Create a Database Prompt:
    Create a new Prisma Postgres database in the US region for my e-commerce project
    
You can also use any PostgreSQL database by configuring your connection string in .env:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"

Prisma Database Workflow Options

Fastest Path to Success

Skip the manual setup and use our pre-built Prisma Continuous AI agent that includes optimized prompts, rules, and the Prisma MCP for consistent database development.
How Prisma Remote MCP Works:
  • Connects to Prismaโ€™s hosted MCP server via mcp-remote
  • Runs on Prismaโ€™s infrastructure (no local installation required)
  • Provides tools for migrations, schema management, and database operations
  • Integrates with Prisma Studio for visual database exploration
  • Includes AI safety guardrails to prevent accidental data loss
Available Prisma Remote MCP Tools:
  • migrate-status - Check migration status
  • migrate-dev - Create and execute migrations
  • migrate-reset - Reset the database
  • Prisma-Postgres-account-status - Check authentication
  • Create-Prisma-Postgres-Database - Provision new databases
  • Prisma-Login - Authenticate with Prisma
  • Prisma-Studio - Launch the data explorer
Installation: Add Prisma Remote MCP from Continue Hub
To use the pre-built agent, you need either:
  • Continue CLI Pro Plan with the models add-on, OR
  • Your own API keys added to Continue Hub secrets
The agent will automatically detect and use your configuration. For Prisma Remote MCP:
  • Prisma authentication token added to Continue Hub secrets
  • PostgreSQL database (local or hosted via Prisma Postgres)
  • Prisma Remote MCP connects to Prismaโ€™s hosted infrastructure (no local installation required)

AI Safety Guardrails: Prisma detects when destructive commands like prisma migrate reset --force are invoked through AI agents and requires explicit user consent before proceeding.

Step 2: Design Your Database Schema with AI

Use Continue CLI to design your database schema through natural language prompts.
  • E-commerce Schema
  • SaaS Application Schema
  • Blog Platform Schema
Prompt:
Design a complete e-commerce database schema with:

Tables:
- Users (authentication, profiles, addresses)
- Products (variants, inventory, categories)
- Orders (line items, status tracking, shipping)
- Reviews (ratings, comments, helpful votes)
- Carts (temporary shopping carts)

Requirements:
- Use UUIDs for all IDs
- Add proper relationships (foreign keys)
- Include created_at and updated_at timestamps
- Add soft deletes for users and products
- Create indexes for:
  * Product searches (name, category)
  * Order lookups (user_id, status, created_at)
  * Review queries (product_id, user_id)

Generate the Prisma schema and initial migration.
Prisma Remote MCP Capabilities for Schema Design:
  • Validates schema syntax automatically
  • Suggests optimal data types and relationships
  • Recommends indexes based on query patterns
  • Warns about potential performance issues
  • Leverages Prismaโ€™s hosted AI models for enhanced schema recommendations

Step 3: Generate and Apply Migrations

Create database migrations from your schema design and apply them safely. Example: Complete Migration Workflow
I've designed my Prisma schema. Now I need to:

1. Check the current migration status
2. Create a new migration named "initial_schema"
3. Review the generated SQL before applying
4. Apply the migration to the database
5. Verify all tables were created correctly

For the migration:
- Include all schema changes
- Add helpful comments in the SQL
- Show me the migration file contents
- Confirm the migration was applied successfully

Database: PostgreSQL
Environment: Development
Expected Output: The AI will:
  • Run prisma migrate status to check current state
  • Generate migration with prisma migrate dev --name initial_schema
  • Show you the SQL file contents for review
  • Apply the migration automatically
  • Verify tables exist using database inspection
Best Practice: Always review AI-generated migrations before applying to production. Test in development first!

Step 4: Seed Your Database with Realistic Data

Generate realistic seed data for development and testing.
  • E-commerce Seed Data
  • SaaS Seed Data
Prompt:
Create a comprehensive seed script for my e-commerce database:

Generate:
- 50 users with realistic names and emails
- 200 products across 10 categories
  * Include product variants (size, color)
  * Set realistic prices and inventory
- 100 orders with random items
  * Various order statuses (pending, shipped, delivered)
  * Created at different dates over the past 6 months
- 300 product reviews
  * Ratings from 1-5 stars
  * Realistic review text
  * Mix of helpful/not helpful votes

Requirements:
- Use realistic fake data (not just "User 1", "Product 1")
- Maintain referential integrity
- Distribute data realistically (more delivered than pending orders)
- Add some edge cases (cancelled orders, out-of-stock items)

Create the seed.ts file and show me how to run it.
Prisma Seed Best Practices:
  • Use faker or similar libraries for realistic data
  • Run seeds in transactions for consistency
  • Make seeds idempotent (safe to run multiple times)
  • Include edge cases and test scenarios

Step 5: Launch Prisma Studio for Visual Management

Use Prisma Studio to visually explore and manage your database. Prompt:
Launch Prisma Studio so I can visually inspect my database tables and data
The AI will:
  • Run prisma studio command
  • Open Studio in your browser (usually http://localhost:5555)
  • Show you how to navigate the interface
Prisma Studio Features:
  • Browse all tables and relationships
  • Edit records directly
  • Filter and search data
  • View relationship connections visually

Step 6: Automate Database Health Checks

Set up automated database monitoring with Continue CLI and GitHub Actions:
name: Database Health Monitor

on:
  push:
    branches:
      - main
    paths:
      - 'prisma/**'
  pull_request:
    paths:
      - 'prisma/**'
  schedule:
    # Run daily at 3 AM UTC
    - cron: "0 3 * * *"
  workflow_dispatch: # Allow manual triggers

jobs:
  check-database-health:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: Install Dependencies
        run: |
          npm install
          npm install -g @continuedev/cli
          echo "โœ… Dependencies installed"

      - name: Setup Database
        env:
          DATABASE_URL: ${{ secrets.DATABASE_URL }}
        run: |
          npx prisma migrate deploy
          echo "โœ… Migrations applied"

      - name: Analyze Database Schema
        env:
          CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }}
          DATABASE_URL: ${{ secrets.DATABASE_URL }}
        run: |
          echo "๐Ÿ” Analyzing database health..."

          cn -p "Using Prisma MCP, perform a comprehensive database health check:

                 1. Migration Status:
                    - Check if all migrations are applied
                    - Identify pending migrations
                    - Detect migration conflicts

                 2. Schema Analysis:
                    - Verify all foreign key relationships are valid
                    - Check for missing indexes on foreign keys
                    - Identify tables without primary keys
                    - Find unused indexes (if possible)

                 3. Data Integrity:
                    - Check for orphaned records (broken foreign keys)
                    - Verify required fields don't have nulls
                    - Identify duplicate records in unique columns

                 4. Performance Review:
                    - Suggest missing indexes based on schema
                    - Identify large tables that might need partitioning
                    - Check for inefficient data types

                 5. Best Practices:
                    - Verify created_at/updated_at timestamps exist
                    - Check for soft delete implementations
                    - Ensure proper enum usage

                 Generate a detailed health report with:
                 - Critical issues that need immediate attention
                 - Warnings for potential problems
                 - Optimization suggestions
                 - SQL scripts to fix identified issues

                 If critical issues are found, fail the workflow."

      - name: Save Health Report
        if: always()
        run: |
          echo "## ๐Ÿ“Š Database Health Report" >> $GITHUB_STEP_SUMMARY
          echo "Generated at $(date)" >> $GITHUB_STEP_SUMMARY
          echo "" >> $GITHUB_STEP_SUMMARY
          echo "Check the 'Analyze Database Schema' step for the full report" >> $GITHUB_STEP_SUMMARY

      - name: Upload Health Report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: database-health-report
          path: |
            *.md
            *.sql
Required GitHub Secrets:Add these at: Repository Settings โ†’ Secrets and variables โ†’ Actions

What Youโ€™ve Built

After completing this guide, you have a complete AI-powered database development workflow that:
  • Designs schemas - AI generates complete database schemas from natural language descriptions
  • Creates migrations - Automatically generates and applies database migrations
  • Seeds data - Generates realistic test data for development
  • Monitors health - Runs automated checks for schema issues and performance problems
  • Visual management - Provides GUI access via Prisma Studio

Continuous AI Database Development

Your system now operates at Level 2 Continuous AI - AI handles schema design and migration generation with human oversight for production deployments.

Advanced Database Development Prompts

Enhance your workflow with these advanced Continue CLI prompts:

Schema Evolution

Analyze existing schema and suggest improvements for scalability, including partitioning strategies and denormalization opportunities

Query Optimization

Review slow queries and generate optimized indexes, explain plans, and query rewrites

Data Migration

Generate data transformation scripts when changing schema structure (e.g., splitting tables, normalizing data)

Backup & Recovery

Create backup strategies and generate recovery scripts for disaster scenarios

Real-World Use Cases

Use Case 1: Adding Multi-Tenancy to Existing Schema

Prompt:
I need to add multi-tenancy to my existing database schema:

Current tables: users, products, orders

Requirements:
- Add an organizations table
- Link all existing tables to organizations
- Ensure data isolation between tenants
- Migrate existing data to a default organization
- Add organization_id to all relevant indexes

Generate:
1. Updated Prisma schema with multi-tenant support
2. Migration to add organization_id columns
3. Data migration script to populate organization_id
4. Updated seed script with multi-tenant data
5. Queries demonstrating tenant isolation
Prompt:
Add full-text search to my blog platform:

Tables: posts (title, content), comments (text)

Requirements:
- Use PostgreSQL full-text search capabilities
- Create search indexes for posts and comments
- Add search ranking/relevance
- Support phrase matching and stemming
- Highlight matching terms in results

Generate:
1. Migration to add tsvector columns and GIN indexes
2. Prisma schema updates
3. Example search queries using raw SQL
4. Helper functions for search in TypeScript

Use Case 3: Implementing Audit Logging

Prompt:
Add comprehensive audit logging to track all data changes:

Tables to audit: users, orders, products

Requirements:
- Record all INSERT, UPDATE, DELETE operations
- Store: who made changes, when, what changed, old/new values
- Implement using PostgreSQL triggers or application-level
- Query audit history for specific records
- Implement data retention policy (keep 90 days)

Generate:
1. Audit log table schema
2. Triggers or Prisma middleware for logging
3. Queries to view audit history
4. Cleanup script for old audit records

Security Best Practices

Database Security Guidelines:
  • Never commit .env files with database credentials
  • Use environment variables for all sensitive configuration
  • Implement row-level security (RLS) for multi-tenant apps
  • Review all AI-generated SQL before running in production
  • Use read replicas for analytics queries
  • Enable SSL/TLS for database connections
  • Regularly rotate database passwords
  • Use least-privilege database users for applications

Troubleshooting

Prisma Remote MCP Connection Issues

If you encounter issues with Prisma Remote MCP:
  1. Verify your PRISMA_AUTH_TOKEN is correctly set in Continue Hub Secrets
  2. Check that the secret key is exactly: prisma/prisma-remote-mcp/PRISMA_AUTH_TOKEN
  3. Ensure you have network connectivity to https://mcp.prisma.io
  4. Verify your Prisma account has access to the database at Prisma Console
  5. Check your DATABASE_URL is correctly set in .env (for local Prisma CLI operations)

Common Migration Issues

IssueSolution
Migration conflictsReset development database with prisma migrate reset
Schema drift detectedRun prisma migrate dev to sync schema with database
Connection refusedVerify DATABASE_URL and database is running
Permission deniedCheck database user has CREATE/ALTER privileges

AI Safety Guardrails

When Prisma Remote MCP detects destructive operations (like migrate reset):
  1. Youโ€™ll see a confirmation prompt
  2. Review what will be deleted
  3. Type โ€œyesโ€ to confirm or โ€œnoโ€ to cancel
  4. The AI will wait for your response before proceeding
This safety feature prevents accidental data loss when AI agents run database commands. The Prisma Remote MCP enforces these guardrails on the server side for enhanced security.

Next Steps

Resources