Read-only access to configured databases for schema inspection and SQL querying across environments.
You now have read-only access to multiple databases through the database command. This skill supports connecting to production, staging, local, or any other configured database.
database dbs
List all configured database connections with their connection status. Shows which database is currently active.
Using a specific database:
database --db production <command>
database --db staging query "SELECT * FROM tasks"
database --db local tables
If you don't specify --db, the default database will be used (usually the first one configured).
database test
Test database connectivity and show connection details for the active database.
database --db staging test
Test connection to a specific database.
database tables
List all tables in the database.
database describe <table_name>
Show the schema (columns, types) and indexes for a specific table.
database stats
Show database statistics including row counts for all tables.
database query "SELECT * FROM tasks WHERE status = 'open' LIMIT 10"
Execute a custom SELECT query. Returns results in table format.
database query "SELECT COUNT(*) FROM users" json
Execute a query and return results in JSON format (useful for parsing).
Supported formats:
table (default) - Human-readable table formatjson - JSON array of objectscsv - Comma-separated valuesUse database when you need to:
tables and describe to understand the schemadatabase tasks instead of raw SQLdatabase test to check connection⚠️ MANDATORY PROCEDURE: Before writing ANY custom query, you MUST verify the table schema first.
This prevents column name errors and ensures your queries work correctly.
describe❌ WRONG - Don't do this:
# Directly querying without checking schema
database query "SELECT id, name, status FROM projects_task LIMIT 5"
# Error: Unknown column 'status' - should be 'status_id'
✅ CORRECT - Always do this:
# Step 1: Check the schema first
database describe projects_task
# Step 2: Review the output to see actual columns
# Output shows: id, code, name, status_id, plan_date, etc.
# Step 3: Write query with correct column names
database query "SELECT id, code, name, status_id, plan_date FROM projects_task LIMIT 5"
# Step 1: Check both table schemas
database describe sytexauth_user
database describe people_profile
# Step 2: Identify join columns and field names
# sytexauth_user has: id, email, profile_id
# people_profile has: id, name
# Step 3: Write the JOIN query correctly
database query "
SELECT u.id, u.email, p.name
FROM sytexauth_user u
JOIN people_profile p ON u.profile_id = p.id
WHERE u.id = 1
"
# List all tables
database tables
# Describe a specific table (shows columns, types, keys)
database describe projects_task
# Describe multiple tables before complex queries
database describe sytexauth_user
database describe people_profile
database describe projects_project
When you have multiple databases configured (e.g., production, staging, local), you can easily switch between them:
# List all configured databases
database dbs
# Compare data between environments
database --db production query "SELECT COUNT(*) FROM projects_task"
database --db staging query "SELECT COUNT(*) FROM projects_task"
# Check schema differences
database --db production describe projects_task
database --db staging describe projects_task
# Debug issues by checking production vs staging
database --db production query "SELECT * FROM projects_task WHERE id = 47515"
database --db staging query "SELECT * FROM projects_task WHERE id = 47515"
# Test queries in staging before running in production
database --db staging query "SELECT COUNT(*) FROM users WHERE last_activity > NOW() - INTERVAL 30 DAY"
# If it works, run in production:
database --db production query "SELECT COUNT(*) FROM users WHERE last_activity > NOW() - INTERVAL 30 DAY"
Default Database:
If you don't specify --db, the first configured database is used by default. You can set a default by configuring SYTEXDB_DEFAULT_DB in your .env file.
Find tasks by status:
database query "SELECT id, title, status FROM tasks WHERE status = 'in_progress' LIMIT 10"
Count records by type:
database query "SELECT status, COUNT(*) as count FROM tasks GROUP BY status"
Join queries:
database query "
SELECT t.title, p.name as project_name
FROM tasks t
JOIN projects p ON t.project_id = p.id
LIMIT 10
"
Check specific record:
database query "SELECT * FROM tasks WHERE id = 12345"
If you get connection errors:
database test to verify credentialsdatabase tables to see available tablesdatabase describe <table> to see columnsIf you get "mysql client not found":
brew install mysql-clientapt-get install mysql-client or yum install mysql.env file (never commit this)For command usage:
database help
For table-specific information:
database describe <table_name>