Validate with Database
БесплатноБез исполняемых скриптовНе проверенConnect to live PostgreSQL database to validate schema assumptions, compare pg_dump vs pgschema output, and query system catalogs interactively
Об этом скилле
Validate with Database
Use this skill to connect to the test PostgreSQL database, validate assumptions about schema behavior, and cross-validate between pg_dump and pgschema implementations.
When to Use This Skill
Invoke this skill when:
- Validating how PostgreSQL actually stores or represents schema objects
- Comparing pg_dump output with pgschema output
- Testing a new feature implementation against real database
- Debugging schema introspection issues
- Verifying system catalog query results
- Understanding how PostgreSQL formats specific DDL
- Checking version-specific behavior (PostgreSQL 14-17)
- Validating migration plans before implementing new features
Database Connection Information
Connection details are stored in .env file at project root:
PGHOST=localhost
PGDATABASE=employee
PGUSER=postgres
PGPASSWORD=testpwd1
Default connection:
- Host:
localhost - Port:
5432(default) - Database:
employee - User:
postgres - Password:
testpwd1
Connection Methods
Method 1: Using psql (Interactive Queries)
Basic connection:
PGPASSWORD='testpwd1' psql -h localhost -p 5432 -U postgres -d employee
One-off query:
PGPASSWORD='testpwd1' psql -h localhost -p 5432 -U postgres -d employee -c "SELECT version();"
Execute multi-line query:
PGPASSWORD='testpwd1' psql -h localhost -p 5432 -U postgres -d postgres -c "
SELECT
t.tgname,
CASE
WHEN t.tgqual IS NOT NULL
THEN pg_get_expr(t.tgqual, t.tgrelid, false)
ELSE 'NO WHEN CLAUSE'
END as when_clause
FROM pg_catalog.pg_trigger t
JOIN pg_catalog.pg_class c ON t.tgrelid = c.oid
WHERE c.relname = 'test_table'
ORDER BY t.tgname;
"
Method 2: Using pg_dump (Schema Export)
Dump entire database schema:
PGPASSWORD='testpwd1' pg_dump -h localhost -p 5432 -U postgres -d employee --schema-only --schema=public
Dump specific table:
PGPASSWORD='testpwd1' pg_dump -h localhost -p 5432 -U postgres -d employee --schema-only --table=employees
Dump only specific object types:
# Only triggers
PGPASSWORD='testpwd1' pg_dump -h localhost -p 5432 -U postgres -d employee --schema-only --schema=public | grep -A 20 "CREATE TRIGGER"
# Only indexes
PGPASSWORD='testpwd1' pg_dump -h localhost -p 5432 -U postgres -d employee --schema-only --schema=public | grep -A 10 "CREATE INDEX"
Method 3: Using pgschema (Project Tool)
Dump with pgschema:
./pgschema dump --host localhost --port 5432 --db employee --user postgres --schema public
Or using environment variables (from .env):
# .env is automatically loaded by pgschema
./pgschema dump --schema public
Dump to file:
./pgschema dump --schema public -o /tmp/schema_dump.sql
Method 4: Database Setup for Testing
Create a test database:
PGPASSWORD='testpwd1' psql -h localhost -p 5432 -U postgres -c "DROP DATABASE IF EXISTS test_validation;"
PGPASSWORD='testpwd1' psql -h localhost -p 5432 -U postgres -c "CREATE DATABASE test_validation;"
Create test schema objects:
PGPASSWORD='testpwd1' psql -h localhost -p 5432 -U postgres -d test_validation -c "
CREATE TABLE test_table (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TRIGGER test_trigger
BEFORE INSERT ON test_table
FOR EACH ROW
WHEN (NEW.name IS NOT NULL)
EXECUTE FUNCTION my_trigger_func();
"
Common Validation Workflows
Workflow 1: Compare pg_dump vs pgschema Output
Purpose: Verify pgschema produces comparable output to pg_dump
Steps:
- Dump with pg_dump:
PGPASSWORD='testpwd1' pg_dump -h localhost -p 5432 -U postgres -d employee --schema-only --schema=public > /tmp/pg_dump_output.sql
- Dump with pgschema:
./pgschema dump --schema public -o /tmp/pgschema_output.sql
- Compare outputs:
# Side-by-side comparison
diff -u /tmp/pg_dump_output.sql /tmp/pgschema_output.sql
# Or use a better diff tool
code --diff /tmp/pg_dump_output.sql /tmp/pgschema_output.sql
- Analyze differences:
- Formatting differences (expected)
- Missing objects (bugs to fix)
- Different DDL structure (may need investigation)
- Comments handling
- Ordering differences
Workflow 2: Validate System Catalog Queries
Purpose: Test system catalog queries return expected data
Steps:
- Create test object:
PGPASSWORD='testpwd1' psql -h localhost -p 5432 -U postgres -d postgres -c "
CREATE TABLE test_triggers (
id INTEGER PRIMARY KEY,
data TEXT
);
CREATE OR REPLACE FUNCTION trigger_func() RETURNS TRIGGER AS \$\$
BEGIN
RETURN NEW;
END;
\$\$ LANGUAGE plpgsql;
CREATE TRIGGER test_when_trigger
BEFORE INSERT ON test_triggers
FOR EACH ROW
WHEN (NEW.data <> '')
EXECUTE FUNCTION trigger_func();
"
- Query system catalogs:
PGPASSWORD='testpwd1' psql -h localhos
Установить Validate with Database в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл Validate with Database?
Connect to live PostgreSQL database to validate schema assumptions, compare pg_dump vs pgschema output, and query system catalogs interactively
Как установить скилл Validate with Database?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Validate with Database запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic