Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

database数据库

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

267

周安装

11

GitHub Stars

168

下载量

87
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:database(数据库)
来源仓库:https://github.com/whawkinsiv/claude-code-skills
仓库路径:skills/database
安装命令:
npx skills add https://github.com/whawkinsiv/claude-code-skills --skill database
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/whawkinsiv/claude-code-skills --skill database

简介

database 用于辅助数据库表结构、查询语句和迁移脚本编写。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中分析 schema 或排查查询问题。
  • 通过 npx skills add 命令从指定仓库安装并使用。
  • 使用时需明确数据库类型和连接环境,区分只读分析与写入变更。
  • 涉及删除或批量导入时应优先 dry-run 或事务保护,避免误操作。

SKILL.md

Database & Data Modeling

Every SaaS app needs a database, and the schema decisions you make early are expensive to change later. This skill helps you choose the right database, design a clean schema, and set up security — explained without jargon.

Core Principles

  • Choose the database that matches your hosting platform. Don't fight the defaults.
  • Schema design is product design. Get the relationships right early — migrations are painful later.
  • Every SaaS app is multi-tenant. Every table needs a way to isolate customer data.
  • Start simple. You don't need Redis, Elasticsearch, or a data warehouse at $0-10k MRR.
  • Row Level Security is not optional. One leaked customer seeing another's data kills trust.

Choosing a Database

For Most Solo Founders: Use What Your Platform Gives You

Building WithDefault DatabaseUse It?
SupabasePostgreSQL (built-in)Yes — best option for most SaaS
Vercel + PrismaSupabase, Neon, or PlanetScaleYes — pick one, stick with it
LovableSupabase (integrated)Yes — don't fight the integration
ReplitSQLite or SupabaseSupabase for production SaaS
RailwayPostgreSQLYes
FirebaseFirestoreYes, if you're already in Google ecosystem

The short answer: Use Supabase (PostgreSQL) unless you have a specific reason not to. It gives you database + auth + storage + realtime + Row Level Security in one service.

When You Might Need Something Else

NeedConsider
Full-text searchSupabase has built-in text search. Only add Algolia/Typesense if it's not enough
CachingStart without it. Add Upstash Redis only when you have measurable latency issues
File storageSupabase Storage, Cloudflare R2, or S3
Analytics/reportingSupabase views or materialized views first. Data warehouse later (post-$10k MRR)

Schema Design for SaaS

The Three Tables Every SaaS Needs

-- 1. Users (who uses the app)
create table users (
  id uuid primary key default gen_random_uuid(),
  email text unique not null,
  full_name text,
  avatar_url text,
  created_at timestamptz default now(),
  updated_at timestamptz default now()
);

-- 2. Organizations / Teams (multi-tenancy)
create table organizations (
  id uuid primary key default gen_random_uuid(),
  name text not null,
  slug text unique not null,
  plan text default 'free',
  stripe_customer_id text,
  created_at timestamptz default now(),
  updated_at timestamptz default now()
);

-- 3. Memberships (who belongs to which org)
create table memberships (
  id uuid primary key default gen_random_uuid(),
  user_id uuid references users(id) on delete cascade,
  org_id uuid references organizations(id) on delete cascade,
  role text default 'member' check (role in ('owner', 'admin', 'member')),
  created_at timestamptz default now(),
  unique(user_id, org_id)
);

Adding Your Core Business Object

Every SaaS has a "main thing" — projects, campaigns, invoices, etc. Connect it to the org:

create table [your_core_object] (
  id uuid primary key default gen_random_uuid(),
  org_id uuid references organizations(id) on delete cascade not null,
  created_by uuid references users(id),
  -- your fields here
  name text not null,
  status text default 'active',
  created_at timestamptz default now(),
  updated_at timestamptz default now()
);

-- Always index the org_id for multi-tenant queries
create index idx_[object]_org_id on [your_core_object](org_id);

Tell AI:

