# Schema exploration

> Schema exploration is an open-source agent skill for developer tools. Lets an agent explore an unfamiliar PostgreSQL schema before writing SQL or answering data. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/timescale/pg-aiguide/tree/main/skills/schema-exploration
- **Repository:** https://github.com/timescale/pg-aiguide
- **GitHub stars:** 1,892
- **License:** Apache-2.0
- **Skill name:** schema-exploration
- **Collection:** https://github.com/timescale/pg-aiguide
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill guides an agent through reading an existing PostgreSQL database before it answers a data question. It starts with a small inventory of the server version, current role and relevant schemas, then narrows to the objects that match the question. The agent is directed to read metadata from pg_catalog using read-only queries, with separate reference notes for tables, partitioning and inheritance, foreign tables, views, routines, triggers, row-level security and extensions.

The workflow asks the agent to corroborate meaning from comments, keys and dependencies rather than trusting names alone. Data-derived statistics or sample rows are off limits until the user approves the specific columns and access method. When SQL is needed, the skill covers establishing join keys and grain and validating a query with a plain EXPLAIN, while avoiding running unknown functions, refreshing materialized views or using EXPLAIN ANALYZE.

It expects a PostgreSQL connection available to the agent, or schema files if no connection exists. The queries target PostgreSQL 18 with notes for older majors. The skill is not meant for schema design or migrations.

## When your agent uses it

> Explore an existing PostgreSQL database before answering questions about its data or writing SQL. Use this skill whenever a user asks for a query or a data-backed answer against an unfamiliar schema (counts, missing or failed records, recent changes), asks where a business concept lives, or asks how tables, joins, views, routines, triggers, RLS, or extensions work. Find the relevant objects with read-only pg_catalog queries, then request approval before inspecting data-derived statistics or rows. Not a schema-design or migration guide.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/timescale/pg-aiguide/tree/HEAD/skills/schema-exploration)
- [License: Apache-2.0](https://github.com/timescale/pg-aiguide/tree/HEAD/skills/schema-exploration)

## Features

- **Database inventory:** Checks the current database, server version, role and scope before choosing schemas to explore.
- **Read-only catalog queries:** Finds relevant tables, views, routines, triggers and extensions through pg_catalog metadata.
- **Approval before data access:** Requires user approval before inspecting data-derived statistics, sample rows or value distributions.
- **Join and grain checks:** Establishes join keys and table grain before drafting SQL against an unfamiliar schema.
- **Safe query validation:** Validates candidate queries with plain EXPLAIN and avoids running unknown functions or analyzing queries.
- **Limitations reporting:** Separates observed facts from inferences and reports permission or version gaps instead of guessing.

## Good for

- Find where customer accounts and orders are stored in an unfamiliar database
- Write a query counting failed payment records in a schema I have not used before
- Explain how a set of views and triggers feed a reporting table
- Check which tables a foreign key relationship connects before writing a join
- Work out whether row-level security limits what a role can read

## Install

### Claude Code

This skill ships in the `pg` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add timescale/pg-aiguide
/plugin install pg@aiguide
```

Or copy only this skill to `~/.claude/skills/schema-exploration`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/schema-exploration &&
cp -R "$tmp/skills/schema-exploration" ~/.claude/skills/schema-exploration &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/schema-exploration` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/schema-exploration` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/schema-exploration &&
cp -R "$tmp/skills/schema-exploration" ~/.agents/skills/schema-exploration &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/schema-exploration` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/schema-exploration` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/schema-exploration &&
cp -R "$tmp/skills/schema-exploration" ~/.cursor/skills/schema-exploration &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/schema-exploration` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/timescale/pg-aiguide.git --path skills/schema-exploration
```

Or copy the folder to `~/.gemini/skills/schema-exploration` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/schema-exploration`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/timescale/pg-aiguide.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/schema-exploration &&
cp -R "$tmp/skills/schema-exploration" ~/.copilot/skills/schema-exploration &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/schema-exploration` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/timescale/pg-aiguide.git
```

Then copy `pg-aiguide/skills/schema-exploration` into your agent's skills folder as `schema-exploration`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Does the skill change my database?

No. It directs the agent to use read-only pg_catalog queries and a read-only transaction where the client supports it, and forbids changing schema, data, roles or session settings without authorization.

### Can the agent look at my table data?

Not by default. Data-derived statistics and rows require approval for the specific columns and access method, and sampling should use explicit limits.

### Which PostgreSQL versions are covered?

The queries target PostgreSQL 18, and version-sensitive sections note alternatives for older major versions. The agent is told to check server_version_num first.

### Is Schema exploration for designing schemas or running migrations?

No. The skill states it is not a schema-design or migration guide; it is for exploring an existing database.

### How do I install Schema exploration in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/schema-exploration to use it in all your projects, or to .claude/skills/schema-exploration in one project. Or install the pg plugin, which includes it: /plugin marketplace add timescale/pg-aiguide, then /plugin install pg@aiguide.

### Does Schema exploration run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Schema exploration?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Schema exploration?

The closest alternatives to Schema exploration are Database migrations, Reviewing oracle to postgres migration, PostgreSQL code review, Dsql on rails and SQL code review.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Database migrations](https://ai-powered.com/skills/database-migrations-nabwinsaud): Database migrations is an open-source agent skill for databases.
- [Reviewing oracle to postgres migration](https://ai-powered.com/skills/reviewing-oracle-to-postgres-migration): Reviewing oracle to postgres migration is an open-source agent skill for databases.
- [PostgreSQL code review](https://ai-powered.com/skills/postgresql-code-review): PostgreSQL code review is an open-source agent skill for databases.
- [Dsql on rails](https://ai-powered.com/skills/dsql-on-rails): Dsql on rails is an open-source agent skill for developer tools.
- [SQL code review](https://ai-powered.com/skills/sql-code-review): SQL code review is an open-source agent skill for databases.
- [Axiom audit database schema](https://ai-powered.com/skills/axiom-audit-database-schema): Axiom audit database schema is an open-source agent skill for developer tools.
- [Planning oracle to postgres migration integration testing](https://ai-powered.com/skills/planning-oracle-to-postgres-migration-integration-testing): Planning oracle to postgres migration integration testing is an open-source agent skill for databases.
- [JSON schema](https://ai-powered.com/skills/json-schema): JSON schema is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/schema-exploration
