database-scout

Inspect SQLite and PostgreSQL schemas, preview data, and run read-only queries.

4.6k|462|Updated Jun 21, 2025
One-click install
npx skills add https://github.com/zebbern/claude-code-guide --skill database-scout
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-scout
Source: https://github.com/zebbern/claude-code-guide/tree/main/skills/database-scout
Command: npx skills add https://github.com/zebbern/claude-code-guide --skill database-scout

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires psycopg2-binary, and includes scripts (resource) components.

What problem does it solve?

Exploring an unfamiliar database usually requires manual SQL work and risks accidental writes. This Skill provides safe, read-only inspection of SQLite and PostgreSQL databases so you can understand table structures and data without modifying anything.

Core Features & Use Cases

  • Schema Inspection: List all tables and views with row counts, and describe columns, types, constraints, foreign keys, and indexes for any table.
  • Data Preview & ER Diagrams: Preview the first N rows of a table and generate Mermaid erDiagram syntax ready to render in documentation.
  • Safe Read-Only Queries: Execute SELECT/WITH/EXPLAIN queries with connection-level read-only mode, keyword blocking, and multi-statement rejection.
  • Use Case: You inherit a legacy SQLite database with no documentation. Use this Skill to list tables, describe each schema, and generate an ER diagram to map out the data model in minutes.

Quick Start

Ask the agent to explore the database at data.db by listing its tables and generating an ER diagram of the schema.

Frequently Asked Questions about database-scout

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I list all tables in a SQLite database with Python?

Run the db_explorer.py script with the list-tables subcommand and the --db-path argument pointing to your SQLite file. It returns a JSON array of tables and views with row counts, opened in read-only mode via a file URI.

How to generate a Mermaid ER diagram from a database schema?

Use the er-diagram subcommand, which reads table definitions and foreign keys from the database and outputs Mermaid erDiagram syntax. The output marks primary keys and foreign keys and can be pasted directly into any Mermaid renderer.

Does this tool support PostgreSQL as well as SQLite?

Yes, PostgreSQL is supported by passing --db-type postgres and a --dsn connection string. It requires the psycopg2-binary package and connects with a read-only session, querying information_schema for table metadata.

Can read-only database queries still modify data?

No. The tool opens SQLite with mode=ro and sets PostgreSQL sessions to read-only, then validates SQL by allowing only SELECT, WITH, EXPLAIN, PRAGMA, and SHOW statements while blocking over 30 write keywords and multi-statement input.

Why does my SQL query get rejected by the explorer?

Queries are rejected if they do not start with an allowed keyword, contain blocked write keywords like INSERT or DROP, or include semicolons indicating multiple statements. Rewrite the query as a single SELECT or WITH statement.