planetscale

为 PlanetScale 提供专家级指导——基于 Vitess 的无服务器 MySQL 平台。帮助开发者使用类似 Git 的分支功能进行数据库架构变更,实现非阻塞的架构迁移,并为无服务器环境提供连接池支持。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
7

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "planetscale":https://skillpi.com/zh/skills/deepskill-e0bf0268d54bf8f574b0e4b303a94656da12dd14e63e1deac6bdc1a8f4247243。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 PlanetScale 提供专家级指导——基于 Vitess 的无服务器 MySQL 平台。帮助开发者使用类似 Git 的分支功能进行数据库架构变更,实现非阻塞的架构迁移,并为无服务器环境提供连接池支持。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: planetscale
description: Expert guidance for PlanetScale, the serverless MySQL platform built on Vitess (the database clustering system powering YouTube). Helps developers set up databases with Git-like branching for schema changes, non-blocking schema migrations, and connection pooling for serverless environments.
license: Apache-2.0
compatibility: No special requirements
metadata:
  author: terminal-skills
  version: 1.0.0
  category: development
  tags:
  - database
  - mysql
  - serverless
  - branching
  - schema-change

PlanetScale — Serverless MySQL Platform

Overview

PlanetScale, the serverless MySQL platform built on Vitess (the database clustering system powering YouTube). Helps developers set up databases with Git-like branching for schema changes, non-blocking schema migrations, and connection pooling for serverless environments.

Instructions

CLI Operations

# Install PlanetScale CLI
brew install planetscale/tap/pscale

# Authenticate
pscale auth login

# Create a database
pscale database create my-app --region us-east

# Connect to your database (opens a local proxy)
pscale connect my-app main --port 3306
# Now connect your app to localhost:3306 with no password

# Create a branch (like git branch, for schema changes)
pscale branch create my-app add-orders-table

# Connect to the branch for testing
pscale connect my-app add-orders-table --port 3307

# Open a shell on the branch
pscale shell my-app add-orders-table

Schema Branching

-- On the "add-orders-table" branch, make schema changes safely
-- These changes don't affect the main branch until you merge

CREATE TABLE orders (
  id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  user_id BIGINT NOT NULL,
  amount DECIMAL(10, 2) NOT NULL,
  currency VARCHAR(3) NOT NULL DEFAULT 'USD',
  status ENUM('pending', 'processing', 'completed', 'refunded') NOT NULL DEFAULT 'pending',
  metadata JSON,
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX idx_user_id (user_id),
  INDEX idx_status_created (status, created_at)
);

-- Add columns to existing tables
ALTER TABLE users ADD COLUMN stripe_customer_id VARCHAR(255);
ALTER TABLE users ADD INDEX idx_stripe_customer (stripe_customer_id);
# Create a deploy request (like a pull request for schema changes)
pscale deploy-request create my-app add-orders-table

# Review the deploy request
pscale deploy-request diff my-app 1

# Deploy (non-blocking — zero downtime)
pscale deploy-request deploy my-app 1

# Schema changes are applied without locking tables
# PlanetScale uses Vitess's online DDL (gh-ost) under the hood

Application Integration

// src/lib/db.ts — Connect to PlanetScale
import { connect } from "@planetscale/database";

// Serverless driver (HTTP-based, works in edge functions)
const db = connect({
  host: process.env.DATABASE_HOST,
  username: process.env.DATABASE_USERNAME,
  password: process.env.DATABASE_PASSWORD,
});

// Query
async function getOrders(userId: string) {
  const results = await db.execute(
    "SELECT * FROM orders WHERE user_id = ? ORDER BY created_at DESC LIMIT 20",
    [userId]
  );
  return results.rows;
}

// Insert
async function createOrder(order: { userId: string; amount: number; currency: string }) {
  const result = await db.execute(
    "INSERT INTO orders (user_id, amount, currency) VALUES (?, ?, ?)",
    [order.userId, order.amount, order.currency]
  );
  return result.insertId;
}

// Transaction
async function processRefund(orderId: string) {
  await db.transaction(async (tx) => {
    await tx.execute(
      "UPDATE orders SET status = 'refunded' WHERE id = ? AND status = 'completed'",
      [orderId]
    );
    const order = await tx.execute("SELECT * FROM orders WHERE id = ?", [orderId]);
    await tx.execute(
      "INSERT INTO refunds (order_id, amount) VALUES (?, ?)",
      [orderId, order.rows[0].amount]
    );
  });
}

