MCP HubMCP Hub
スキル一覧に戻る

database-patterns

spences10
更新日 Today
159 閲覧
5
5
GitHubで表示
その他data

について

このスキルは、安全なCRUD操作を実現するために、better-sqlite3を使用したプリペアドステートメントによるSQLiteデータベースパターンを提供します。主な機能として、nanoidによる主キー、Unixタイムスタンプの管理、行レベルセキュリティによるユーザースコープのクエリを実装しています。セキュリティのベストプラクティスに沿った構造化されたデータベース連携が必要なアプリケーションを構築する際にご利用ください。

クイックインストール

Claude Code

推奨
プラグインコマンド推奨
/plugin add https://github.com/spences10/devhub-crm
Git クローン代替
git clone https://github.com/spences10/devhub-crm.git ~/.claude/skills/database-patterns

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

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_id in 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

GitHub リポジトリ

spences10/devhub-crm
パス: .claude/skills/database-patterns

関連スキル

content-collections

メタ

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

スキルを見る

polymarket

メタ

This skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.

スキルを見る

hybrid-cloud-networking

メタ

This skill configures secure hybrid cloud networking between on-premises infrastructure and cloud platforms like AWS, Azure, and GCP. Use it when connecting data centers to the cloud, building hybrid architectures, or implementing secure cross-premises connectivity. It supports key capabilities such as VPNs and dedicated connections like AWS Direct Connect for high-performance, reliable setups.

スキルを見る

llamaindex

メタ

LlamaIndex is a data framework for building RAG-powered LLM applications, specializing in document ingestion, indexing, and querying. It provides key features like vector indices, query engines, and agents, and supports over 300 data connectors. Use it for document Q&A, chatbots, and knowledge retrieval when building data-centric applications.

スキルを見る