{"id":"75a3924e-eccd-4804-a72f-a5fc877ea0c1","entityType":"agent","slug":"clawhub-lrg913427-dot-db-explorer-lrg","name":"Db Explorer","canonicalUrl":"https://www.xpersona.co/agent/clawhub-lrg913427-dot-db-explorer-lrg","canonicalPath":"/agent/clawhub-lrg913427-dot-db-explorer-lrg","generatedAt":"2026-10-10T15:53:30.833Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-10T13:04:05.255Z","emptyReason":null},"description":"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a datab... Skill: Db Explorer Owner: lrg913427-dot Summary: Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a datab... Tags: latest:3.0.0 Version history: v3.0.0 | 2026-06-04T04:06:03.636Z | auto - Removed the skill-card.md file. - No other functional or documentation changes noted. v2.6.0 | 2026-06-03T16:05:30.806Z | auto - Up","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 1.4K downloads reported by the source. Last updated 10/10/2026.","installCommand":"clawhub skill install s175nn6ap9fe4ne23bws9svzm185ywrq:db-explorer-lrg","sourceUrl":"https://clawhub.ai/lrg913427-dot/db-explorer-lrg","homepage":"https://clawhub.ai/lrg913427-dot/skills/db-explorer-lrg","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/lrg913427-dot/db-explorer-lrg","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/lrg913427-dot/skills/db-explorer-lrg","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":63,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a datab..."},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-10T13:04:05.255Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T13:04:05.255Z","emptyReason":null},"stars":null,"forks":null,"downloads":1422,"packageName":null,"latestVersion":"3.0.0","tractionLabel":"1.4K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-10T13:04:05.255Z","emptyReason":null},"lastUpdatedAt":"2026-10-10T13:04:05.255Z","lastCrawledAt":"2026-10-10T13:04:05.255Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-11T13:04:05.255Z","lastVerifiedAt":null,"highlights":[{"version":"3.0.0","createdAt":"2026-06-04T04:06:03.636Z","changelog":"- Removed the skill-card.md file. - No other functional or documentation changes noted.","fileCount":3,"zipByteSize":5186},{"version":"2.6.0","createdAt":"2026-06-03T16:05:30.806Z","changelog":"- Updated version from 2.4.0 to 2.5.0 in SKILL.md. - Removed the skill-card.md file. - No changes to feature set, documentation content, or functionality.","fileCount":3,"zipByteSize":5271},{"version":"2.5.0","createdAt":"2026-05-31T16:03:02.364Z","changelog":"自动迭代维护","fileCount":3,"zipByteSize":5303},{"version":"2.4.0","createdAt":"2026-05-28T10:03:03.321Z","changelog":"- Removed the file skill-card.md. - No other changes; skill content and usage remain the same.","fileCount":3,"zipByteSize":5227},{"version":"2.3.1","createdAt":"2026-05-26T04:03:22.516Z","changelog":"- Updated version number in SKILL.md from 2.1.0 to 2.3.0. - No other functional or content changes were made.","fileCount":3,"zipByteSize":5305},{"version":"2.3.0","createdAt":"2026-05-24T04:03:32.154Z","changelog":"- No file or documentation changes detected in this release. - Version number updated from 2.1.0 to 2.3.0. - No new features, fixes, or modifications introduced.","fileCount":2,"zipByteSize":3993},{"version":"2.2.0","createdAt":"2026-05-23T10:03:45.879Z","changelog":"No changes detected in this release. - Version number updated from 2.1.0 to 2.2.0. - No file or documentation changes found.","fileCount":2,"zipByteSize":3994},{"version":"2.1.0","createdAt":"2026-05-21T10:03:47.942Z","changelog":"Version 2.1.0 - Updated SKILL.md to increment version from 2.0.0 to 2.1.0. - No other content or feature changes detected.","fileCount":2,"zipByteSize":3994}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s175nn6ap9fe4ne23bws9svzm185ywrq:db-explorer-lrg","setupComplexity":"low","setupSteps":["Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-10T15:53:30.831Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-lrg913427-dot-db-explorer-lrg/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-10-10T13:04:05.255Z","emptyReason":null},"readme":"Skill: Db Explorer\n\nOwner: lrg913427-dot\n\nSummary: Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a datab...\n\nTags: latest:3.0.0\n\nVersion history:\n\nv3.0.0 | 2026-06-04T04:06:03.636Z | auto\n\n- Removed the skill-card.md file.\n- No other functional or documentation changes noted.\n\nv2.6.0 | 2026-06-03T16:05:30.806Z | auto\n\n- Updated version from 2.4.0 to 2.5.0 in SKILL.md.\n- Removed the skill-card.md file.\n- No changes to feature set, documentation content, or functionality.\n\nv2.5.0 | 2026-05-31T16:03:02.364Z | user\n\n自动迭代维护\n\nv2.4.0 | 2026-05-28T10:03:03.321Z | auto\n\n- Removed the file skill-card.md.\n- No other changes; skill content and usage remain the same.\n\nv2.3.1 | 2026-05-26T04:03:22.516Z | auto\n\n- Updated version number in SKILL.md from 2.1.0 to 2.3.0.\n- No other functional or content changes were made.\n\nv2.3.0 | 2026-05-24T04:03:32.154Z | auto\n\n- No file or documentation changes detected in this release.\n- Version number updated from 2.1.0 to 2.3.0. \n- No new features, fixes, or modifications introduced.\n\nv2.2.0 | 2026-05-23T10:03:45.879Z | auto\n\nNo changes detected in this release.\n\n- Version number updated from 2.1.0 to 2.2.0.\n- No file or documentation changes found.\n\nv2.1.0 | 2026-05-21T10:03:47.942Z | auto\n\nVersion 2.1.0\n\n- Updated SKILL.md to increment version from 2.0.0 to 2.1.0.\n- No other content or feature changes detected.\n\nv2.0.1 | 2026-05-18T16:03:38.540Z | auto\n\nVersion 2.0.1\n\n- No file changes were detected in this release.\n- No updates to documentation or code.\n\nv2.0.0 | 2026-05-09T10:03:24.322Z | auto\n\nMajor update: Expanded instructions and best practices for multi-database exploration from the terminal.\n\n- Added detailed usage guide for connecting, querying, and exploring PostgreSQL, MySQL, SQLite, MongoDB, and Redis.\n- Included explicit safety and confirmation rules for data modification commands.\n- Comprehensive schema exploration and export workflows provided.\n- Introduced common performance and diagnostic queries for PostgreSQL and MySQL.\n- Added backup and restore procedures for supported databases.\n- Clarified install instructions and CLI tool usage per database.\n\nArchive index:\n\nArchive v3.0.0: 3 files, 5186 bytes\n\nFiles: skill-card.md (2162b), SKILL.md (9834b), _meta.json (134b)\n\nFile v3.0.0:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.5.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v3.0.0:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"3.0.0\",\n  \"publishedAt\": 1780545963636\n}\n\nFile v3.0.0:skill-card.md\n\n## Description:\n\nConnect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis), run queries, inspect schemas, export data, and debug database issues.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[lrg913427-dot](https://clawhub.ai/user/lrg913427-dot)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers and engineers use this skill to inspect database schemas, run bounded queries, diagnose database health, and export or migrate data across PostgreSQL, MySQL, SQLite, MongoDB, and Redis.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Database export, restore, import, and migration commands can expose or alter data if copied directly.\n\nMitigation: Use least-privileged, non-production credentials where possible, confirm the exact target database before running data-changing commands, and review generated commands before execution.\n\nRisk: Credentials may be exposed when passwords are pasted into command lines or shared output locations.\n\nMitigation: Prefer environment variables or private secret handling for credentials, avoid echoing real passwords, and write exports to private, access-controlled locations instead of shared temporary paths.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/lrg913427-dot/skills/db-explorer-lrg)\n- [ClawHub Publisher Profile](https://clawhub.ai/user/lrg913427-dot)\n- [MongoDB Shell Documentation](https://www.mongodb.com/docs/shell)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown with inline shell commands and query snippets]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May include database CLI commands, SQL or shell snippets, schema summaries, export guidance, and safety checks.]\n\n## Skill Version(s):\n\n3.0.0 (source: server release metadata)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nArchive v2.6.0: 3 files, 5271 bytes\n\nFiles: skill-card.md (2449b), SKILL.md (9834b), _meta.json (134b)\n\nFile v2.6.0:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.5.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.6.0:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.6.0\",\n  \"publishedAt\": 1780502730806\n}\n\nFile v2.6.0:skill-card.md\n\n## Description: <br>\nConnect to and explore databases including PostgreSQL, MySQL, SQLite, MongoDB, and Redis; run queries, inspect schemas, export data, and debug database issues. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[lrg913427-dot](https://clawhub.ai/user/lrg913427-dot) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers, engineers, and database operators use this skill to inspect database structure, run diagnostic queries, export data, and prepare backup, restore, or migration commands with review-oriented safeguards. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Database export, restore, migration, and write commands can alter, overwrite, or expose sensitive data. <br>\nMitigation: Use read-only credentials where possible, avoid production connections unless explicitly intended, and review every export, restore, migration, or write command before execution. <br>\nRisk: Database credentials and connection strings may be exposed through command history, logs, or copied output. <br>\nMitigation: Prefer environment variables or protected secret handling, and avoid echoing passwords or full credential-bearing connection strings. <br>\nRisk: Large or broad queries can retrieve excessive data or create operational load. <br>\nMitigation: Limit result sets by default, require explicit user intent for full exports, and review potentially expensive diagnostic queries before running them. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/lrg913427-dot/db-explorer-lrg) <br>\n- [ClawHub publisher profile](https://clawhub.ai/user/lrg913427-dot) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance] <br>\n**Output Format:** [Markdown with inline SQL and bash code blocks] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May include database queries, CLI commands, schema summaries, export steps, and safety checks.] <br>\n\n## Skill Version(s): <br>\n2.6.0 (source: server release metadata; artifact frontmatter states 2.5.0) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nArchive v2.5.0: 3 files, 5303 bytes\n\nFiles: skill-card.md (2502b), SKILL.md (9834b), _meta.json (134b)\n\nFile v2.5.0:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.4.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.5.0:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.5.0\",\n  \"publishedAt\": 1780243382364\n}\n\nFile v2.5.0:skill-card.md\n\n## Description: <br>\nConnect to and explore databases including PostgreSQL, MySQL, SQLite, MongoDB, and Redis, with guidance for queries, schema inspection, exports, diagnostics, backups, restores, and migrations. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[lrg913427-dot](https://clawhub.ai/user/lrg913427-dot) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers, operators, and data practitioners use this skill to inspect database schemas, run bounded queries, diagnose database health, and prepare exports or backups from common database systems. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Database access can expose sensitive data or credentials. <br>\nMitigation: Use read-only or test credentials where possible, keep secrets in environment variables, and avoid echoing passwords or connection strings. <br>\nRisk: Exports, backups, restores, imports, migrations, or production queries can expose or alter data if aimed at the wrong database. <br>\nMitigation: Require explicit user approval, review exact target databases and output paths, and clean up exported files containing sensitive data. <br>\nRisk: Write or destructive database commands can change or delete data. <br>\nMitigation: Stay read-only by default, show the exact command before execution, and use transaction safety with rollback review before commit. <br>\n\n\n## Reference(s): <br>\n- [ClawHub Skill Page](https://clawhub.ai/lrg913427-dot/db-explorer-lrg) <br>\n- [ClawHub Publisher Profile](https://clawhub.ai/user/lrg913427-dot) <br>\n- [MongoDB Shell Documentation](https://www.mongodb.com/docs/mongodb-shell/) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance] <br>\n**Output Format:** [Markdown guidance with inline SQL and shell command examples] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May propose commands that create export, dump, backup, or migration files such as CSV, JSON, SQL, or database backup artifacts.] <br>\n\n## Skill Version(s): <br>\n2.5.0 (source: server release metadata; artifact frontmatter reports 2.4.0) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nArchive v2.4.0: 3 files, 5227 bytes\n\nFiles: skill-card.md (2356b), SKILL.md (9834b), _meta.json (134b)\n\nFile v2.4.0:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.3.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.4.0:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.4.0\",\n  \"publishedAt\": 1779962583321\n}\n\nFile v2.4.0:skill-card.md\n\n## Description: <br>\nConnect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[lrg913427-dot](https://clawhub.ai/user/lrg913427-dot) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers and engineers use this skill to inspect database schemas, run read-oriented queries, export result sets, and diagnose database health or performance issues across PostgreSQL, MySQL, SQLite, MongoDB, and Redis. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: The skill can guide real database CLI work when given credentials, including access to production systems. <br>\nMitigation: Use read-only, least-privilege credentials by default and avoid production access unless it is necessary and approved. <br>\nRisk: Exports, backups, restores, imports, migrations, or writes can expose data or change database state. <br>\nMitigation: Review and confirm the exact command before execution, require explicit confirmation for writes, and store generated dumps or CSV/JSON files only in approved secure locations. <br>\nRisk: Large or unconstrained queries can reveal more data than intended or affect database performance. <br>\nMitigation: Limit query results by default and expand scope only when the user explicitly requests it. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/lrg913427-dot/db-explorer-lrg) <br>\n- [Publisher profile](https://clawhub.ai/user/lrg913427-dot) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance] <br>\n**Output Format:** [Markdown with inline shell and database command examples] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May include database queries, schema summaries, export commands, backup and restore commands, and operational safety guidance.] <br>\n\n## Skill Version(s): <br>\n2.4.0 (source: server release metadata) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nArchive v2.3.1: 3 files, 5305 bytes\n\nFiles: skill-card.md (2500b), SKILL.md (9834b), _meta.json (134b)\n\nFile v2.3.1:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.3.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.3.1:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.3.1\",\n  \"publishedAt\": 1779768202516\n}\n\nFile v2.3.1:skill-card.md\n\n## Description: <br>\nConnect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis), run queries, inspect schemas, export data, and debug database issues. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[lrg913427-dot](https://clawhub.ai/user/lrg913427-dot) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers and engineers use this skill to connect to PostgreSQL, MySQL, SQLite, MongoDB, or Redis databases, inspect schemas and health signals, run bounded queries, and export selected data from the terminal. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Restore, migration, or write commands can change live databases despite the skill's read-only-by-default posture. <br>\nMitigation: Use read-only database users where possible, avoid production restore/import tasks through this skill, and require explicit confirmation before any command that writes or restores data. <br>\nRisk: Exports and backups can contain private or sensitive data. <br>\nMitigation: Treat exported files as sensitive, store them only in approved locations, restrict sharing, and delete temporary exports when they are no longer needed. <br>\nRisk: Database credentials can be exposed through command history, logs, or pasted connection strings. <br>\nMitigation: Prefer environment variables or secret-managed connection strings and avoid echoing passwords or full credentials in terminal output. <br>\n\n\n## Reference(s): <br>\n- [ClawHub skill page](https://clawhub.ai/lrg913427-dot/db-explorer-lrg) <br>\n- [Publisher profile](https://clawhub.ai/user/lrg913427-dot) <br>\n- [MongoDB Shell documentation](https://www.mongodb.com/docs/mongodb-shell/) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [guidance, shell commands, code, configuration] <br>\n**Output Format:** [Markdown with inline bash and SQL code blocks] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [May include database CLI commands, schema summaries, diagnostic queries, export commands, and safety checks.] <br>\n\n## Skill Version(s): <br>\n2.3.1 (source: server release metadata; SKILL.md frontmatter says 2.3.0) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nArchive v2.3.0: 2 files, 3993 bytes\n\nFiles: SKILL.md (9834b), _meta.json (134b)\n\nFile v2.3.0:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.1.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.3.0:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.3.0\",\n  \"publishedAt\": 1779595412154\n}\n\nArchive v2.2.0: 2 files, 3994 bytes\n\nFiles: SKILL.md (9834b), _meta.json (134b)\n\nFile v2.2.0:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.1.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.2.0:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.2.0\",\n  \"publishedAt\": 1779530625879\n}\n\nArchive v2.1.0: 2 files, 3994 bytes\n\nFiles: SKILL.md (9834b), _meta.json (134b)\n\nFile v2.1.0:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.1.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.1.0:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.1.0\",\n  \"publishedAt\": 1779357827942\n}\n\nArchive v2.0.1: 2 files, 3993 bytes\n\nFiles: SKILL.md (9834b), _meta.json (134b)\n\nFile v2.0.1:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.0.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.0.1:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.0.1\",\n  \"publishedAt\": 1779120218540\n}\n\nArchive v2.0.0: 2 files, 3994 bytes\n\nFiles: SKILL.md (9834b), _meta.json (134b)\n\nFile v2.0.0:SKILL.md\n\n---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.0.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n2. **Limit results** — Always add `LIMIT 100` (or equivalent) to SELECT queries unless user asks for all\n3. **Show before execute** — For any write operation, show the exact SQL/command and ask for confirmation\n4. **No passwords in history** — Use environment variables or connection strings, don't echo passwords\n5. **Transaction safety** — For writes, wrap in BEGIN/ROLLBACK first, show results, then ask to COMMIT\n\n### 4. Schema Exploration Workflow\n\nWhen user says \"explore the database\" or \"show me the schema\":\n\n```bash\n# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map\n```\n\nPostgreSQL full schema dump:\n```bash\npsql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\"\n```\n\nMySQL full schema dump:\n```bash\nmysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\"\n```\n\n### 5. Export Formats\n\nExport query results to common formats:\n\n```bash\n# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\"\n```\n\n### 6. Common Diagnostic Queries\n\n```sql\n-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;\n```\n\n## Performance Analysis\n\n### PostgreSQL Performance\n\n```bash\n# Slow queries (active for > 1s)\npsql \"$CONN\" -c \"\nSELECT pid, now() - query_start AS duration, query\nFROM pg_stat_activity\nWHERE state = 'active' AND now() - query_start > interval '1 second'\nORDER BY duration DESC;\n\"\n\n# Index usage\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename, indexname, idx_scan, idx_tup_read\nFROM pg_stat_user_indexes\nORDER BY idx_scan ASC LIMIT 20;\n\"\n\n# Table bloat\npsql \"$CONN\" -c \"\nSELECT schemaname, tablename,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) AS total_size,\n  pg_size_pretty(pg_relation_size(schemaname||'.'||tablename)) AS table_size,\n  pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename) - pg_relation_size(schemaname||'.'||tablename)) AS index_size\nFROM pg_tables\nWHERE schemaname = 'public'\nORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC LIMIT 10;\n\"\n\n# Cache hit ratio (should be > 99%)\npsql \"$CONN\" -c \"\nSELECT\n  sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) AS cache_hit_ratio\nFROM pg_statio_user_tables;\n\"\n```\n\n### MySQL Performance\n\n```bash\n# Slow queries\nmysql \"$CONN\" -e \"SELECT * FROM information_schema.processlist WHERE TIME > 1 ORDER BY TIME DESC;\"\n\n# Index usage\nmysql \"$CONN\" -e \"\nSELECT table_name, index_name, cardinality\nFROM information_schema.statistics\nWHERE table_schema = DATABASE()\nORDER BY cardinality DESC LIMIT 20;\n\"\n\n# Table sizes\nmysql \"$CONN\" -e \"\nSELECT table_name,\n  ROUND(data_length/1024/1024, 2) AS data_mb,\n  ROUND(index_length/1024/1024, 2) AS index_mb,\n  table_rows\nFROM information_schema.tables\nWHERE table_schema = DATABASE()\nORDER BY data_length DESC LIMIT 10;\n\"\n```\n\n## Backup & Restore\n\n### PostgreSQL\n\n```bash\n# Backup single database\npg_dump \"$CONN\" > backup_$(date +%Y%m%d).sql\n\n# Backup single table\npg_dump \"$CONN\" -t table_name > table_backup.sql\n\n# Restore\npsql \"$CONN\" < backup.sql\n\n# Backup with compression\npg_dump \"$CONN\" | gzip > backup_$(date +%Y%m%d).sql.gz\n```\n\n### MySQL\n\n```bash\n# Backup single database\nmysqldump -h host -u user -p dbname > backup_$(date +%Y%m%d).sql\n\n# Backup single table\nmysqldump -h host -u user -p dbname table_name > table_backup.sql\n\n# Restore\nmysql -h host -u user -p dbname < backup.sql\n```\n\n### SQLite\n\n```bash\n# Backup\nsqlite3 /path/to/db.db \".backup /tmp/backup.db\"\n\n# Or just copy\ncp /path/to/db.db /tmp/backup_$(date +%Y%m%d).db\n```\n\n## Data Migration Helpers\n\n### Copy table between databases\n\n```bash\n# PostgreSQL to CSV to MySQL\npsql \"$PG_CONN\" -c \"\\copy table_name TO '/tmp/export.csv' WITH CSV HEADER\"\nmysql \"$MYSQL_CONN\" -e \"LOAD DATA LOCAL INFILE '/tmp/export.csv' INTO TABLE table_name FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 ROWS;\"\n```\n\n### Schema comparison\n\n```bash\n# Get PostgreSQL schema hash for comparison\npsql \"$CONN\" -c \"\nSELECT md5(string_agg(table_name || column_name || data_type, '' ORDER BY table_name, ordinal_position))\nFROM information_schema.columns\nWHERE table_schema = 'public';\n\"\n```\n\n## Pitfalls\n\n- **Connection strings with special chars** — URL-encode passwords containing @, :, /, etc.\n- **SSL requirements** — Many cloud databases (RDS, Cloud SQL, Supabase) require `?sslmode=require` or `--ssl-mode=REQUIRED`\n- **Timeout on large tables** — Always LIMIT unless user explicitly wants full export\n- **SQLite locking** — Only one writer at a time; use WAL mode for concurrent reads: `PRAGMA journal_mode=WAL;`\n- **MongoDB auth database** — Sometimes auth is on `admin` db, not the target db: `?authSource=admin`\n- **Redis SELECT** — Redis has 16 databases (0-15); check which one: `redis-cli INFO keyspace`\n\n## Verification\n\nAfter connecting:\n1. Run a simple query to confirm connection works\n2. List tables/collections to show the schema\n3. Run a count query on a key table to verify data access\n4. Check cache hit ratio (PostgreSQL) or slow queries (MySQL)\n5. Verify backup capability with a test dump\n\n## Environment Variables\n\nThe skill uses these if available:\n- `DATABASE_URL` — Full connection string (takes priority)\n- `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD` — Individual params\n- `DB_TYPE` — postgres/mysql/sqlite/mongo/redis\n\nFile v2.0.0:_meta.json\n\n{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"2.0.0\",\n  \"publishedAt\": 1778321004322\n}","readmeExcerpt":"Skill: Db Explorer Owner: lrg913427-dot Summary: Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a datab... Tags: latest:3.0.0 Version history: v3.0.0 | 2026-06-04T04:06:03.636Z | auto - Removed the skill-card.md file. - No other functional or documentation changes noted. v2.6.0 | 2026-06-03T16:05:30.806Z | auto - Up","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\""},{"language":"bash","snippet":"# Step 1: List all tables\n# Step 2: For each table, show columns, types, and constraints\n# Step 3: Show row counts\n# Step 4: Show foreign key relationships\n# Step 5: Summarize as a readable schema map"},{"language":"bash","snippet":"psql \"$CONN\" -c \"\nSELECT table_name, column_name, data_type, is_nullable, column_default\nFROM information_schema.columns\nWHERE table_schema = 'public'\nORDER BY table_name, ordinal_position;\n\""},{"language":"bash","snippet":"mysql \"$CONN\" -e \"\nSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_SCHEMA = DATABASE()\nORDER BY TABLE_NAME, ORDINAL_POSITION;\n\""},{"language":"bash","snippet":"# CSV (PostgreSQL)\npsql \"$CONN\" -c \"\\copy (SELECT * FROM table_name) TO '/tmp/export.csv' WITH CSV HEADER\"\n\n# CSV (MySQL)\nmysql \"$CONN\" -e \"SELECT * FROM table_name\" | sed 's/\\t/,/g' > /tmp/export.csv\n\n# JSON (PostgreSQL)\npsql \"$CONN\" -t -c \"SELECT json_agg(t) FROM (SELECT * FROM table_name LIMIT 100) t;\" > /tmp/export.json\n\n# SQLite to CSV\nsqlite3 /path/to/db.db \".mode csv\" \".headers on\" \".output /tmp/export.csv\" \"SELECT * FROM table_name;\" \".quit\""},{"language":"sql","snippet":"-- PostgreSQL: Table sizes\nSELECT schemaname, tablename, pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename))\nFROM pg_tables WHERE schemaname = 'public' ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;\n\n-- PostgreSQL: Active connections\nSELECT pid, usename, application_name, client_addr, state, query_start, query\nFROM pg_stat_activity WHERE state != 'idle';\n\n-- PostgreSQL: Slow queries (> 1s)\nSELECT pid, now() - pg_stat_activity.query_start AS duration, query\nFROM pg_stat_activity WHERE state = 'active' AND now() - pg_stat_activity.query_start > interval '1 second';\n\n-- MySQL: Table sizes\nSELECT table_name, ROUND(data_length/1024/1024, 2) AS data_mb, table_rows\nFROM information_schema.tables WHERE table_schema = DATABASE() ORDER BY data_length DESC;\n\n-- MySQL: Process list\nSHOW FULL PROCESSLIST;"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: db-explorer\ndescription: \"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a database, explore schema, check data, export results, or debug database issues.\"\nversion: 2.5.0\nauthor: lrg913427-dot\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [database, sql, postgresql, mysql, sqlite, mongodb, redis, query, schema, data]\n    related_skills: [jupyter-live-kernel, airtable]\n---\n\n# DB Explorer\n\nConnect to databases, run queries, explore schemas, and export data — all from the terminal.\n\n## When to Use\n\nActivate this skill when the user:\n- Says \"check the database\", \"query the DB\", \"show me the data\"\n- Wants to see table structure, row counts, or sample data\n- Needs to export data to CSV/JSON\n- Wants to find slow queries or check DB health\n- Mentions a database connection string or DB name\n\n## Supported Databases\n\n| Database   | CLI Tool     | Install (macOS)           | Install (Linux)                    |\n|-----------|-------------|---------------------------|-----------------------------------|\n| PostgreSQL | psql        | brew install postgresql    | apt install postgresql-client      |\n| MySQL      | mysql       | brew install mysql         | apt install mysql-client           |\n| SQLite     | sqlite3     | (built-in on macOS)       | apt install sqlite3                |\n| MongoDB    | mongosh     | brew install mongosh       | See mongodb.com/docs/shell         |\n| Redis      | redis-cli   | brew install redis         | apt install redis-tools            |\n\n## Quick Start\n\n### 1. Identify the Database\n\nAsk the user for:\n- Database type (postgres/mysql/sqlite/mongo/redis)\n- Connection string OR host/port/database/user/password\n- For SQLite: just the file path\n\n### 2. Connect and Explore\n\n```bash\n# PostgreSQL\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\dt\"           # list tables\npsql \"postgresql://user:password@host:5432/dbname\" -c \"\\d table_name\" # describe table\npsql \"postgresql://user:password@host:5432/dbname\" -c \"SELECT count(*) FROM table_name;\"\n\n# MySQL\nmysql -h host -u user -p dbname -e \"SHOW TABLES;\"\nmysql -h host -u user -p dbname -e \"DESCRIBE table_name;\"\nmysql -h host -u user -p dbname -e \"SELECT count(*) FROM table_name;\"\n\n# SQLite\nsqlite3 /path/to/db.db \".tables\"                    # list tables\nsqlite3 /path/to/db.db \".schema table_name\"         # describe table\nsqlite3 /path/to/db.db \"SELECT count(*) FROM table_name;\"\n\n# MongoDB\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.getCollectionNames()\"\nmongosh \"mongodb://user:password@host:27017/dbname\" --eval \"db.collection_name.countDocuments()\"\n\n# Redis\nredis-cli -h host -p 6379 -a password INFO keyspace\nredis-cli -h host -p 6379 -a password DBSIZE\nredis-cli -h host -p 6379 -a password KEYS \"*\"\n```\n\n### 3. Safety Rules\n\n**ALWAYS follow these rules:**\n\n1. **Read-only by default** — Never run INSERT/UPDATE/DELETE/DROP without explicit user confirmation\n"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn78qy8qw1m82vx09qkaawp9c985z0mn\",\n  \"slug\": \"db-explorer-lrg\",\n  \"version\": \"3.0.0\",\n  \"publishedAt\": 1780545963636\n}"},{"path":"skill-card.md","content":"## Description:\n\nConnect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis), run queries, inspect schemas, export data, and debug database issues.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[lrg913427-dot](https://clawhub.ai/user/lrg913427-dot)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers and engineers use this skill to inspect database schemas, run bounded queries, diagnose database health, and export or migrate data across PostgreSQL, MySQL, SQLite, MongoDB, and Redis.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Database export, restore, import, and migration commands can expose or alter data if copied directly.\n\nMitigation: Use least-privileged, non-production credentials where possible, confirm the exact target database before running data-changing commands, and review generated commands before execution.\n\nRisk: Credentials may be exposed when passwords are pasted into command lines or shared output locations.\n\nMitigation: Prefer environment variables or private secret handling for credentials, avoid echoing real passwords, and write exports to private, access-controlled locations instead of shared temporary paths.\n\n## Reference(s):\n\n- [ClawHub Skill Page](https://clawhub.ai/lrg913427-dot/skills/db-explorer-lrg)\n- [ClawHub Publisher Profile](https://clawhub.ai/user/lrg913427-dot)\n- [MongoDB Shell Documentation](https://www.mongodb.com/docs/shell)\n\n## Skill Output:\n\n**Output Type(s):** [text, markdown, shell commands, configuration, guidance]\n\n**Output Format:** [Markdown with inline shell commands and query snippets]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May include database CLI commands, SQL or shell snippets, schema summaries, export guidance, and safety checks.]\n\n## Skill Version(s):\n\n3.0.0 (source: server release metadata)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment."}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a datab... Skill: Db Explorer Owner: lrg913427-dot Summary: Connect to and explore databases (PostgreSQL, MySQL, SQLite, MongoDB, Redis). Run queries, inspect schemas, export data. Use when user wants to query a datab... Tags: latest:3.0.0 Version history: v3.0.0 | 2026-06-04T04:06:03.636Z | auto - Removed the skill-card.md file. - No other functional or documentation changes noted. v2.6.0 | 2026-06-03T16:05:30.806Z | auto - Up","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":1024,"uniquenessScore":49,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-10T13:04:05.255Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-10T13:04:05.255Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-10T15:53:30.833Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}