AGENT SKILL

database

PostgreSQL, Supabase, Firebase, schema design, migrations, RLS.

License 许可
MIT
最近更新
2026-11-11
Stars
★ 0
Forks
0

01 前言 Front Matter

name
database
author
Joshua (joshlcoleman), Hermes Agent
license
MIT
version
1.0.0
metadata
{ "hermes": { "tags": [ "database", "postgres", "supabase", "firebase", "schema", "rls" ], "related_skills": [ "nextjs", "testing" ] } }
platforms
[ "linux", "macos", "windows" ]
description
PostgreSQL, Supabase, Firebase, schema design, migrations, RLS.

02 资源文件 1

03 SKILL.md 正文

Database

When to Use

  • Schema design and migrations
  • Writing queries or RLS policies
  • Setting up Supabase/Firebase
  • Performance optimization

Quick Reference

Task Tool
Migrations Prisma / Drizzle / Supabase CLI
ORM Prisma (type-safe) / Drizzle (SQL-like)
Real-time Supabase Realtime / Firebase RTDB
Storage Supabase Storage / Firebase Storage
Auth Supabase Auth / Firebase Auth

Schema Design

Prisma Example

model User {
  id        String   @id @default(cuid())
  email     String   @unique
  name      String?
  posts     Post[]
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Post {
  id       String @id @default(cuid())
  title    String
  body     String
  author   User   @relation(fields: [authorId], references: [id])
  authorId String
  published Boolean @default(false)
  tags     Tag[]  @relation("PostTags")
}

model Tag {
  id    String @id @default(cuid())
  name  String @unique
  posts Post[] @relation("PostTags")
}

Indexing Strategy

-- Always index foreign keys
CREATE INDEX idx_post_author ON "Post"("authorId");

-- Index for common filters
CREATE INDEX idx_post_published ON "Post"("published") WHERE published = true;

-- GIN index for JSONB / full-text
CREATE INDEX idx_post_search ON "Post" USING GIN(to_tsvector('english', title || ' ' || body));

Row Level Security (Supabase)

-- Enable RLS
ALTER TABLE posts ENABLE ROW LEVEL SECURITY;

-- Users can read their own posts
CREATE POLICY "Users can read own posts"
  ON posts FOR SELECT
  USING (auth.uid() = author_id);

-- Users can update own posts
CREATE POLICY "Users can update own posts"
  ON posts FOR UPDATE
  USING (auth.uid() = author_id)
  WITH CHECK (auth.uid() = author_id);

-- Public can read published posts
CREATE POLICY "Public can read published"
  ON posts FOR SELECT
  USING (published = true);

Pitfalls

  • N+1 queries → Use include/select in Prisma or JOINs
  • Missing indexes → Index foreign keys, filter columns, sort columns
  • No soft delete → Add deletedAt timestamp
  • Over-normalizing → Sometimes JSONB is better than 6th normal form
  • Forgetting RLS → Always enable, test with anon key

Verification

  • [ ] Schema migrated successfully
  • [ ] Indexes created for common queries
  • [ ] RLS policies tested (owner, admin, public)
  • [ ] No N+1 in API routes
  • [ ] Backups configured (automated)

04 同仓库更多 Skills

Trollz1004
Trollz1004/ANTIGRAVITY

security-audit

Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

impeccable

Use when the user wants to design, redesign, shape, critique, audit, polish, simplify, harden, animate, or otherwise improve a frontend interface: websites, landing pages, dashboards, product UI, components, forms, settings, onboarding, empty states, and native iOS or Android screens. Handles UX review, hierarchy, layout, typography, color, motion, UX copy, accessibility, responsive behavior, edge cases, and capturing or documenting design systems (DESIGN.md, tokens). Also for making bland UI bolder, loud UI quieter, or ambitious visual effects. Not for backend-only or non-UI tasks.

设计师前端开发视觉设计
★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

hallmark

Design skill for websites and new pages that look designed, not generated. Use when the user asks to build or design something new, or names Hallmark. Never use it on an existing design unless the user names Hallmark, as in `/hallmark redesign <path>`.

视觉设计Skill与智能体开发
★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

测试与质量前端开发
★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

appinsights-instrumentation

Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. USE FOR: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices. DO NOT USE FOR: adding App Insights to my app (use azure-prepare), add telemetry to my project (use azure-prepare), add monitoring (use azure-prepare). This skill provides guidance—azure-prepare orchestrates component changes.

★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

youtube-automation

YouTube automation: upload, SEO, thumbnails, scheduling, analytics.

数据分析师市场营销分析与可视化营销推广
★ 0