query-database-schema

query-database-schema is a skill for Claude Code, Codex from antonrisch/db-skills. It costs 40 tokens per session (1,025 once invoked), scanned A, original, MIT.

A guide for inspecting a database's structure and metadata, including tables, columns, data types, indexes, constraints, and relationships between tables.

In plain words
What is it for?
Use it to explore a database, plan joins and aggregations, investigate query behavior, or document the schema.
Why use it?
It helps developers understand an unfamiliar database and check whether their assumptions match the actual structure before writing queries or migrations.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to explore a database, plan joins and aggregations, investigate query behavior, or document the schema.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/antonrisch/db-skills/query-database-schema
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add antonrisch/db-skills --skill query-database-schema
Clone the repo
git clone --depth 1 https://github.com/antonrisch/db-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for query-database-schema

README.md
[![agentmods](https://agentmods.dev/badge/skills/antonrisch/db-skills/query-database-schema/github.svg)](https://agentmods.dev/skills/antonrisch/db-skills/query-database-schema)
Your own site
<a href="https://agentmods.dev/skills/antonrisch/db-skills/query-database-schema"><img src="https://agentmods.dev/badge/skills/antonrisch/db-skills/query-database-schema/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for query-database-schema

Your own site · 80×15
<a href="https://agentmods.dev/skills/antonrisch/db-skills/query-database-schema"><img src="https://agentmods.dev/badge/skills/antonrisch/db-skills/query-database-schema.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,025 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00040 $0.01025
Opus 5.5 $0.00016 $0.00410
Sonnet 5.5 $0.00008 $0.00205
Haiku 4.5 $0.00004 $0.00103

Measured 1mo ago against content hash d53c24c99149, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

query-database-schema scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/query-database-schema/SKILL.md · 215 lines

How it starts

The opening of the file, as written. The whole thing — 215 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Query Database Schema

Quick Start

Use this skill to quickly answer: what tables exist, what columns/types they have, how tables relate, and what constraints/indexes affect query behavior.

When to use this skill

  • onboarding onto an unfamiliar database
  • before writing joins, aggregations, or migrations
  • when app behavior suggests bad assumptions (nullability, defaults, constraints)
  • when documenting schema for teammates

Before running queries, collect:

  • database engine (postgres/mysql/sqlite)
  • database + schema name (if applicable)
  • target tables (or suspected domain area)

Common Database Queries

PostgreSQL

list schemas:

SELECT schema_name
FROM information_schema.schemata
ORDER BY schema_name;

List all tables:

SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public';

Get table structure:

SELECT
    column_name,
    data_type,
    is_nullable,
    column_default
FROM information_schema.columns
WHERE table_name = 'your_table_name'
ORDER BY ordinal_position;

list indexes (including uniqueness):

SELECT
  tablename,
  indexname,
  indexdef
FROM pg_indexes
WHERE schemaname = 'public'
  AND tablename = 'your_table_name'
ORDER BY indexname;

list constraints (pk/unique/check/fk):

SELECT
  tc.constraint_type,
  tc.constraint_name,
  kcu.column_name
FROM information_schema.table_constraints tc
LEFT JOIN information_schema.key_column_usage kcu
  ON tc.constraint_name = kcu.constraint_name
  AND tc.table_schema = kcu.table_schema
WHERE tc.table_schema = 'public'
  AND tc.table_name = 'your_table_name'
ORDER BY tc.constraint_type, tc.constraint_name, kcu.ordinal_position;

Find foreign key relationships:

SELECT
    tc.table_name,
    kcu.column_name,
    ccu.table_name AS foreign_table_name,
    ccu.column_name AS foreign_column_name
FROM information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
    ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage AS ccu
    ON ccu.constraint_name = tc.constraint_name
WHERE tc.constraint_type = 'FOREIGN KEY';

Read the full file on GitHub · 215 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 215 lines · 40 tokens per session scan A d53c24c99149

Subscribe to this mod's changes

query-database-schema is a skill published in the GitHub repository antonrisch/db-skills (9 stars, last pushed 9mo ago), licensed MIT. It adds 40 tokens to every session and 1,025 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

alloydb-basics

Manages clusters, instances, and backups for AlloyDB for PostgreSQL, and integrates with AlloyDB Model Context Protocol (MCP) tools for automated database operations. Use when creating, configuring, or administering AlloyDB databases. Do NOT use for general PostgreSQL instances (e.g. Cloud SQL) or other GCP databases.

google/skills · 72 tokens

cloud-databases-onboarding

Guides users through discovering their database requirements, recommends a Google Cloud database based on a recommendation matrix, and assists in database creation. Use when a user asks 'What database service should I use?', 'Help me pick a database', or when a user wants to create a new database on Google Cloud.…

google/skills · 83 tokens

spanner-basics

Assists in provisioning instances and databases, designing performant schemas, and querying data in Cloud Spanner on Google Cloud. Use when designing primary keys, writing SQL queries or client library code, or diagnosing performance issues.

google/skills · 47 tokens

obsidian-bases

Create and edit Obsidian Bases (.base files) with views, filters, formulas, and summaries. Use when working with .base files, creating database-like views of notes, or when the user mentions Bases, table views, card views, filters, or formulas in Obsidian.

kepano/obsidian-skills · 63 tokens

similarity-search-patterns

Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.

foryourhealth111-pixel/Vibe-Skills · 30 tokens

supabase

Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies…

supabase/agent-skills · 185 tokens