Skip to main content
skill CX Codex

database-scout — Claude Code skill: explore SQLite and PostgreSQL

A read-only skill for SQLite and PostgreSQL: lists tables, inspects schemas, previews rows and renders Mermaid ER diagrams. Queries stay read-only.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add zebbern/claude-code-guide --skill database-scout -a claude-code
Open on GitHub

What database-scout does

The skill hands your agent a read-only window into a database. It lists tables and views with row counts, walks a table schema — column names, types, PK/FK/NOT NULL constraints, indexes and defaults — previews the first N rows, and emits Mermaid erDiagram syntax you can render right away.

Everything runs through one script, scripts/db_explorer.py, with the subcommands list-tables, describe, preview, er-diagram and query. SQLite needs nothing beyond the built-in sqlite3 module; PostgreSQL support requires psycopg2-binary. Python 3.8+ is the floor.

Write protection sits at two levels. SQLite opens through a ?mode=ro URI, PostgreSQL gets SET SESSION READ ONLY, and the SQL itself passes a whitelist — only SELECT, WITH, EXPLAIN, PRAGMA and SHOW get through. INSERT, UPDATE, DELETE, DROP, ALTER, CREATE and 30+ other keywords are blocked, and semicolon-separated statements are rejected outright. So if you want an agent that can migrate or seed a database, look elsewhere: writes are closed at the connection level here.

What it helps with

  • see which tables and views a database holds, with row counts
  • read a table schema: columns, types, PK/FK, indexes
  • peek at the first rows to understand the data shape
  • turn table relationships into a Mermaid ER diagram
  • run a SELECT without risking production data

Example prompts for the agent

  • list all tables in data.db
  • describe the schema of the orders table
  • generate an ER diagram for this database

How to install database-scout

1Skills CLI (Vercel)

npx skills add zebbern/claude-code-guide --skill database-scout -a claude-code

2Manually: put the files in place

~/.claude/skills/database-scout/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/database-scout/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about database-scout

How do I install database-scout in Claude?

Run npx skills add zebbern/claude-code-guide --skill database-scout -a claude-code. The skill lands in ~/.claude/skills/database-scout/SKILL.md.

What does database-scout do?

It lists tables and views, inspects table schemas with types and constraints, previews data, generates Mermaid ER diagrams, and runs read-only SQL against SQLite and PostgreSQL.

Which SQL statements are allowed?

Only SELECT, WITH, EXPLAIN, PRAGMA and SHOW. Write operations and semicolon-separated multi-statements are rejected.

Source text

SKILL.md · MIT
---
name: database-scout
description: "Explore SQLite and PostgreSQL databases: list tables, inspect schemas (columns/types/constraints), preview data, generate Mermaid ER diagrams, and run safe read-only queries. Triggered by requests to explore a database, view table structures, describe tables, generate diagrams, or query data, and by keywords like database exploration, schema, ER diagram, or SQL query."
license: MIT
---

# database-scout

Read-only exploration tool for SQLite / PostgreSQL databases — inspect table schemas, preview data, generate ER diagrams, and run safe queries.

## Feature Overview

| Feature | Description |
|---------|-------------|
| List all tables | Show tables and views in the database, with row counts |
| Inspect table schema | Column names, types, constraints (PK/FK/NOT NULL), indexes, defaults |
| Data preview | View the first N rows of a table |
| ER diagram generation | Output Mermaid erDiagram syntax, ready to render |
| Safe read-only queries | Only SELECT/WITH/EXPLAIN allowed; write operations are blocked |

## Security Mechanisms

- **Connection-level read-only**: SQLite opens with `?mode=ro` URI; PostgreSQL uses `SET SESSION READ ONLY`
- **SQL whitelist**: Only statements starting with SELECT / WITH / EXPLAIN / PRAGMA / SHOW are allowed
- **Dangerous keyword blocking**: INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, and 30+ other keywords are blocked
- **Multi-statement blocking**: Semicolon-separated multiple SQL statements are rejected (prevents injection)
- **Identifier escaping**: Table names are double-quote escaped to prevent SQL injection

## Quick Start

```bash
# List all tables in a SQLite database
python3 scripts/db_explorer.py --db-path data.db list-tables

# Inspect table schema
python3 scripts/db_explorer.py --db-path data.db describe users

# Preview data (default 20 rows)
python3 scripts/db_explorer.py --db-path data.db preview orders --limit 10

# Generate Mermaid ER diagram
python3 scripts/db_explorer.py --db-path data.db er-diagram

# Run a read-only query
python3 scripts/db_explorer.py --db-path data.db query "SELECT name, age FROM users WHERE age > 18 LIMIT 10"
```

