/db:database-pipelinefrom db
Guides database operations: migrations with rollback plans, query optimization via EXPLAIN ANALYZE, and data warehouse schema design. Use when changing schemas or tuning queries.
Ships in db. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
CRITICAL: Database operations require specialized workflows for safety and performance.
Trigger: Any schema change or migration Sequence:
1. db:postgresql-expert/mongodb-expert → Analyze current schema
2. Query Context7 for migration best practices
3. Write migration with rollback plan
4. core:test-runner → Test migration on dev database
5. Create backup verification test
6. Document migration in changelog
7. Never run migrations without rollback plan
Context7 Best Practices:
Trigger: Slow query or performance issue Sequence:
1. db:postgresql-expert → Analyze query plan (EXPLAIN ANALYZE)
2. Query Context7 for optimization patterns
3. Identify missing indexes or inefficient operations
4. Write performance test (must show improvement)
5. Implement optimization
6. core:test-runner → Verify no functionality regression
7. Document optimization in CLAUDE.md
PostgreSQL Optimization (Context7: /websites/postgresql):
-- Use EXPLAIN ANALYZE to identify bottlenecks
EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 123;
-- Optimize with appropriate index
CREATE INDEX idx_orders_customer_id ON orders(customer_id);
-- Verify improvement
EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 123;
MongoDB Optimization (Context7: /mongodb/docs):
// Use explain() for aggregation pipelines
db.collection.aggregate([
{$match: {status: "active"}},
{$group: {_id: "$category", total: {$sum: 1}}}
]).explain("executionStats");
// Create compound index in query order
db.collection.createIndex({status: 1, category: 1});
Redis Optimization (Context7: /websites/redis_io):
Trigger: BigQuery/CosmosDB implementation Sequence:
1. db:bigquery-expert/cosmosdb-expert → Design schema
2. Query Context7 for partitioning/clustering best practices
3. Create partitioning/sharding strategy
4. Implement ETL/ELT pipeline
5. core:test-runner → Validate data integrity
6. Monitor costs and performance
BigQuery Best Practices (Context7: /websites/cloud_google-bigquery):
-- Partition by date, cluster by filter columns
CREATE TABLE analytics.events (
event_id INT64,
event_timestamp TIMESTAMP,
user_id STRING,
event_type STRING
)
PARTITION BY DATE(event_timestamp)
CLUSTER BY user_id, event_type
OPTIONS (
partition_expiration_days=365,
require_partition_filter=TRUE
);
-- Optimize queries with partition pruning
SELECT event_type, COUNT(*) as total
FROM analytics.events
WHERE DATE(event_timestamp) BETWEEN '2024-01-01' AND '2024-01-31'
AND user_id = 'user123'
GROUP BY event_type;
Cosmos DB Best Practices (Context7: /websites/learn_microsoft-en-us-azure-cosmos-db):
Trigger: Redis caching requirement Sequence:
1. db:redis-expert → Design cache strategy
2. Query Context7 for caching patterns
3. Implement cache invalidation logic
4. Write cache hit/miss tests
5. core:test-runner → Verify cache behavior
6. Monitor memory usage and hit rates
Redis Caching Patterns (Context7: /websites/redis_io):
# Client-side caching with placeholder pattern
SET cache:user:1234 "caching-in-progress"
# Compute expensive operation
SET cache:user:1234 "{\"name\":\"Alice\",\"role\":\"admin\"}"
EXPIRE cache:user:1234 3600
# Cache aside pattern
GET cache:product:456
# If miss, query database and set cache
SET cache:product:456 '{"name":"Widget","price":29.99}'
EXPIRE cache:product:456 1800
Cache Invalidation Strategies:
Trigger: Backup strategy implementation Sequence:
1. Database expert → Design backup strategy
2. Query Context7 for backup best practices
3. Implement automated backup script
4. Write restore verification test
5. core:test-runner → Test backup and restore
6. Document recovery procedures
7. Schedule regular backup drills
Backup Strategies by Database:
# Full backup with custom format (allows selective restore)
pg_dump -Fc -d mydatabase -f backup.dump
# Point-in-time recovery setup
# Enable WAL archiving in postgresql.conf
wal_level = replica
archive_mode = on
archive_command = 'cp %p /backup/wal/%f'
# Consistent backup with oplog
mongodump --oplog --gzip --out /backup/mongodb/
# Verify backup integrity
mongorestore --dry-run --gzip --dir /backup/mongodb/
# Manual snapshot
redis-cli BGSAVE
# Configure automatic snapshots
save 900 1 # After 900s if ≥1 key changed
save 300 10 # After 300s if ≥10 keys changed
save 60 10000 # After 60s if ≥10000 keys changed
-- Create snapshot for time travel
CREATE SNAPSHOT TABLE mydataset.events_snapshot
CLONE mydataset.events;
-- Query historical data (up to 7 days)
SELECT * FROM mydataset.events
FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY);
Trigger: New query patterns or performance degradation Sequence:
1. Database expert → Analyze query patterns
2. Query Context7 for indexing strategies
3. Identify missing or unused indexes
4. Create index with minimal lock strategy
5. core:test-runner → Verify performance improvement
6. Monitor index usage statistics
PostgreSQL Index Management (Context7: /websites/postgresql):
-- Create index concurrently (no table lock)
CREATE INDEX CONCURRENTLY idx_users_created_at ON users(created_at);
-- Identify unused indexes
SELECT
schemaname, tablename, indexname, idx_scan
FROM pg_stat_user_indexes
WHERE idx_scan = 0 AND schemaname = 'public'
ORDER BY pg_relation_size(indexrelid) DESC;
-- Drop unused index
DROP INDEX CONCURRENTLY idx_old_unused;
MongoDB Index Management (Context7: /mongodb/docs):
// Find index inconsistencies in sharded collections
db.collection.aggregate([
{$indexStats: {}},
{$group: {
_id: "$name",
shards: {$push: "$shard"},
specs: {$push: {$objectToArray: {$ifNull: ["$spec", {}]}}}
}},
{$project: {
missingFromShards: {$setDifference: ["$allShards", "$shards"]}
}}
]);
All database operations should query Context7 for:
Example Context7 queries:
/websites/postgresql - PostgreSQL indexing and optimization/mongodb/docs - MongoDB aggregation and sharding/websites/redis_io - Redis data structures and caching/websites/cloud_google-bigquery - BigQuery partitioning and clustering/websites/learn_microsoft-en-us-azure-cosmos-db - Cosmos DB consistency and partitioningWhat SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
npx claudepluginhub lagowski/claudeautopm --plugin dbOther plugins' skills for the same job