With Prisma ORM

// prisma/schema.prisma — PlanetScale with Prisma
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider     = "mysql"
  url          = env("DATABASE_URL")
  relationMode = "prisma"    // Required: PlanetScale doesn't support foreign keys
}

model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String
  plan      String   @default("free")
  orders    Order[]
  createdAt DateTime @default(now()) @map("created_at")

  @@map("users")
}

model Order {
  id        Int      @id @default(autoincrement())
  userId    Int      @map("user_id")
  amount    Decimal  @db.Decimal(10, 2)
  status    String   @default("pending")
  user      User     @relation(fields: [userId], references: [id])
  createdAt DateTime @default(now()) @map("created_at")

  @@index([userId])
  @@index([status, createdAt])
  @@map("orders")
}
# Push schema changes via Prisma (on a branch)
pscale connect my-app add-orders-table --port 3309 &
DATABASE_URL="mysql://root@localhost:3309/my-app" npx prisma db push

Insights and Monitoring

# View query insights (slow queries, most frequent queries)
pscale query-insights my-app main

# View database size and row counts
pscale database show my-app

# Audit log
pscale audit-log list my-app

Installation

# CLI
brew install planetscale/tap/pscale

# Serverless driver (Node.js)
npm install @planetscale/database

# With Prisma
npm install prisma @prisma/client

Examples

Example 1: Setting up Planetscale with a custom configuration

User request:

I just installed Planetscale. Help me configure it for my TypeScript + React workflow with my preferred keybindings.

The agent creates the configuration file with TypeScript-aware settings, configures relevant plugins/extensions for React development, sets up keyboard shortcuts matching the user's preferences, and verifies the setup works correctly.

Example 2: Extending Planetscale with custom functionality

User request:

I want to add a custom schema branching to Planetscale. How do I build one?

The agent scaffolds the extension/plugin project, implements the core functionality following Planetscale's API patterns, adds configuration options, and provides testing instructions to verify it works end-to-end.

Guidelines

  1. Branch for every schema change — Never modify main directly; create a branch, test, then deploy via deploy request
  2. No foreign key constraints — PlanetScale (Vitess) doesn't support FK constraints; use relationMode = "prisma" or enforce in application code
  3. Serverless driver for edge — Use @planetscale/database (HTTP-based) for Vercel Edge, Cloudflare Workers; use mysql2 for Node.js servers
  4. Non-blocking migrations — PlanetScale applies ALTER TABLE without locking; deploy schema changes during business hours safely
  5. Deploy request review — Treat deploy requests like pull requests; review the diff before deploying to production
  6. Index before you need them — Add indexes on columns you filter/sort by; PlanetScale's query insights shows which queries need them
  7. Connection string from environment — Use pscale connect for local dev (no password needed); use connection strings in production
  8. Read replicas for read-heavy apps — PlanetScale supports read-only regions; route read queries to replicas for lower latency

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值92/100

亮点

  • 提供 PlanetScale 无服务器 MySQL 平台的完整专家级指导
  • 涵盖 CLI 操作、Schema 分支、应用集成等核心工作流
  • 解决零停机迁移、Git-like 分支管理等开发者核心痛点
触发精准95/100

亮点

  • 触发词精准覆盖 PlanetScale 平台特性
  • 明确区分于其他数据库工具,边界清晰
  • description 完整描述核心功能价值
结构规范95/100

待提升项

  • 缺少 When to Use 章节 原报告严重程度:轻微

    文档结构完整但缺少明确的 When to Use 使用场景说明章节

    改进建议:建议在 Guidelines 前添加 When to Use 章节,明确说明适用场景和使用时机

亮点

  • Phase/步骤划分清晰,逻辑连贯
  • 提供端到端完整示例,便于理解执行
  • frontmatter 完整,单文件长度符合规范
执行可靠90/100

亮点

  • 工具来源明确,参数格式正确
  • 覆盖主要异常场景和错误处理
  • 不可逆操作有确认机制,安全可靠
证据可验 (前四项均值)93/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。