spences10/devhub-crm · Archived

database-patterns

SQLite operations using better-sqlite3 with prepared statements. Use when implementing CRUD operations, timestamps, and user-scoped queries with row-level security.

First seen Mar 15, 2026

Installation

$ npx skills add spences10/devhub-crm --skill database-patterns

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from spences10/devhub-crm.

npx skills add spences10/devhub-crm

Browse all from spences10/devhub-crm

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 6
Default branch main
Open issues 1
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,509 B
  • docs SUMMARY.md 207 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 2 installs

SKILL.md

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

  • [schema.md](references/schema.md) - Complete schema with columns and

types

  • [relationships.md](references/relationships.md) - Table

relationships and foreign keys

  • [query-examples.md](references/query-examples.md) - Joins,

transactions, and advanced patterns