feat(claude): add database slash commands for common operations

Add 5 new slash commands for database management:

- /db-check - Check database connection and show table row counts
- /db-migrate - Create and apply Prisma migrations (production)
- /db-push - Push schema changes without migrations (development)
- /db-studio - Open Prisma Studio visual database browser
- /db-seed - Run seed script to initialize database

These commands make it easy to test database connectivity, run migrations,
view data in Prisma Studio, and seed the database with initial data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ajax Davis 2025-11-28 02:24:28 +10:00
parent 9c91df95ec
commit fa962d3527
5 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,13 @@
---
description: Check if database connection is working and show table counts
---
Check if the database connection is working by:
1. Running `pnpm --filter=@tpmjs/db db:studio` in the background to verify Prisma can connect
2. If successful, kill the studio process immediately
3. Report connection status to the user
Then show me the current row counts for all tables (Tool, SyncCheckpoint, SyncLog) by writing a quick script that imports the Prisma client and queries each table.
This helps verify the database is properly configured and shows if any data exists.

View file

@ -0,0 +1,12 @@
---
description: Create and apply a Prisma migration
---
Create and apply a new Prisma migration:
1. Run `pnpm --filter=@tpmjs/db db:migrate` to create and apply a migration
2. The migration will be named automatically based on changes
3. After migration completes, regenerate the Prisma client with `pnpm --filter=@tpmjs/db db:generate`
4. Report the results to the user
This is used for production-ready database schema changes that create migration files.

View file

@ -0,0 +1,11 @@
---
description: Push Prisma schema changes to database (dev only)
---
Push the current Prisma schema to the database without creating migrations:
1. Run `pnpm --filter=@tpmjs/db db:push` to sync schema changes to the database
2. After push completes, regenerate the Prisma client with `pnpm --filter=@tpmjs/db db:generate`
3. Report the results to the user
This is useful for development when you want to quickly iterate on schema changes without creating migration files. Do NOT use this in production - use db:migrate instead.

View file

@ -0,0 +1,11 @@
---
description: Seed the database with initial data
---
Run the database seed script to initialize the database with default data:
1. Run `pnpm --filter=@tpmjs/db db:seed` to execute the seed script
2. The seed script will create initial SyncCheckpoint records for the changes feed and keyword sync
3. Report the results to the user
This should be run once after creating the database to set up the initial sync checkpoints. It's safe to run multiple times - it will only create records if they don't already exist.

View file

@ -0,0 +1,13 @@
---
description: Open Prisma Studio to view and edit database data
---
Open Prisma Studio, a visual database browser:
1. Run `pnpm --filter=@tpmjs/db db:studio` in the background
2. Wait for the "Prisma Studio is up on http://localhost:5555" message
3. Tell the user that Prisma Studio is now running at http://localhost:5555
4. Remind the user they can view and edit all database tables (Tool, SyncCheckpoint, SyncLog) in the browser
5. Tell them to use Ctrl+C in the terminal or kill the background process when done
This provides a visual interface to browse, search, and edit database records.