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 agentmods add skills/xiaobei930/cc-best/databasenpx skills add xiaobei930/cc-best --skill databasegit clone --depth 1 https://github.com/xiaobei930/cc-bestWrote 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/xiaobei930/cc-best/database)<a href="https://agentmods.dev/skills/xiaobei930/cc-best/database"><img src="https://agentmods.dev/badge/skills/xiaobei930/cc-best/database.svg" alt="Measured on agentmods" 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 | $0.00025 | $0.01660 |
| Opus 5 | $0.00013 | $0.00830 |
| Sonnet 5 | $0.00005 | $0.00332 |
| Haiku 4.5 | $0.00003 | $0.00166 |
Grade A, and why
database 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 yesterday.
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 — 215 lines — stays where its author put it; the contents beside it link to each section on GitHub.
数据库模式技能
关联 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 次查询
What ships with it
4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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.
- yesterday First seen · 215 lines · 25 tokens per session scan A a871a6e7be53
database is a skill published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 25 tokens to every session and 1,660 once invoked, about $0.0001 per session on Opus 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-03.
Other skills, from other repositories
optimize
Analyze and suggest performance improvements for code, queries, or systems.
db
Database operations via CLI. Replaces Postgres/SurrealDB MCP (saves 3,000-8,000 tokens). Supports PostgreSQL, SurrealDB, SQLite.
moai-platform-database-cloud
Cloud database platform specialist covering Neon (serverless PostgreSQL), Supabase (PostgreSQL 16 with real-time), and Firebase Firestore (NoSQL with offline sync). Use when choosing or setting up cloud databases.
design-patterns
Detect, suggest, and evaluate GoF design patterns in TypeScript/JavaScript codebases. Use when refactoring code, applying singleton/factory/observer/strategy patterns, reviewing pattern quality, or finding stack-native alternatives for React, Angular, NestJS, and Vue.
eval-hooks
Audit Claude Code hooks defined in settings.json files for validity, performance safety, and correctness. Resolves each command against the filesystem, checks exit-code strategy for blocking hooks, flags missing timeouts, and reviews interactive vs async patterns. Use when setting up hooks for the first time…
source-command-audit-whitepapers
Audit version freshness, FR/EN parity, and metadata quality of all whitepapers and recap cards.