Specialist Database Reviewer logo

Specialist Database Reviewer

Community
VenTheZone
specialist-database-reviewer

PostgreSQL specialist for query optimization, schema design, Row Level Security, and performance review. Use when reviewing SQL for slow queries and missing indexes, designing schemas, adding RLS policies, fixing N+1 patterns, or tuning concurrency and connection management.

Overview

PublisherVenTheZone
Repositorypi-dots
Skill namespecialist-database-reviewer
Stars
41
Forks
0
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by VenTheZone on GitHub. Read the source before you install it.

Installation

Install the Specialist Database Reviewer AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/VenTheZone/pi-dots/tree/main/pi-dotfiles-specialist-skills/skills/specialist-database-reviewer
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/VenTheZone/pi-dots.git /tmp/pi-dots
mkdir -p .claude/skills
cp -r /tmp/pi-dots/pi-dotfiles-specialist-skills/skills/specialist-database-reviewer .claude/skills/specialist-database-reviewer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Specialist Database Reviewer in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Specialist Database Reviewer on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Specialist Database Reviewer is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Specialist: Database Reviewer

PostgreSQL specialist focused on query optimization, schema design, security (RLS), and performance. Ensures database code follows best practices, prevents table scans, and maintains data integrity. Incorporates Supabase postgres-best-practices patterns.

Workflow

  1. Measure — pull slow queries, table sizes, and index usage from pg_stat_statements
  2. Review schema — data types, primary keys, constraints, index coverage on WHERE/JOIN columns
  3. Security pass — RLS enabled and optimized on multi-tenant tables, least-privilege access
  4. Concurrency pass — short transactions, SKIP LOCKED for queues, lock strategy
  5. Verify with EXPLAIN — run EXPLAIN ANALYZE on complex queries and confirm the fix

Database Analysis Commands

bash
psql $DATABASE_URL

# Slow queries (requires pg_stat_statements)
psql -c "SELECT query, mean_exec_time, calls FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10;"

# Table sizes
psql -c "SELECT relname, pg_size_pretty(pg_total_relation_size(relid)) FROM pg_stat_user_tables ORDER BY pg_total_relation_size(relid) DESC;"

# Index usage
psql -c "SELECT indexrelname, idx_scan, idx_tup_read FROM pg_stat_user_indexes ORDER BY idx_scan DESC;"

Index Patterns

Index WHERE and JOIN columns — 100–1000x faster on large tables:

sql
-- BAD: no index on foreign key
CREATE TABLE orders (
  id bigint PRIMARY KEY,
  customer_id bigint REFERENCES customers(id)
);

-- GOOD: index on foreign key
CREATE INDEX orders_customer_id_idx ON orders (customer_id);
Index TypeUse CaseOperators
B-tree (default)Equality, range=, <, >, BETWEEN, IN
GINArrays, JSONB, full-text@>, ?, ?&, ?|, @@
BRINLarge time-seriesRange queries on sorted data
HashEquality only= (marginally faster than B-tree)

Composite indexes — equality columns first, then range:

sql
-- BAD: separate indexes
CREATE INDEX orders_status_idx ON orders (status);
CREATE INDEX orders_created_idx ON orders (created_at);

-- GOOD: composite
CREATE INDEX orders_status_created_idx ON orders (status, created_at);

Schema Design Patterns

sql
-- BAD: poor type choices
CREATE TABLE users (
  id int,                           -- overflows at 2.1B
  email varchar(255),               -- artificial limit
  created_at timestamp,             -- no timezone
  is_active varchar(5),             -- should be boolean
  balance float                     -- precision loss
);

-- GOOD: proper types
CREATE TABLE users (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  email text NOT NULL,
  created_at timestamptz DEFAULT now(),
  is_active boolean DEFAULT true,
  balance numeric(10,2)
);

Primary keys: single database → bigint GENERATED ALWAYS AS IDENTITY; distributed systems → UUIDv7 (time-ordered).

Row Level Security

sql
-- BAD: application-only filtering — a bug exposes all rows
SELECT * FROM orders WHERE user_id = $current_user_id;

-- GOOD: database-enforced RLS
ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
ALTER TABLE orders FORCE ROW LEVEL SECURITY;

CREATE POLICY orders_user_policy ON orders
  FOR ALL
  USING ((SELECT auth.uid()) = user_id);  -- SELECT wraps: cached, called once

Avoid per-row function calls — USING (auth.uid() = user_id) runs 1M times for 1M rows. Always index RLS policy columns.

Concurrency & Locking

Keep transactions short — never hold locks across external calls:

sql
-- BAD: lock held during 5s HTTP call
BEGIN;
SELECT * FROM orders WHERE id = 1 FOR UPDATE;
-- HTTP call takes 5 seconds...
UPDATE orders SET status = 'paid' WHERE id = 1;
COMMIT;

-- GOOD: API call outside transaction, lock held for milliseconds
UPDATE orders SET status = 'paid', payment_id = $1
WHERE id = $2 AND status = 'pending'
RETURNING *;

Use SKIP LOCKED for worker queues — 10x throughput:

sql
UPDATE jobs
SET status = 'processing', worker_id = $1, started_at = now()
WHERE id = (
  SELECT id FROM jobs
  WHERE status = 'pending'
  ORDER BY created_at
  LIMIT 1
  FOR UPDATE SKIP LOCKED
)
RETURNING *;

Data Access Patterns

Eliminate N+1 — batch with ANY or JOIN:

sql
SELECT * FROM orders WHERE user_id = ANY(ARRAY[1, 2, 3, ...]);

SELECT u.id, u.name, o.*
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.active = true;

Cursor pagination instead of OFFSET:

sql
-- BAD: OFFSET scans 200k rows at depth
SELECT * FROM products ORDER BY id LIMIT 20 OFFSET 199980;

-- GOOD: cursor-based, index-driven, O(1)
SELECT * FROM products WHERE id > 199980 ORDER BY id LIMIT 20;

Review Checklist

  • All WHERE/JOIN columns indexed
  • Composite indexes in correct column order
  • Proper data types (bigint, text, timestamptz, numeric)
  • RLS enabled on multi-tenant tables
  • RLS policies use (SELECT auth.uid()) pattern
  • Foreign keys have indexes
  • No N+1 query patterns
  • EXPLAIN ANALYZE run on complex queries
  • Lowercase identifiers used
  • Transactions kept short

Remember: Database issues are often the root cause of application performance problems. Use EXPLAIN ANALYZE to verify assumptions. Always index foreign keys and RLS policy columns.

Frequently asked questions

What does the Specialist Database Reviewer AI skill do?

PostgreSQL specialist for query optimization, schema design, Row Level Security, and performance review. Use when reviewing SQL for slow queries and missing indexes, designing schemas, adding RLS policies, fixing N+1 patterns, or tuning concurrency and connection management.

Why use Specialist Database Reviewer on TypingMind?

Because you install it once and use it with any model. Specialist Database Reviewer is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Specialist Database Reviewer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/VenTheZone/pi-dots/tree/main/pi-dotfiles-specialist-skills/skills/specialist-database-reviewer. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Specialist Database Reviewer?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Specialist Database Reviewer?

As many as you like. As long as a model supports skills, you can use Specialist Database Reviewer with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Specialist Database Reviewer AI skill free?

It is published on GitHub by VenTheZone. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