database
Skill48 starsChanged 10 months agoMITView on GitHub
Database design, query optimization, migrations, and indexing. Use when designing schemas, writing queries, or managing migrations.
24 other projects use a version of this.
Adopted by
Most recently taken up by
- davidvornholt/mailboxtheir own version, first seen Oct 4, 2026
- msrv-tech/skillstheir own version, first seen Oct 2, 2026
- theopenco/llmgatewaytheir own version, first seen Oct 1, 2026
- AsiaOstrich/universal-dev-standardstheir own version, first seen Sep 30, 2026
- lecluse-net/galaristheir own version, first seen Sep 27, 2026
- yamanidev/claude-code-configurationtheir own version, first seen Sep 13, 2026
Used with
Projects with it also use payment, monitoring and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
lightpointventuresSkillpayment
当用户想加支付、收款、集成 Stripe、做订阅付费时使用 — 集成支付系统,支持一次性和订阅
Also in 3 projects that use this
rogue-dev-studioSkillmonitoring
Claude monitoring and usage tracking tools (UV, claude-monitor, claude-usage-cli). Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `monitoring` work when listed in TEAM.yaml or explicitly requested.
Also in 3 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 3 projects that use this
ffsshhttiikkSkilli18n
Internationalization and localization
Also in 3 projects that use this
OpenAISkillemail
Email sending integration guidance — Resend (native Vercel Marketplace) with React Email templates. Covers API setup, transactional emails, domain verification, and template patterns. Use when sending emails from a Vercel-deployed application.
Also in 3 projects that use this
GitHubSkillrefactor
Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
Also in 5 projects that use this
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 24
- theopenco/llmgateway★ 1.7ksame name
- AsiaOstrich/universal-dev-standards★ 76same name
- msrv-tech/skills★ 57same name
- lightpointventures/claude-code-starter★ 36same name
- neuron-one/GODMODE★ 33same name
- yamanidev/claude-code-configuration★ 9same name
- YepAPI/skills★ 8same name
- SecuringTheRealm/str-agentic-adventures★ 4same name
- davidvornholt/mailbox★ 2same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
14 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository21 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- docs/llms.txtllms.txt
- llms.txtllms.txt
- apiSkill
- architectureSkill
- backendSkill
- compactSkill
- debugSkill
- devopsSkill
- explorationSkill
- frontendSkill
- gitSkill
- learningSkill
- modelSkill
- nativeSkill
- qualitySkill
- search-firstSkill
- second-opinionSkill
- securitySkill
- sessionSkill
- testingSkill
The file
Files
数据库模式技能
关联 Agent:
architect— 架构设计时加载数据库约束上下文
本技能提供数据库设计和操作的最佳实践,支持多数据库按需加载。
触发条件
- 设计数据库 Schema
- 编写数据库查询
- 优化查询性能
- 管理数据库迁移
- 配置索引
数据库专属模式
根据项目技术栈,加载对应的数据库专属文件:
| 数据库 | 加载文件 | 适用场景 |
| PostgreSQL | postgres.md | 企业应用、复杂查询 |
| MySQL | mysql.md | Web 应用、读多写少 |
| Oracle | oracle.md | 大型企业、高并发 OLTP |
| SQLite | sqlite.md | 嵌入式、移动端、本地化 |
检测方式: 根据连接字符串、ORM 配置或项目依赖确定数据库类型。
通用 Schema 设计
命名规范
-- 表名:小写下划线,复数形式
users, order_items, user_preferences
-- 列名:小写下划线
created_at, updated_at, user_id, is_active
-- 索引名:idx_表名_列名
idx_users_email, idx_orders_user_id_created_at
-- 外键名:fk_表名_关联表
fk_orders_users必备字段
CREATE TABLE users (
id BIGINT PRIMARY KEY, -- 主键
-- 业务字段...
created_at TIMESTAMP NOT NULL, -- 创建时间
updated_at TIMESTAMP NOT NULL, -- 更新时间
deleted_at TIMESTAMP -- 软删除
);关系设计
| 关系类型 | 设计方式 | 示例 |
| 一对多 | 子表添加外键 | orders.user_id → users |
| 多对多 | 中间表 + 联合主键 | user_roles(user_id, role_id) |
| 一对一 | 子表主键 = 外键 | user_settings.user_id |
通用索引策略
何时创建索引
- ✅ WHERE 条件频繁使用的列
- ✅ JOIN 关联的列
- ✅ ORDER BY / GROUP BY 的列
- ❌ 很少查询的列
- ❌ 值重复率高的列(如性别)
- ❌ 频繁更新的列
索引类型选择
| 查询模式 | 推荐索引 |
WHERE col = value | B-tree |
WHERE col > value | B-tree |
| 全文搜索 | 全文索引 |
| JSON 字段查询 | GIN/JSON 索引 |
| 时序数据范围查询 | BRIN(PG) |
复合索引原则
-- 规则:等值列在前,范围列在后
-- 查询:WHERE status = 'active' AND created_at > '2024-01-01'
-- ✅ 正确顺序
CREATE INDEX idx_orders_status_created ON orders(status, created_at);
-- ❌ 错误顺序(范围列在前会导致后续列无法使用索引)
CREATE INDEX idx_orders_created_status ON orders(created_at, status);N+1 问题
问题示例
获取 100 个用户及其订单:
1 次查询获取用户 + 100 次查询获取每个用户的订单 = 101 次查询解决方案
| 方案 | 方式 | 适用场景 |
| 预加载 | JOIN 或 IN 查询 | 数据量适中 |
| 批量加载 | 分批 IN 查询 | 大数据量 |
| 延迟加载 | 按需查询 | 不确定是否需要 |
分页优化
-- ❌ 大偏移量慢(OFFSET 10000 需要扫描 10000 行)
SELECT * FROM posts ORDER BY id LIMIT 20 OFFSET 10000;
-- ✅ 游标分页(直接定位)
SELECT * FROM posts WHERE id > 10000 ORDER BY id LIMIT 20;事务原则
ACID 特性
| 特性 | 含义 |
| A 原子性 | 全部成功或全部失败 |
| C 一致性 | 数据始终有效 |
| I 隔离性 | 事务互不干扰 |
| D 持久性 | 提交后永久保存 |
隔离级别
| 级别 | 脏读 | 不可重复读 | 幻读 | 性能 |
| READ UNCOMMITTED | ✓ | ✓ | ✓ | 最高 |
| READ COMMITTED | ✗ | ✓ | ✓ | 高 |
| REPEATABLE READ | ✗ | ✗ | ✓ | 中 |
| SERIALIZABLE | ✗ | ✗ | ✗ | 低 |
迁移管理
迁移原则
- 版本控制 - 所有迁移文件纳入 Git
- 只增不改 - 不修改已执行的迁移
- 可回滚 - 每个 UP 对应 DOWN
- 原子性 - 一个迁移只做一件事
常用 ORM 命令
# Prisma
npx prisma migrate dev --name add_column
# SQLAlchemy/Alembic
alembic revision --autogenerate -m "add column"
alembic upgrade head
# TypeORM
npm run typeorm migration:generate -- -n AddColumn
npm run typeorm migration:run最佳实践清单
- 表名/列名统一命名规范
- 必备字段:id, created_at, updated_at
- 软删除而非物理删除
- 基于查询模式创建索引
- 避免 N+1 查询
- 大数据量使用游标分页
- 迁移文件纳入版本控制
- 合理配置连接池
- 使用 EXPLAIN 分析慢查询
数据库专属内容
详细的数据库专属实现请参考:
- PostgreSQL: postgres.md - 数据类型、索引策略、RLS、性能诊断
- MySQL: mysql.md - InnoDB 优化、索引策略、字符集
- Oracle: oracle.md - 分区表、全局索引、PL/SQL
- SQLite: sqlite.md - WAL 模式、PRAGMA 优化、嵌入式场景
记住: 数据库设计是系统的地基——索引、约束、迁移策略在上线前就要规划好。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