Design a database schema for [describe your SaaS product].
The main objects are: [list your core objects].
Users belong to organizations. Each org has its own data.
Use Supabase (PostgreSQL). Include:
- Table definitions with proper types and constraints
- Foreign key relationships
- Indexes for common queries
- Row Level Security policies

Row Level Security (RLS)

RLS ensures users can only see their own organization's data. This is critical for SaaS.

Basic Pattern

-- Enable RLS on every table with customer data
alter table [your_table] enable row level security;

-- Users can only see rows belonging to their org
create policy "Users see own org data"
  on [your_table]
  for select
  using (
    org_id in (
      select org_id from memberships
      where user_id = auth.uid()
    )
  );

-- Users can only insert into their own org
create policy "Users insert own org data"
  on [your_table]
  for insert
  with check (
    org_id in (
      select org_id from memberships
      where user_id = auth.uid()
    )
  );

RLS Checklist

For every table that contains customer data:
- [ ] RLS is enabled
- [ ] SELECT policy restricts to user's org
- [ ] INSERT policy restricts to user's org
- [ ] UPDATE policy restricts to user's org
- [ ] DELETE policy restricts to user's org (or is blocked)
- [ ] Tested: User A cannot see User B's data

Migrations

What Migrations Are

Database migrations are version-controlled changes to your schema. Like git for your database structure.

Best Practices

  • Never edit production tables directly. Always use a migration.
  • Each migration does one thing. "Add status column to projects" not "Restructure everything."
  • Migrations are forward-only. Don't delete old migrations. Add new ones.
  • Test on a branch database first. Supabase has database branching for this.

Tell AI:

Write a Supabase migration to [describe the change].
Current table structure: [describe or paste current schema].
Include: the SQL migration and any RLS policy updates needed.

Common Patterns

Soft Deletes

Don't hard-delete records. Mark them as deleted:

alter table [table] add column deleted_at timestamptz;

-- Update RLS to exclude soft-deleted rows
create policy "Hide deleted rows"
  on [table] for select
  using (deleted_at is null and org_id in (...));

Audit Trail

Track who changed what:

create table audit_log (
  id uuid primary key default gen_random_uuid(),
  org_id uuid references organizations(id),
  user_id uuid references users(id),
  action text not null, -- 'create', 'update', 'delete'
  table_name text not null,
  record_id uuid not null,
  changes jsonb,
  created_at timestamptz default now()
);

Status Workflows

-- Use a check constraint for valid statuses
status text default 'draft' check (
  status in ('draft', 'active', 'paused', 'completed', 'archived')
)

Performance Basics

Index Rules

  • Always index foreign keys (org_id, user_id, etc.)
  • Index columns you filter or sort by frequently
  • Don't index everything — each index slows down writes

Query Tips

  • Select only the columns you need, not SELECT *
  • Use pagination for lists (LIMIT/OFFSET or cursor-based)
  • Use database views for complex repeated queries
  • Add explain analyze before queries to check performance

Common Mistakes

MistakeFix
No multi-tenancy from the startAdd org_id to every table from day 1
Skipping RLSEnable it on every table with customer data
Editing production schema directlyAlways use migrations
Storing files in the databaseUse Supabase Storage or S3 for files
No indexes on foreign keysIndex every org_id and user_id column
One giant table for everythingNormalize into separate tables with relationships
No created_at/updated_atAdd timestamps to every table
Hard deleting recordsUse soft deletes (deleted_at column)

Success Looks Like

  • Clean schema with clear relationships between tables
  • RLS policies on every customer-facing table, tested
  • Migrations tracked and versioned
  • Queries are fast for your current scale
  • You can explain your data model to a contractor or AI tool clearly

Related Skills

  • compliance — Encryption and audit trail requirements for regulated industries
  • deploy — Get your app and database live in production
  • secure — Security beyond RLS: auth, API protection, data encryption
  • build — Hand your schema to AI tools and build features on top of it
  • payments — Add Stripe tables and subscription tracking to your schema

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.5%
按下载量换算29

Claude

29.64%
按下载量换算26

Cursor

18.69%
按下载量换算16

Gemini CLI

9.27%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills