跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 prisma-postgres-setup

Prisma Postgres 设置

建立一个新的Prisma Postgres数据库,并使用管理API连接到本地项目. 当被要求"设置数据库","创建一个Prisma Postgres项目","获得连接字符串","连接我的应用到Prisma Postgres",或"提供数据库"时使用.

295835 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

建立一个新的 Prisma Postgres 数据库,并将其连接到使用管理 API 的本地项目

何时用

请求“设置数据库”、“创建 Prisma Postgres 工程”、“ 获得连接字符串”、“ 连接我的应用程序到 Prisma Postgres ” 或“ 提供数据库”

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Prisma Postgres Setup、When to Apply、Prerequisites、UX Guidelines、Workflow、Step 1: Authenticate。 其中含规范建议的小节:分步指令。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/auth.md、references/endpoints.md、references/prisma7-client.md、references/api-basics.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Set up a new Prisma Postgres database and connect it to a local project using the Management API. Use when asked to "set up a database", "create a Prisma Postgres project", "get a connection string", "connect my app to Prisma Postgres", or "provision a database".

Prisma Postgres SetupWhen to ApplyPrerequisitesUX GuidelinesWorkflowStep 1: AuthenticateStep 2: List available regionsStep 3: Create a project with a databaseStep 4: Create a named connection (optional)Step 5: Configure the local projectStep 6: Define schema and pushStep 7: Verify the connection

· 许可:MIT

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
prisma-postgres-setup
description
Set up a new Prisma Postgres database and connect it to a local project using the Management API. Use when asked to "set up a database", "create a Prisma Postgres project", "get a connection string", "connect my app to Prisma Postgres", or "provision a database".
许可
MIT
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 4
  • references/auth.md
  • references/endpoints.md
  • references/prisma7-client.md
  • references/api-basics.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「prisma-postgres-setup」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-b2b674f98fabe9c9-Prisma-Postgres-%E8%AE%BE%E7%BD%AE.html
请存为 .cursor/skills/prisma-postgres-setup/SKILL.md 或 .claude/skills/prisma-postgres-setup/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/prisma/skills 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/prisma/skills' --list