### PostgreSQL

```bash
# Connect to PostgreSQL
python3 scripts/db_explorer.py --db-type postgres --dsn "host=localhost dbname=mydb user=reader" list-tables

# Inspect table schema
python3 scripts/db_explorer.py --db-type postgres --dsn "host=localhost dbname=mydb user=reader" describe orders
```

## Detailed Usage

### Parameters

| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| `--db-type` | No | sqlite | Database type: sqlite or postgres |
| `--db-path` | Yes (for SQLite) | — | Path to the SQLite database file |
| `--dsn` | Yes (for PostgreSQL) | — | PostgreSQL connection string |

### Subcommands

| Command | Description | Example |
|---------|-------------|---------|
| `list-tables` | List all tables/views | `list-tables` |
| `describe <table>` | Show detailed table schema | `describe users` |
| `preview <table> [--limit N / -n N]` | Preview the first N rows | `preview orders --limit 5` |
| `er-diagram` | Generate Mermaid ER diagram | `er-diagram` |
| `query "<sql>"` | Run a read-only SQL query | `query "SELECT count(*) FROM users"` |

## Output Examples

### list-tables

```json
[
  {"name": "users", "type": "table", "row_count": 1500},
  {"name": "orders", "type": "table", "row_count": 8200},
  {"name": "user_stats", "type": "view", "row_count": 1500}
]
```

### describe

```json
{
  "table": "orders",
  "row_count": 8200,
  "columns": [
    {"cid": 0, "name": "id", "type": "INTEGER", "notnull": true, "default": null, "primary_key": true},
    {"cid": 1, "name": "user_id", "type": "INTEGER", "notnull": true, "default": null, "primary_key": false},
    {"cid": 2, "name": "amount", "type": "REAL", "notnull": false, "default": "0.0", "primary_key": false}
  ],
  "foreign_keys": [
    {"from": "user_id", "to_table": "users", "to_column": "id"}
  ],
  "indexes": [
    {"name": "idx_orders_user_id", "unique": false, "columns": ["user_id"]}
  ]
}
```

### er-diagram (Mermaid)

```mermaid
erDiagram
    users {
        INTEGER id PK
        TEXT name
        TEXT email
        INTEGER age
    }
    orders {
        INTEGER id PK
        INTEGER user_id FK
        REAL amount
        TEXT created_at
    }
    users ||--o{ orders : "user_id"
```

## Dependencies

- Python 3.8+ (`sqlite3` is a built-in module)
- PostgreSQL support requires: `pip install psycopg2-binary`

© zebbern · MIT · zebbern/claude-code-guide

Similar skills

All skills for Data and databases →

From the same set12

pipeline-blueprint The skill hands you CI/CD pipeline templates for GitHub Actions and GitLab CI, picked by project type. Useful when you're setting up CI or cleaning up a pipeline that grew messy. CX Codex +1 ★ 4,676repo stars network-101 A skill that walks the agent through standing up and testing HTTP, HTTPS, SNMP and SMB in a pentest lab, from service config to log analysis. CX Codex +1 ★ 4,676repo stars linux-shell-scripting A skill that hands your agent ready bash templates for backups, resource monitoring, user management and log parsing. Useful when you want a working script, not a sketch. CX Codex +1 ★ 4,676repo stars dev-guide-generator Turns a technical topic into a full tutorial: prerequisites, environment setup, core steps, error troubleshooting and a closing cheatsheet. CX Codex +1 ★ 4,676repo stars cv-tailor This skill compares your resume against a job description, scores keyword coverage, and rewrites experience bullets with STAR and numbers. CX Codex +1 ★ 4,676repo stars code-documenter A skill that writes docstrings, builds OpenAPI specs and documentation sites. Useful when the code works but nobody documented it. CX Codex +1 ★ 4,676repo stars aws-penetration-testing A skill that walks the agent through AWS pentesting: IAM enumeration, privilege escalation, metadata SSRF, S3 and Lambda exploitation. CX Codex +1 ★ 4,676repo stars api-shape-explorer Runs several sub-agents at once so you get radically different interface designs for a module and can compare them before writing code. CX Codex +1 ★ 4,676repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor