tdsk-database

Provides schema, service, and migration knowledge for a Drizzle ORM PostgreSQL database layer.

Updated Jan 4, 2026
One-click install
npx skills add https://github.com/threadedstack/threadedstack --skill tdsk-database-threadedstack
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tdsk-database
Source: https://github.com/threadedstack/threadedstack/tree/main/.claude/skills/tdsk-database
Command: npx skills add https://github.com/threadedstack/threadedstack --skill tdsk-database-threadedstack

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working with a large database layer of 30+ tables, 22 services, junction tables, and exclusive-arc constraints is error-prone without deep context. This Skill gives an AI assistant the full knowledge base of the Threaded Stack database repo so it can write correct queries, services, and migrations on the first attempt. ## Core Features & Use Cases - Schema Reference: Documents all 25 Drizzle-managed tables, 2 external tables (Neon Auth users, Caddy certificates), and 9 junction tables with key fields, indexes, and constraints. - Service Layer Guide: Explains the Base service class CRUD pattern, domain model conversion, and specialized methods like quota atomic increments, thread branching, and pgvector memory search. - Migration & Ops Commands: Covers drizzle-kit workflows (generate, migrate, push, studio), seeding, purging, and the fleet toggle script for standing the autonomous agent fleet up or down. - Use Case: Ask the assistant to add a new org-scoped table with a service, and it will follow the repo's base schema fields, exclusive-arc CHECK constraint conventions, and service inheritance patterns. ## Quick Start Ask the assistant to create a new Drizzle table and matching service for the database repo following the existing patterns.

Frequently Asked Questions about tdsk-database

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new table and service to a Drizzle ORM database layer?▼

Define the table in src/schemas using the shared base fields (uuid id, createdAt, updatedAt), export it from the schema barrel, then create a service extending Base<TTable, S, I, M> with a model() override. Register the service so the database() singleton initializes it.

How do I run Drizzle migrations with drizzle-kit?▼

Run pnpm generate to create migration files from schema changes, then pnpm migrate to apply them. Use pnpm push for direct schema pushes, but note it is interactive and cannot modify existing CHECK constraints, which require manual drop-and-recreate SQL.

What is the exclusive arc pattern in PostgreSQL schema design?▼

An exclusive arc uses CHECK constraints to ensure a row belongs to exactly one parent entity, such as assets requiring exactly one of orgId, projectId, userId, threadId, or messageId. This repo implements 2-way, 4-way, and 5-way arcs across roles, domains, secrets, and assets.

Does Drizzle ORM support pgvector for semantic search?▼

Yes, the memories table uses a vector(1536) embedding column with pgvector enabled. The memory service performs scored retrieval combining cosine similarity, recency decay, and importance, falling back to ts_rank lexical ranking when embeddings are absent.

Why can't drizzle-kit push modify existing CHECK constraints?▼

drizzle-kit push cannot alter existing CHECK constraints in place. You must drop and recreate the constraint with manual SQL, which matters when updating exclusive-arc rules on tables like secrets or assets.