Skip to content
Back to skills

Databases

BSecurity

PostgreSQL database guide — SQL queries, JOINs, CTEs, window functions, indexing, EXPLAIN/ANALYZE, user management, backups, replication, psql CLI. Use when writing SQL queries, designing schemas, optimizing performance, or administering PostgreSQL databases. For Supabase-specific RLS, SDK, and Postgres tuning see the `supabase` skill.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 11, 2026
databasesbashsqldatabaseperformance

Works with

  • cli

Security analysis

B88/100
  • criticalModifies startup scripts or system services for persistence

Pro scans all 16 files and shows the line behind each finding

Scanned September 11, 2026

npx -y skills add trungdo9/ClauKit --skill databases --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Databases?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Databases
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/trungdo9-databases/badge)](https://www.skillsdirectory.com/skills/trungdo9-databases)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: postgresql
description: PostgreSQL database guide — SQL queries, JOINs, CTEs, window functions, indexing, EXPLAIN/ANALYZE, user management, backups, replication, psql CLI. Use when writing SQL queries, designing schemas, optimizing performance, or administering PostgreSQL databases. For Supabase-specific RLS, SDK, and Postgres tuning see the `supabase` skill.
license: MIT
---

# PostgreSQL

Core guide for working with PostgreSQL — queries, schema design, performance, and administration.

## When to Use

- Writing SQL queries (SELECT, JOINs, subqueries, CTEs, window functions)
- Designing and migrating schemas
- Optimizing indexes and analyzing query performance
- Managing database users and permissions
- Setting up backups, replication, and maintenance
- Using psql CLI

> For Supabase-specific concerns (RLS policies, connection pooling, Edge Functions, supabase-js) → read the `supabase` skill file instead.

## Quick Start

```bash
# Ubuntu/Debian install
sudo apt-get install postgresql postgresql-contrib
sudo systemctl start postgresql

# Connect
psql -U postgres -d mydb
```

## Common Operations

```sql
-- Create table
CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE, created_at TIMESTAMPTZ DEFAULT NOW());

-- CRUD
INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');
SELECT * FROM users WHERE created_at > NOW() - INTERVAL '7 days';
UPDATE users SET name = 'Bob' WHERE id = 1;
DELETE FROM users WHERE id = 1;

-- Index
CREATE INDEX idx_users_email ON users(email);
CREATE INDEX idx_users_status_created ON users(status, created_at DESC);

-- EXPLAIN
EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'alice@example.com';
```

## References

- **[postgresql-queries.md](references/postgresql-queries.md)** — SELECT, JOINs, subqueries, CTEs, window functions
- **[postgresql-psql-cli.md](references/postgresql-psql-cli.md)** — psql commands, meta-commands, scripting
- **[postgresql-performance.md](references/postgresql-performance.md)** — EXPLAIN, query optimization, vacuum, indexes
- **[postgresql-administration.md](references/postgresql-administration.md)** — User management, backups, replication, maintenance
- **[safe-writes.md](references/safe-writes.md)** — **the DB write protocol (mandatory for every mutation)**: reviewed script file → dry-run SELECT with exact row count → paired rollback in the same commit → explicit approval → single-statement comment-free SQL → post-evidence re-count

## Resources

- https://www.postgresql.org/docs/
- https://www.postgresqltutorial.com/

Files in this skill

  • SKILL.md2.5 KB
  • references/postgresql-administration.md11.8 KB
  • references/postgresql-performance.md11.3 KB
  • references/postgresql-psql-cli.md10.3 KB
  • references/postgresql-queries.md9.9 KB
  • references/safe-writes.md3.1 KB
  • scripts/.coverage52 KB
  • scripts/db_backup.py16.4 KB
  • scripts/db_migrate.py13.5 KB
  • scripts/db_performance_check.py10.4 KB
  • scripts/requirements.txt558 B
  • scripts/tests/coverage-db.json46.3 KB
  • scripts/tests/requirements.txt69 B
  • scripts/tests/test_db_backup.py10.5 KB
  • scripts/tests/test_db_migrate.py9.3 KB
  • scripts/tests/test_db_performance_check.py11.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.