Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add Morningstar202604/awesome-skillkit --skill supabase-postgres-best-practicesgit clone --depth 1 https://github.com/Morningstar202604/awesome-skillkitWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/morningstar202604/awesome-skillkit/supabase-postgres-best-practices)<a href="https://agentmods.dev/skills/morningstar202604/awesome-skillkit/supabase-postgres-best-practices"><img src="https://agentmods.dev/badge/skills/morningstar202604/awesome-skillkit/supabase-postgres-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/morningstar202604/awesome-skillkit/supabase-postgres-best-practices"><img src="https://agentmods.dev/badge/skills/morningstar202604/awesome-skillkit/supabase-postgres-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00071 | $0.01238 |
| Opus 5.5 | $0.00028 | $0.00495 |
| Sonnet 5.5 | $0.00014 | $0.00248 |
| Haiku 4.5 | $0.00007 | $0.00124 |
Grade A, and why
supabase-postgres-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 76 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Supabase / Postgres 最佳实践
本 skill 面向 fullstack-database-engineer,聚焦 Supabase 托管 Postgres 的日常建模、性能与安全。
何时使用
- 新建表/迁移、加索引、写 RLS 策略;
- 慢查询、连接打满、RLS 拖慢查询;
- 评估分区、约束、vacuum、pg_stat_statements 调优。
核心原则
- 迁移即代码:所有 DDL 走 migration 工具(Supabase CLI / Flyway),禁止在控制台手改结构。
- 先看计划再建索引:用
EXPLAIN (ANALYZE, BUFFERS)确认全表扫描,再决定索引。 - RLS 默认开:public 表必须开 Row Level Security,不依赖"前端不发请求"。
- 连接池:Supabase 用 pgbouncer 事务池,应用连 pooler 端口,不直连 5432。
- 约束兜底:外键、check、unique、not null 在数据库层,不只靠应用。
索引实践
- 覆盖高频 WHERE/JOIN/ORDER BY:单列 btree 起步,多列按等值在前、排序在后排列。
- 部分索引:
CREATE INDEX ON orders(user_id) WHERE status = 'pending';减小索引体积。 - 表达式索引:对
lower(email)、(json->>'field')建表达式索引,不要对整列建。 - 不要过度索引:每个索引都拖慢写入,先量测再加。
- 查看未用索引:
SELECT * FROM pg_stat_user_indexes WHERE idx_scan = 0;
RLS 模板
alter table public.profiles enable row level security;
create policy "用户只能看自己的资料"
on public.profiles for select
using (auth.uid() = id);
create policy "用户只能更新自己的资料"
on public.profiles for update
using (auth.uid() = id)
with check (auth.uid() = id);
- Service key 绕过 RLS,绝不能下发到浏览器/客户端。
- RLS 策略里避免逐行子查询,必要时把关联表也索引好。
慢查询排查流程
- 开
pg_stat_statements(Supabase 已默认启用)。 - 按
mean_exec_time * calls找总成本最高的查询。 - 对目标 SQL 跑
EXPLAIN (ANALYZE, BUFFERS),看 Seq Scan / 行数估算偏差。 - 加索引或改写 SQL(避免
select *、避免在索引列上包函数)。 - 复核是否命中索引,观察
pg_stat_statements改善。
连接与迁移
- 应用用 Supabase 连接池(port 6543,transaction mode),长连接/事务批量才用直接连接。
- 迁移大表加列/加默认值用在线方式(
ADD COLUMN ... DEFAULT ...在 PG11+ 是元数据操作;重写表要锁表,避开高峰)。 - 大表分区:按时间 range(按月/周),老分区 detach 归档。
清单(交付前逐项过)
- 新表默认
enable row level security,并写好 select/insert/update 策略。 - 外键、
not null、unique、check约束齐全。 - 高频查询有
EXPLAIN ANALYZE证据,索引不是拍脑袋加的。 - Service key 只在服务端使用,前端只用 anon key + RLS。
- 所有 DDL 进 migration 文件,可回滚、可审查。
- 连接走 pooler,未在应用里维持大量长连接。
- 大表/归档策略已评估分区或 detach。
- 敏感列(密码 hash、PII)有注释与脱敏约定。
易错点
- 在浏览器用 service_role key:等于把数据库管理员钥匙交给用户,RLS 直接失效。
- 索引列上包函数:
WHERE lower(email) = ...普通索引失效,要建表达式索引。 - RLS 策略里 N+1 子查询:每行都查一次,列表接口直接慢百倍;把条件改成 join 或把权限冗余进本表。
- 过度索引:写入密集表堆了七八个索引,insert/update 变慢;定期清未用索引。
- 迁移在生产手工执行:环境漂移,必须 CLI migration 可重复。
- 忘记 vacuum 统计信息:分析信息过旧导致计划走错,autovacuum 正常运行即可,别手动关。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2mo ago First seen · 76 lines · 71 tokens per session scan A c9dc0420408d
supabase-postgres-best-practices is a skill published in the GitHub repository Morningstar202604/awesome-skillkit (0 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 71 tokens to every session and 1,238 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-27.
supabase-postgres-best-practices compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| supabase-postgres-best-practicesMorningstar202604/awesome-skillkit | Skill | 0 | 2mo ago | Apache-2.0 | A | 71 | Claude Code, Codex |
| postgres-patternsaffaan-m/ECC | Skill | 313k | 7d ago | MIT | A | 45 | Claude Code, Kiro |
| postgres-migrationlangwatch/langwatch | Skill | 5.1k | today | Apache-2.0 | A | 294 | Claude Code |
| haven-dblangwatch/langwatch | Skill | 5.1k | today | Apache-2.0 | A | 116 | Claude Code |
| alembic-migrationvstorm-co/full-stack-ai-agent-template | Skill | 2.0k | 3d ago | MIT | A | 56 | Claude Code |
| postgresql-table-designBidingCC/BuildingAI | Skill | 1.9k | 13d ago | Apache-2.0 | A | 31 | Claude Code, Codex |
| database-patternsyonatangross/orchestkit | Skill | 312 | today | MIT | A | 32 | Claude Code |