database-patterns
关于
This skill provides SQLite database patterns using better-sqlite3 with prepared statements for secure CRUD operations. It implements key features including nanoid primary keys, Unix timestamp management, and user-scoped queries with row-level security. Use this when building applications that require structured database interactions with security best practices.
技能文档
Database Patterns
Quick Start
import { db } from '$lib/server/db';
import { nanoid } from 'nanoid';
// SELECT with user_id (row-level security)
const contact = db
.prepare('SELECT * FROM contacts WHERE id = ? AND user_id = ?')
.get(id, user_id) as Contact | undefined;
// INSERT with nanoid and timestamps
const stmt = db.prepare(
'INSERT INTO contacts (id, user_id, name, created_at, updated_at) VALUES (?, ?, ?, ?, ?)',
);
stmt.run(nanoid(), user_id, name, Date.now(), Date.now());
Core Principles
- Prepared statements: Use for all queries (SQL injection prevention)
- ID generation: Use
nanoid()for all primary keys (no auto-increment) - Timestamps: Store as Unix epoch with
Date.now()(milliseconds) - Row-level security: Always include
user_idin WHERE clause (never query by ID alone) - Transactions: Use for multi-table operations (all-or-nothing)
- Synchronous: better-sqlite3 is sync - no async/await needed
Reference Files
- schema.md - Complete schema with columns and types
- relationships.md - Table relationships and foreign keys
- query-examples.md - Joins, transactions, and advanced patterns
快速安装
/plugin add https://github.com/spences10/devhub-crm/tree/main/database-patterns在 Claude Code 中复制并粘贴此命令以安装该技能
GitHub 仓库
相关推荐技能
llamaindex
元LlamaIndex是一个专门构建RAG应用的开发框架,提供300多种数据连接器用于文档摄取、索引和查询。它具备向量索引、查询引擎和智能代理等核心功能,支持构建文档问答、知识检索和聊天机器人等数据密集型应用。开发者可用它快速搭建连接私有数据与LLM的RAG管道。
adk-deployment-specialist
文档这个Skill用于在Vertex AI Agent Engine上管理ADK智能体间的A2A协议通信。它支持智能体发现、任务提交、状态轮询和会话管理,实现多智能体系统的编排。新增的监控功能包括可观测性面板、Cloud Trace集成和BigQuery分析导出。
nestjs
元这个Claude Skill为NestJS开发提供框架标准和架构模式指导,特别擅长领域驱动设计和模块化架构。它能帮助开发者正确使用依赖注入、装饰器模式,以及构建中间件、守卫、拦截器等核心组件。适用于创建控制器、服务、REST/GraphQL API、微服务架构,以及与TypeORM/Prisma的数据库集成。
generating-test-reports
元这个Skill能自动生成包含覆盖率指标和趋势分析的全面测试报告,支持HTML、PDF等格式。它能聚合多种测试框架的结果,计算关键指标并进行历史对比分析。当开发者需要测试报告、覆盖率分析或失败原因排查时,直接使用相关触发词即可调用。
