
db
Database operations for SQLite, PostgreSQL, and MySQL. Use for queries, schema inspection, migrations, and AI-assisted query generation.
- Installs
- 97
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/johnlindquist/claude --skill db- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads db automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Database Manager
Query and manage databases across SQLite, PostgreSQL, and MySQL.
Prerequisites
Install database CLIs as needed:
# SQLite (usually pre-installed on macOS/Linux)
sqlite3 --version
# PostgreSQL
brew install postgresql
# or
apt install postgresql-client
# MySQL
brew install mysql-client
# or
apt install mysql-client
CLI Reference
SQLite
# Connect to database
sqlite3 database.db
# Execute query
sqlite3 database.db "SELECT * FROM users LIMIT 10"
# Output as CSV
sqlite3 -csv database.db "SELECT * FROM users"
# Output as JSON (requires sqlite 3.33+)
sqlite3 -json database.db "SELECT * FROM users"
# Column headers
sqlite3 -header database.db "SELECT * FROM users"
# Execute SQL file
sqlite3 database.db < queries.sql
# Schema commands
sqlite3 database.db ".schema"
sqlite3 database.db ".tables"
sqlite3 database.db ".schema users"
PostgreSQL
# Connect
psql postgresql://user:pass@host:5432/dbname
# Execute query
psql -c "SELECT * FROM users LIMIT 10" postgresql://...
# Tuples only (no headers)
psql -t -c "SELECT count(*) FROM users" postgresql://...
# No alignment (machine-readable)
psql -t -A -c "SELECT id,name FROM users" postgresql://...
# Execute SQL file
psql -f queries.sql postgresql://...
# List tables
psql -c "\dt" postgresql://...
# Describe table
psql -c "\d users" postgresql://...
# Output format
psql -c "SELECT * FROM users" --csv postgresql://...
psql -c "SELECT * FROM users" --html postgresql://...
MySQL
# Connect
mysql -h host -u user -p dbname
# Execute query
mysql -h host -u user -p -e "SELECT * FROM users LIMIT 10" dbname
# Batch mode (no headers)
mysql -h host -u user -p -B -e "SELECT * FROM users" dbname
# Execute SQL file
mysql -h host -u user -p dbname < queries.sql
# Show tables
mysql -h host -u user -p -e "SHOW TABLES" dbname
# Describe table
mysql -h host -u user -p -e "DESCRIBE users" dbname
Common Operations
Schema Inspection
SQLite
# All tables
sqlite3 db.sqlite ".tables"
# Table schema
sqlite3 db.sqlite ".schema tablename"
# All schemas
sqlite3 db.sqlite ".schema"
PostgreSQL
# All tables
psql -c "\dt" $DATABASE_URL
# Table schema
psql -c "\d tablename" $DATABASE_URL
# Table with indexes
psql -c "\d+ tablename" $DATABASE_URL
MySQL
# All tables
mysql -e "SHOW TABLES" -h host -u user -p dbname
# Table schema
mysql -e "DESCRIBE tablename" -h host -u user -p dbname
# Create statement
mysql -e "SHOW CREATE TABLE tablename" -h host -u user -p dbname
Query Explanation
# SQLite
sqlite3 db.sqlite "EXPLAIN QUERY PLAN SELECT * FROM users WHERE email = 'x'"
# PostgreSQL
psql -c "EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'x'" $DATABASE_URL
# MySQL
mysql -e "EXPLAIN SELECT * FROM users WHERE email = 'x'" dbname
Data Export
# SQLite to CSV
sqlite3 -csv -header db.sqlite "SELECT * FROM users" > users.csv
# PostgreSQL to CSV
psql -c "\COPY users TO 'users.csv' CSV HEADER" $DATABASE_URL
# MySQL to CSV
mysql -e "SELECT * FROM users" -B dbname | tr '\t' ',' > users.csv
AI-Assisted Query Generation
Use Gemini to help write queries:
# Describe what you want
gemini -m pro -o text -e "" "Write a SQL query to:
- Find all users who signed up in the last 30 days
- Who have made at least one purchase
- Order by purchase count descending
Table schemas:
- users (id, email, created_at)
- purchases (id, user_id, amount, created_at)
Output PostgreSQL-compatible SQL."
Safe Query Review
# Generate query
QUERY=$(gemini -m pro -o text -e "" "Write SQL for: [your request]")
# Review before executing
echo "Generated query:"
echo "$QUERY"
# Then execute if safe
# psql -c "$QUERY" $DATABASE_URL
Migration Patterns
Schema Changes
# Create migration file
cat > migrations/001_add_column.sql << 'EOF'
ALTER TABLE users ADD COLUMN status VARCHAR(50) DEFAULT 'active';
EOF
# Apply migration
psql -f migrations/001_add_column.sql $DATABASE_URL
Safe Migration Workflow
# 1. Test on copy first
createdb test_migration
pg_dump $DATABASE_URL | psql test_migration
# 2. Run migration on test
psql -f migration.sql test_migration
# 3. Verify
psql -c "\d tablename" test_migration
# 4. Apply to production
psql -f migration.sql $DATABASE_URL
# 5. Cleanup
dropdb test_migration
Environment Variables
Store connection strings securely:
# .env file (don't commit!)
DATABASE_URL=postgresql://user:pass@host:5432/dbname
SQLITE_DB=./data/app.db
# Usage
psql $DATABASE_URL
sqlite3 $SQLITE_DB
Best Practices
- Never hardcode credentials - Use environment variables
- Review AI-generated queries - Before executing
- Use EXPLAIN - Check query performance
- Test migrations - On copy before production
- Backup before changes - Especially destructive ones
- Use transactions - For multi-statement changes
- Limit results - Always use LIMIT during exploration
FAQ
What does the db skill do?
Database operations for SQLite, PostgreSQL, and MySQL. Use for queries, schema inspection, migrations, and AI-assisted query generation.
How do I install db?
Run npx skills add https://github.com/johnlindquist/claude --skill db in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/db/ (personal) or .claude/skills/db/ (project).
Which AI agents can use db?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is db safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains db?
It is published by johnlindquist in johnlindquist/claude. It has 97 recorded installs.
More from johnlindquist/claude
gemini-image
johnlindquist/claude
Analyze images using Gemini's vision capabilities. Use for image analysis, text extraction from screenshots, and visual content understanding.
brainstorm
johnlindquist/claude
Open the skill to read its SKILL.md instructions.
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.