npx skills add 'https://github.com/prisma/skills' --skill 'prisma-postgres-setup'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: prisma-postgres-setup description: Set up a new Prisma Postgres database and connect it to a local project using the Management API. Use when asked to "set up a database", "create a Prisma Postgres project", "get a connection string", "connect my app to Prisma Postgres", or "provision a database". license: MIT metadata: author: prisma version: "1.1.0" --- # Prisma Postgres Setup Procedural skill that guides you through provisioning a new Prisma Postgres database via the Management API and connecting it to a local project. ## When to Apply Use this skill when: - Setting up a new Prisma Postgres database for a project - Creating a Prisma Postgres project and connecting it locally - Obtaining a connection string for Prisma Postgres - Provisioning a database via the Management API (not the Console UI) Do **not** use this skill when: - Setting up CI/CD preview databases — use `prisma-postgres-cicd` - Building multi-tenant database provisioning into an app — use `prisma-postgres-integrator` - Working with a database that already exists and is connected (schema/migration tasks are standard Prisma CLI) ## Prerequisites - Node.js 18+ - A Prisma Postgres workspace (create one at https://console.prisma.io if needed) - A workspace service token (see `references/auth.md`) ## UX Guidelines When presenting choices to the user (region selection, project deletion, etc.), **use your platform's interactive selection mechanism** (e.g., `ask` tool in Claude Code, structured prompts in other agents). Do not print static tables and ask the user to type a value — present selectable options so the user can pick with minimal effort. ## Workflow Follow these steps in order. Each step includes the API call to make and how to handle the response. ### Step 1: Authenticate You need a service token. Try these methods in order: **1a. Token in the user's prompt** Check if the user included a service token in their initial message (e.g., "Set up Prisma Postgres with token eyJ..."). If so, use it **exactly as provided** — do not truncate, re-encode, or round-trip it through a file. Store it in a shell variable for subsequent calls. **1b. Token in the environment** Check for `PRISMA_SERVICE_TOKEN` in the environment or `.env` file. **1c. Ask the user to create one** If no token is available, instruct the user: > Create a service token in Prisma Console → Workspace Settings → Service Tokens. > Copy the token and paste it here. Read `references/auth.md` for details on service token creation. Once you have a token, store it in a shell variable (`PRISMA_SERVICE_TOKEN`) and use it for all subsequent API calls. ### Step 2: List available regions Fetch the list of available Prisma Postgres regions to let the user choose where to deploy. ```bash curl -s -H "Authorization: Bearer $PRISMA_SERVICE_TOKEN" \ https://api.prisma.io/v1/regions/postgres ``` The response contains an array of regions with `id`, `name`, and `status`. Only present regions where `status` is `available`. **Present the regions as an interactive menu** — let the user pick from options rather than typing a region ID manually. Read `references/endpoints.md` for the full response shape. ### Step 3: Create a project with a database ```bash curl -s -X POST https://api.prisma.io/v1/projects \ -H "Authorization: Bearer $PRISMA_SERVICE_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "", "region": "", "createDatabase": true }' ``` Use the current directory name as the project name by default. The response is wrapped in `{ "data": { ... } }`. Extract: - `data.id` — the project ID (prefixed with `proj_`) - `data.database.id` — the database ID (prefixed with `db_`) - `data.database.connections[0].endpoints.direct.connectionString` — the direct PostgreSQL connection string Use the **direct** connection string (`endpoints.direct.connectionString`). Do not use the pooled or accelerate endpoints — those are for legacy Accelerate setups and not needed for new projects. If the response status is `provisioning`, wait a few seconds and poll `GET /v1/databases/` until `status` is `ready`. **If creation fails due to a database limit**, list the user's existing projects and present them as an interactive menu for deletion. After the user picks one, delete it and retry. Read `references/endpoints.md` for the full request/response shapes. ### Step 4: Create a named connection (optional) If you need a dedicated connection (e.g., per-developer or per-environment), create one: ```bash curl -s -X POST https://api.prisma.io/v1/databases//connections \ -H "Authorization: Bearer $PRISMA_SERVICE_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "dev" }' ``` Extract the direct connection string from `data.endpoints.direct.connectionString`. ### Step 5: Configure the local project 1. Install dependencies: ```bash npm install prisma @prisma/client @prisma/adapter-pg pg dotenv ``` All five packages are required: - `prisma` — CLI for migrations, schema push, client generation - `@prisma/client` — the generated query client - `@prisma/adapter-pg` — Prisma 7 driver adapter for direct PostgreSQL connections - `pg` — Node.js PostgreSQL driver (used by the adapter) - `dotenv` — loads `.env` variables for `prisma.config.ts` 2. Write the direct connection string to `.env`. **Append** to the file if it already exists — do not overwrite existing entries: ``` DATABASE_URL="" ``` 3. Verify `.gitignore` includes `.env`. Create `.gitignore` if it does not exist. Warn the user if `.env` is not gitignored. 4. Ensure `package.json` has `"type": "module"` set (Prisma 7 generates ESM output). 5. If `prisma/schema.prisma` does not exist, run `npx prisma init` to scaffold the project. This creates both `prisma/schema.prisma` and `prisma.config.ts`. 6. Ensure `schema.prisma` has the `postgresql` provider and **no** `url` or `directUrl` in the datasource block (Prisma 7 manages connection URLs in `prisma.config.ts`, not in the schema): ```prisma datasource db { provider = "postgresql" } ``` 7. Ensure `prisma.config.ts` loads the connection URL from the environment: ```typescript import path from 'node:path' import { defineConfig } from 'prisma/config' import 'dotenv/config' export default defineConfig({ earlyAccess: true, schema: path.join(import.meta.dirname, 'prisma', 'schema.prisma'), datasource: { url: process.env.DATABASE_URL!, }, }) ``` **Important Prisma 7 notes:** - Connection URLs go in `prisma.config.ts`, never in `schema.prisma` - The provider in `schema.prisma` must be `"postgresql"` (not `"prismaPostgres"`) - `dotenv/config` must be imported in `prisma.config.ts` to load `.env` variables ### Step 6: Define schema and push If the schema already has models, skip to pushing. Otherwise, **present these options as an interactive menu**: 1. **"I'll define my schema manually"** — Tell the user to edit `prisma/schema.prisma` and come back when ready. Wait for them before proceeding. 2. **"Give me a starter schema"** — Add a Blog starter schema (User, Post, Comment with relations) to `prisma/schema.prisma`. Show the user what was added and ask if they want to adjust it before pushing. 3. **"I'll describe what I need"** — Ask the user to describe their data model in natural language (e.g., "I'm building a task manager with projects, tasks, and team members"). Generate a schema from the description, show it, and ask for confirmation before pushing. Once the schema has models and the user is ready, create a migration and generate the client: ```bash npx prisma migrate dev --name init ``` This creates migration files in `prisma/migrations/` **and** generates the client in one step. Migration history is essential for CI/CD workflows (`prisma migrate deploy`) and production deployments. Only use `npx prisma db push` if the user explicitly asks for prototyping-only mode (no migration history). In that case, follow it with `npx prisma generate`. ### Step 7: Verify the connection After generating the client, create and run a quick verification script to confirm everything works end-to-end. This is **critical** — do not skip this step. Create a file named `test-connection.ts`: ```typescript import 'dotenv/config' import pg from 'pg' import { PrismaPg } from '@prisma/adapter-pg' import { PrismaClient } from './generated/prisma/client.js' const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL }) const adapter = new PrismaPg(pool) const prisma = new PrismaClient({ adapter }) const result = await prisma.$queryRawUnsafe('SELECT 1 as connected') console.log('Connected to Prisma Postgres:', result) await prisma.$disconnect() await pool.end() ``` Run it: ```bash npx tsx test-connection.ts ``` **Prisma 7 client instantiation rules:** - Import from `./generated/prisma/client.js` (not `./generated/prisma`) - Create a `pg.Pool` with the `DATABASE_URL` connection string - Wrap it in a `PrismaPg` adapter - Pass `{ adapter }` to the `PrismaClient` constructor - Do **not** use `datasourceUrl` — that option does not exist in Prisma 7 - Do **not** use `new PrismaClient()` with no arguments — it will throw After verification succeeds, delete `test-connection.ts`. Then share links for the user to explore their database: - **Prisma Studio (CLI):** `npx prisma studio` — opens a visual data browser locally - **Console:** `https://console.prisma.io////dashboard` — strip the prefixes (`wksp_`, `proj_`, `db_`) from the IDs returned in Step 3 to build this URL Read `references/prisma7-client.md` for the full client instantiation reference. ## Error Handling Read `references/api-basics.md` for the full error reference. Key self-correction patterns: | HTTP Status | Error Code | Action | |---|---|---| | 401 | `authentication-failed` | Service token is invalid or expired. Ask the user to create a new one in Console → Workspace Settings → Service Tokens. | | 404 | `resource-not-found` | Check that the resource ID includes the correct prefix (`proj_`, `db_`, `con_`). | | 422 | `validation-error` | Check request body against the endpoint schema. Common: missing `name`, invalid `region`. | | 429 | `rate-limit-exceeded` | Back off and retry after a few seconds. | ## Reference Files Detailed API and usage information is in: ``` references/auth.md — Service token creation and usage references/api-basics.md — Base URL, envelope, IDs, errors, pagination references/endpoints.md — Endpoint details for projects, databases, connections, regions references/prisma7-client.md — Prisma 7 client instantiation and usage patterns ```

相关技能

Agent 工作流

技能创建者Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

克劳德胡布Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

团队指挥Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

超级力量Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…